Backend server for the Budgetly personal finance app β track expenses, incomes, and get AI-powered spending insights. Built with Node.js, Express, MongoDB, and OpenAI API.
- π JWT Authentication (Register/Login)
- πΈ Track income and expenses in one schema
- π AI-generated budget insights and savings suggestions
- π§ Logs all user AI queries for future reference
- π§Ύ REST API with clean endpoints
- π CORS and environment-based config
| Layer | Tool |
|---|---|
| Server | Node.js + Express.js |
| Auth | JWT |
| Database | MongoDB + Mongoose |
| AI Engine | OpenAI API |
| Middleware | CORS, dotenv |
/budgetly-api
βββ index.js
βββ package.json
βββ .env
βββ /routes
β βββ authRoutes.js
β βββ transactionsRoutes.js
β βββ aiPromptRoutes.js
βββ /controllers
β βββ authController.js
β βββ transactionsController.js
β βββ aiPromptsController.js
βββ /middleware
β βββ verifyJWT.js
βββ /models
β βββ User.js
β βββ Transaction.js
β βββ AIPrompt.js
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/register |
Register a new user |
| POST | /api/login |
Login and get token |
| GET | /api/transactions |
Get user's transactions |
| POST | /api/transactions |
Add new income/expense |
| PUT | /api/transactions |
Edit income/expense |
| POST | /api/ai/generate |
Get AI insight response |
Create a .env file in the root with the following:
PORT=3000
MONGO_URI=your_mongo_connection_string
JWT_SECRET=your_very_secure_jwt_secret
OPENAI_API_KEY=sk-xxxxxx
npm install
npm run devMake sure MongoDB is running locally or provide a MongoDB Atlas URI.
This backend uses JWT for protected routes. Send the token in headers like so:
Authorization: Bearer <your-token>- Auth & basic transactions
- AI integration (OpenAI)
- Budget summaries by month
- Expense category analytics
- Email reports (SendGrid)
- Push notifications (via Firebase FCM)
MIT β feel free to fork, learn, and build your own budget tracker!
Shan Ayub β LinkedIn
For full project UI & wireframes, see the frontend repo: budgetly-app