A RESTful API for managing personal expenses and funds.
- User authentication and authorization
- CRUD operations for expenses
- CRUD operations for categories
- CRUD operations for funds
- Fund transactions tracking
- Linking expenses with funds
- Default fund support
- Fund balance management
- Fund transfers between accounts
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout user
GET /api/categories- Get all categoriesPOST /api/categories- Create a new categoryPUT /api/categories/:id- Update a categoryDELETE /api/categories/:id- Delete a category
GET /api/costs- Get all costs (with optional date range filter)POST /api/cost- Create a new costPUT /api/cost/:id- Update a costDELETE /api/cost/:id- Delete a cost
GET /api/funds- Get all fundsPOST /api/funds- Create a new fundPUT /api/funds/:id- Update a fundDELETE /api/funds/:id- Delete a fundGET /api/funds/:id- Get fund detailsGET /api/funds/:id/transactions- Get fund transactionsPOST /api/funds/transfer- Transfer money between funds
POST /api/cost
{
"amount": 100,
"category": "categoryId",
"comment": "Grocery shopping",
"userId": "userId",
"date": "2024-03-20T10:00:00Z",
"fund": "fundId" // Optional: link cost to a specific fund
}POST /api/funds
{
"name": "Main Account",
"icon": "💰",
"description": "Primary spending account",
"initialBalance": 1000,
"isDefault": true,
"userId": "userId"
}POST /api/funds/transfer
{
"userId": "userId",
"fromFundId": "sourceFundId",
"toFundId": "targetFundId",
"amount": 500,
"description": "Transfer to savings"
}- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT for authentication
- Clone the repository
- Install dependencies:
npm install
- Create a
.envfile with the following variables:MONGODB_URI=your_mongodb_uri JWT_SECRET=your_jwt_secret PORT=3000 - Start the server:
npm start
To run the server in development mode with auto-reload:
npm run devTo run tests:
npm test