Skip to content

Niroop8305/Expense-Management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Expense Management System

A full-stack MERN application for managing company expenses with multi-level approval workflows.

Tech Stack

Frontend

  • Build Tool: Vite 5.0
  • Framework: React 18.2 (JSX)
  • Styling: TailwindCSS 3.4
  • Routing: React Router DOM 6.20
  • HTTP Client: Axios 1.5
  • Charts: Chart.js 4.x + react-chartjs-2 5.x

Backend

  • Runtime: Node.js
  • Framework: Express.js 4.18
  • Database: MongoDB with Mongoose 7.5
  • Authentication: JWT (jsonwebtoken)
  • Password Hashing: bcryptjs 2.4
  • File Upload: Multer
  • Email: Nodemailer

Features (Current Phase)

Core Features

  • โœ… Company registration with automatic admin user creation
  • โœ… Country-based currency auto-selection (195+ countries)
  • โœ… Secure password hashing with bcrypt
  • โœ… RESTful API architecture
  • โœ… Multi-role dashboards (Admin/Manager/Employee)
  • โœ… Advanced filtering and search
  • โœ… Change password feature

Security & Authentication

  • โœ… Forgot Password with Email Verification (6-digit code, 10-min expiry)
  • โœ… JWT authentication (7-day expiry)
  • โœ… Role-based access control (Admin/Manager/Employee)

Expense Management

  • โœ… Receipt upload for expenses (images & PDFs, 5MB limit)
  • โœ… CSV export functionality with role-based filtering
  • โœ… Multi-level expense approval workflow
  • โœ… Rejection reasons tracking

Email Notifications ๐Ÿ“ง

  • โœ… Password reset emails with verification code
  • โœ… Expense submission notifications to managers
  • โœ… Expense approval confirmations to employees
  • โœ… Expense rejection notifications with reasons
  • โœ… Welcome emails for new users with credentials
  • โœ… Professional HTML email templates (responsive design)

Data Visualization ๐Ÿ“Š

  • โœ… Interactive Charts with Chart.js
  • โœ… Expense by Category - Pie/Doughnut chart
  • โœ… Expense Trends - Line chart over time
  • โœ… Status Distribution - Bar chart (Pending/Approved/Rejected)
  • โœ… Top Categories - Horizontal bar chart
  • โœ… Real-time data updates
  • โœ… Responsive chart design

UI/UX Enhancements

  • โœ… Dark Mode ๐ŸŒ™ (System preference detection, localStorage persistence)
  • โœ… Comprehensive animations (fadeIn, slideIn, scaleIn, shake, pulse)
  • โœ… Smooth transitions and hover effects
  • โœ… Mobile-responsive design
  • โœ… Color-coded status badges
  • โœ… Loading states and spinners
  • โœ… Toast notifications

Project Structure

Expense-Management/
โ”œโ”€โ”€ backend/          # Express.js API server
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ models/   # Mongoose schemas
โ”‚   โ”‚   โ”œโ”€โ”€ routes/   # API endpoints
โ”‚   โ”‚   โ””โ”€โ”€ utils/    # DB connection
โ”‚   โ””โ”€โ”€ package.json
โ””โ”€โ”€ frontend/         # Vite + React app
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ pages/    # React pages
    โ”‚   โ””โ”€โ”€ App.jsx
    โ””โ”€โ”€ package.json

Setup Instructions (Windows PowerShell)

Prerequisites

  • Node.js (v18+)
  • MongoDB (running locally or MongoDB Atlas)
  • Git

Backend Setup

  1. Navigate to backend folder:
cd backend
  1. Install dependencies:
npm install
  1. Create .env file:
Copy-Item .env.example .env
  1. Update .env with your MongoDB connection string if needed.

  2. Start the backend server:

npm start

The backend will run on http://localhost:5000

Frontend Setup

  1. Open a new terminal and navigate to frontend folder:
cd frontend
  1. Install dependencies:
npm install
  1. Start the development server:
npm run dev

The frontend will run on http://localhost:5173

Visual Charts & Analytics ๐Ÿ“Š

The application features comprehensive data visualization using Chart.js to help users understand their expense patterns:

Available Charts

  1. Expense by Category (Pie/Doughnut Chart)

    • Visual breakdown of expenses by category
    • Interactive legends
    • Percentage distribution
    • Color-coded categories
  2. Expense Trends Over Time (Line Chart)

    • Track spending patterns over months
    • Multiple datasets for different categories
    • Smooth curves with tension
    • Responsive tooltips
  3. Status Distribution (Bar Chart)

    • Compare pending, approved, and rejected expenses
    • Count and amount visualizations
    • Color-coded by status (yellow/green/red)
  4. Top Spending Categories (Horizontal Bar)

    • Identify highest expense categories
    • Sorted by amount
    • Easy comparison across categories

Chart Features

  • โœ… Real-time updates - Charts refresh with data changes
  • โœ… Interactive tooltips - Hover for detailed information
  • โœ… Responsive design - Adapts to screen size
  • โœ… Smooth animations - Professional transitions
  • โœ… Role-based data - Each role sees relevant data
  • โœ… Custom colors - Brand-consistent color palette
  • โœ… Export-ready - Charts can be exported as images

Viewing Charts

  • Employee Dashboard: Personal expense analytics
  • Manager Dashboard: Team expense overview
  • Admin Dashboard: Company-wide analytics

Dark Mode ๐ŸŒ™

The application features a complete dark mode implementation for comfortable viewing in low-light conditions:

Features

  • ๐ŸŽจ Complete UI Coverage: All pages, components, and charts support dark mode
  • ๐Ÿ’พ Persistent Preference: Your theme choice is saved in localStorage
  • ๐Ÿ”„ System Sync: Automatically detects your system's dark mode preference
  • โšก Instant Toggle: Switch between light and dark themes with one click
  • ๐Ÿ“Š Chart Compatibility: All Chart.js visualizations adapt to dark mode
  • ๐ŸŽฏ Consistent Design: Carefully crafted dark color palette for optimal readability

Supported Components

  • โœ… Authentication pages (Login, Register, Forgot Password)
  • โœ… All dashboards (Employee, Manager, Admin)
  • โœ… Settings page
  • โœ… Forms and input fields
  • โœ… Tables and data grids
  • โœ… Charts and visualizations
  • โœ… Status badges and alerts
  • โœ… Navigation headers

Color Palette

Dark Mode Colors:

  • Background: #0f172a (slate-900)
  • Cards: #1e293b (slate-800)
  • Borders: #334155 (slate-700)
  • Text: #e2e8f0 (slate-200)
  • Muted Text: #94a3b8 (slate-400)

How to Use

  1. Look for the sun/moon toggle button in the top-right corner of any page
  2. Click to switch between light and dark themes
  3. Your preference is automatically saved for future visits

Technical Implementation

  • Tailwind CSS: darkMode: 'class' strategy
  • React Context: ThemeContext provides global state management
  • Chart.js: Dynamic color configuration based on theme
  • localStorage: Theme persistence across sessions

Email Notifications ๐Ÿ“ง

Automated email notifications keep all stakeholders informed:

Email Types

  1. Password Reset - 6-digit verification code (10-min expiry)
  2. Expense Submitted - Notify manager of new submissions
  3. Expense Approved - Confirm approval to employee
  4. Expense Rejected - Notify with rejection reason
  5. New User Welcome - Credentials and onboarding info

Email Features

  • โœ… Professional HTML templates
  • โœ… Mobile-responsive design
  • โœ… Color-coded by type
  • โœ… Automatic sending
  • โœ… Error handling & logging

Configuration

See EMAIL_SETUP.md for Gmail configuration instructions.

API Endpoints

POST /api/auth/register-company

Register a new company with an admin user.

Request Body:

{
  "companyName": "Acme Corp",
  "country": "US",
  "adminName": "John Doe",
  "adminEmail": "john@acme.com",
  "adminPassword": "securepassword123"
}

Response:

{
  "message": "Company and admin created",
  "company": {
    "id": "...",
    "name": "Acme Corp",
    "currency": "USD"
  },
  "admin": {
    "id": "...",
    "email": "john@acme.com",
    "name": "John Doe"
  }
}

Supported Features by Role

Admin ๐Ÿ‘‘

  • View all company expenses
  • Manage users (create, edit, delete employees & managers)
  • Approve/reject any expense
  • Access all analytics and reports
  • Export complete company data
  • Change user roles

Manager ๐Ÿ‘ฅ

  • View team expenses
  • Approve/reject team member expenses
  • Submit personal expenses
  • View team analytics
  • Export team expense data
  • Assign expenses to employees

Employee ๐Ÿ‘ค

  • Submit expenses with receipts
  • Track expense status
  • View personal analytics
  • Export personal expense history
  • Update profile & change password
  • Upload receipt images/PDFs

Supported Countries & Currencies

The system supports 195+ countries with automatic currency detection via REST Countries API.

Popular currencies:

  • ๐Ÿ‡บ๐Ÿ‡ธ US โ†’ USD ($)
  • ๐Ÿ‡ฎ๐Ÿ‡ณ IN โ†’ INR (โ‚น)
  • ๐Ÿ‡ฌ๐Ÿ‡ง GB โ†’ GBP (ยฃ)
  • ๐Ÿ‡ช๐Ÿ‡บ EU โ†’ EUR (โ‚ฌ)
  • ๐Ÿ‡ฏ๐Ÿ‡ต JP โ†’ JPY (ยฅ)
  • ๐Ÿ‡จ๐Ÿ‡ฆ CA โ†’ CAD (C$)
  • ๐Ÿ‡ฆ๐Ÿ‡บ AU โ†’ AUD (A$)
  • And 188+ more!

Documentation

  • EMAIL_SETUP.md - Gmail configuration for email notifications
  • EMAIL_NOTIFICATIONS.md - Complete email system documentation
  • EMAIL_QUICK_REFERENCE.md - Quick setup guide for emails
  • FORGOT_PASSWORD_IMPLEMENTATION.md - Password reset feature details
  • HACKATHON_STRATEGY.md - Feature roadmap and priorities

Project Highlights

What Makes This Special

  • ๐ŸŽจ Professional UI/UX - Smooth animations, modern design
  • ๐Ÿ“Š Data Visualization - Interactive charts with Chart.js
  • ๐Ÿ“ง Email Integration - Automated notifications with HTML templates
  • ๐Ÿ” Security - JWT auth, password hashing, reset verification
  • ๐Ÿ“ฑ Responsive - Works perfectly on mobile and desktop
  • ๐ŸŒ Global - Supports 195+ countries and currencies
  • ๐Ÿ“„ Receipt Management - Upload and view receipt images/PDFs
  • ๐Ÿ“ˆ Analytics - Real-time expense insights and trends
  • ๐Ÿ”„ Workflow - Complete approval/rejection workflow
  • ๐Ÿ’พ Export - CSV export for reporting

Architecture Highlights

  • RESTful API design
  • JWT-based authentication
  • Role-based access control (RBAC)
  • MongoDB with Mongoose ODM
  • Multer for file uploads
  • Nodemailer for emails
  • React with functional components
  • TailwindCSS for styling
  • Chart.js for data visualization

Future Enhancements

  • Multi-level approval chains (threshold-based)
  • Budget tracking and alerts
  • Expense categories customization
  • Advanced analytics dashboard
  • Mobile app (React Native)
  • Integration with accounting software
  • Recurring expense templates
  • Expense report generation (PDF)
  • Dark mode
  • Multi-language support

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors