A REST API project for managing employee expenses with authentication, role-based authorization, approval workflows, department budgets, filtering, and finance reporting.
Developed using Node.js, Express.js, TypeScript, MongoDB Atlas, Mongoose, JWT Authentication, and bcrypt.
# Quick Start
git clone https://github.com/ARYAN0-work/Expense-Tracker-with-Approvals.git
cd Expense-Tracker-with-Approvals
pnpm install
pnpm seed
pnpm devBase URL
https://expense-tracker-with-approvals.onrender.com/api/v1
GitHub Repository
https://github.com/ARYAN0-work/Expense-Tracker-with-Approvals
- User Registration
- User Login
- JWT Authentication
- Password Hashing (bcrypt)
- Protected Routes
- Role Based Authorization
- Create Draft Expense
- Edit Draft Expense
- Delete Draft Expense
- Submit Expense
- View Own Expenses
- Reopen Rejected Expense
- View Department Expenses
- Approve Submitted Expenses
- Reject Submitted Expenses
- Cannot Approve Own Expenses
- Cannot Reject Own Expenses
- Read-only access to expenses
- Department Budget Usage
- Department Filtering
- Organization-wide visibility
- Create Expense
- Update Draft Expense
- Delete Draft Expense
- Submit Expense
- Get Expense by ID
- Get All Expenses
- Filtering
- Pagination
- Sorting
Draft
│
▼
Submitted
│
├────────► Approved
│
└────────► Rejected
│
▼
Reopened
│
▼
Draft
- Can edit only Draft expenses
- Can delete only Draft expenses
- Can submit only Draft expenses
- Can reopen only Rejected expenses
- Can access only their own expenses
- Can approve only Submitted expenses
- Can reject only Submitted expenses
- Cannot approve/reject own expenses
- Limited to their department
- Read-only access
- Cross-department visibility
- Budget tracking
- Node.js
- Express.js
- TypeScript
- MongoDB Atlas
- Mongoose
- JWT
- bcrypt
- pnpm
- Husky
- Prettier
- Render
src
│
├── common
│ └── errors
│
├── config
├── db
│
├── modules
│ ├── auth
│ ├── department
│ ├── expense
│ └── user
│
├── seed
│
├── app.ts
└── server.ts
git clone https://github.com/ARYAN0-work/Expense-Tracker-with-Approvals.gitcd Expense-Tracker-with-Approvalspnpm installCreate a .env
PORT=5000
MONGO_URI=<your_mongodb_connection_string>
JWT_SECRET=<your_secret_key>
JWT_EXPIRES_IN=7dpnpm seedThis creates
- Departments
- Employee User
- Manager User
- Finance User
- Draft Expense
- Submitted Expense
- Approved Expense
- Rejected Expense
pnpm devpnpm build
pnpm start| Role | Password | |
|---|---|---|
| Employee | employee@example.com | Password123! |
| Manager | manager@example.com | Password123! |
| Finance | finance@example.com | Password123! |
| Method | Endpoint |
|---|---|
| POST | /auth/register |
| POST | /auth/login |
| Method | Endpoint |
|---|---|
| POST | /expenses |
| GET | /expenses |
| GET | /expenses/:id |
| PATCH | /expenses/:id |
| DELETE | /expenses/:id |
| PATCH | /expenses/:id/submit |
| PATCH | /expenses/:id/reopen |
| Method | Endpoint |
|---|---|
| GET | /manager/expenses |
| PATCH | /manager/expenses/:id/approve |
| PATCH | /manager/expenses/:id/reject |
| Method | Endpoint |
|---|---|
| GET | /finance/expenses |
| GET | /finance/budget/:departmentId |
- Status
- Category
- Date Range
- Amount Range
- Department (Finance)
- Pagination
- Sorting
Each expense contains
- Title
- Amount
- Currency
- Category
- Description
- Employee
- Department
- Status
- Approved By
- Receipt URL
- Notes
- Rejection Reason
Implemented
- JWT Authentication
- Password Hashing
- Protected Routes
- Role Based Authorization
- Ownership Validation
- Department Isolation
- Business Rule Validation
- Input Validation
Department budget usage is calculated using MongoDB Aggregation.
Returns
- Budget
- Approved Spending
- Remaining Budget
| Code | Meaning |
|---|---|
| 200 | OK |
| 201 | Created |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 409 | Conflict |
| 422 | Unprocessable Entity |
| 500 | Internal Server Error |
The repository includes an exported Insomnia Collection.
Import the provided Expense-Tracker-with-Approvals.yaml file into Insomnia. The collection includes all tested endpoints and a pre-configured Base Environment for the deployed API.
- Hosting: Render
- Database: MongoDB Atlas
Aryan Mishra