This is a RESTful API that allows users create, read, update and delete their personal budget. The personal budget follows the principles of envelope budgeting, where users allocate a certain amount of money to different categories and track their spending. Learn more here: Envelope Budgeting
- Node.js
- Express.js
- TypeScript
- PostgreSQL
-
Envelope
- id: number
- name: string
- amount: number
-
Transaction
- id: number
- date: date
- amount: number
- recipient: string
- envelope_id: number
GET /api/envelopes/- Get all envelopesGET /api/envelopes/:id- Get an envelope by idPOST /api/envelopes/- Create a new envelope- Sample request Body:
{ "name": "Gym", "amount": 40.00 }
- Sample request Body:
POST /api/envelopes/transfer- Transfer money from one envelope to another using the envelope ids- Sample request Body:
{ "fromEnvelopeId": 1, "toEnvelopeId": 7, "amount": 50.00 }
- Sample request Body:
PUT /api/envelopes/:id- Update an envelope by id- Sample request Body:
{ "id": 8, "name": "Gym", "amount": 50.00 }
- Sample request Body:
DELETE /api/envelopes/:id- Delete an envelope by id
GET /api/transactions/- Get all transactionsGET /api/transactions/:id- Get a transaction by idPOST /api/transactions/- Create a new transaction- Sample request Body:
{ "date": "2021-09-01", "amount": 40.00, "recipient": "Planet Fitness", "envelopeId": 1 }
- Sample request Body:
PUT /api/transactions/:id- Update a transaction by id- Sample request Body:
{ "id": 1, "date": "2021-09-01", "amount": 50.00, "recipient": "Planet Fitness", "envelopeId": 1 }
- Sample request Body:
DELETE /api/transactions/:id- Delete a transaction by id
- Node.js
- TypeScript
- PostgreSQL (running on port 5432)
- Postman
- pnpm (optional but recommended)
-
Clone the repository
-
Install the dependencies
pnpm install
-
Create a
.envfile in the root directory and add the following environment variables:DB_USER=<your_postgres_username> DB_HOST=localhost DB_NAME=<your_database_name> DB_PASSWORD=<your_postgres_password> DB_PORT=<your_postgres_port>
-
Initialize the database with schema and seed data
psql -U <your_postgres_username> -d <your_database_name> -a -f src/db/schema.sql psql -U <your_postgres_username> -d <your_database_name> -a -f src/db/data.sql -
Run the server
pnpm start
-
Open Postman and test the API endpoints personal-budget
- Add front-end to interact with the API
- Document the API using Swagger
- Deploy to Render
This project was realized with the help of the following resources: