This is a Node.js-based API for tracking personal expenses, built using Express, PostgreSQL (with Prisma ORM), and JWT for authentication. The API allows users to create accounts, log in, manage their expenses, and filter expenses by different time periods.
- User authentication (Sign up, Login, JWT token generation)
- Protected expense-related endpoints
- CRUD operations on expenses (Create, Read, Update, Delete)
- Expense filtering options:
- Past week
- Last month
- Last 3 months
- Custom date ranges
- Expense categories:
- Groceries
- Leisure
- Electronics
- Utilities
- Clothing
- Health
- Others
- Node.js (v14 or later)
- Docker and Docker Compose
- PostgreSQL (if not using Docker)
git clone https://github.com/MohakGupta2004/expenses-backend
cd expense-backend
npm install
Create a .env
file in the root of the project and fill in the following:
DATABASE_URL="postgresql://your_username:your_password@localhost:5432/your_database"
JWT_SECRET="your_secret_key"
docker run -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
npx prisma migrate dev --name init
npx prisma generate
npm run dev
POST /signup
- Create a new userPOST /login
- Login and get JWT token
GET /expenses
- List all expenses (with optional filters)POST /expenses
- Add a new expensePUT /expenses/:id
- Update an existing expenseDELETE /expenses/:id
- Delete an expense
- Past week
- Last month
- Last 3 months
- Custom date range (start and end date)
- Node.js
- Express
- PostgreSQL
- Prisma ORM
- JWT for Authentication
- Docker (optional for PostgreSQL)
This project is licensed under the MIT License.