A full-stack expense tracking application built with Express, Prisma ORM, PostgreSQL/Supabase, JWT authentication, and Tailwind CSS.
- User registration, login, and logout
- Password hashing with bcrypt
- JWT authentication using HTTP-only cookies
- Authorization header fallback for API clients
- Add, view, and delete personal expenses
- User-specific expense access control
- Prisma ORM with PostgreSQL/Supabase
- Tailwind CSS frontend assets
- Node.js
- Express.js
- Prisma ORM
- PostgreSQL / Supabase
- JWT
- bcrypt
- Tailwind CSS
.
|-- db.js
|-- server.js
|-- prisma/
| `-- schema.prisma
|-- public/
| |-- index.html
| |-- output.css
| `-- script.js
`-- src/
|-- controllers/
| |-- auth.js
| `-- expenses.js
|-- middleware/
| `-- authTokenChecker.js
|-- routes/
| |-- authRuth.js
| `-- expense.js
`-- input.css
git clone https://github.com/ShubhamTiwari007xx/expensetrackingapp.git
cd expensetrackingappnpm installfor auth , cookie etc download the necessary packages
Create a .env file in the project root:
DATABASE_URL="your_postgresql_or_supabase_connection_string"
JWT_SECRET="your_jwt_secret"Generate the Prisma client:
npx prisma generatePush the schema to your database:
npx prisma db pushnpm run devThe server runs at:
http://localhost:5000
npm run devRuns the Express server with Nodemon and watches Tailwind CSS.
npm run build:cssBuilds Tailwind CSS from src/input.css into public/output.css.
npm run watch:cssWatches Tailwind CSS and rebuilds on changes.
| Method | Endpoint | Description |
|---|---|---|
| POST | /auth/register |
Register a new user |
| POST | /auth/login |
Log in an existing user |
| POST | /auth/logout |
Log out the current user |
These routes require authentication through the token cookie or an Authorization: Bearer <token> header.
| Method | Endpoint | Description |
|---|---|---|
| GET | /expenses |
Get expenses for the logged-in user |
| POST | /expenses |
Create a new expense |
| DELETE | /expenses/:id |
Delete one of the logged-in user's expenses |
{
"username": "shubham",
"email": "shubham@example.com",
"password": "password123"
}{
"title": "Groceries",
"amount": 500,
"category": "Food"
}The app uses two main Prisma models:
User: stores username, email, hashed password, and related expensesExpense: stores title, amount, category, timestamp, and owner user ID- stores amounts by adding them
- Do not commit your
.envfile. - For production, update cookie security settings to use secure cookies over HTTPS.
- The default server port is
5000.