๐ Building My First Backend Project: Expense Tracker API
Source: Dev.to
Project Overview
The Expense Tracker API is a RESTful backend service that allows users to:
- Create and manage expense categories
- Add and track expenses
- Organize expenses by category
- Perform CRUD operations through API endpoints
It can serve as the backend engine for a mobile app, web dashboard, or financial management system.
Tech Stack
- Node.js โ Runtime environment
- Express.js โ Web framework for building the API
- PostgreSQL โ Relational database
- Sequelize ORM โ Database modeling and migrations
- Docker โ Containerized development environment
- TablePlus โ Database management
These tools helped illustrate how modern backend systems are structured and deployed.
Database Design
The API is built around two main entities:
Categories
Categories help organize expenses into groups such as:
- Food
- Transportation
- Utilities
- Entertainment
Each category contains:
idnamecreatedAtupdatedAt
Expenses
Expenses represent individual financial records. Each expense contains:
idtitleamountcategoryId(foreign key)createdAtupdatedAt
The categoryId links each expense to a category, ensuring proper categorization.
API Endpoints
Standard REST endpoints are provided.
Categories
POST /categoriesGET /categoriesGET /categories/:idPUT /categories/:idDELETE /categories/:id
Expenses
POST /expensesGET /expensesGET /expenses/:idPUT /expenses/:idDELETE /expenses/:id
These endpoints enable full CRUD functionality for managing financial data.
Key Things I Learned
Building this project deepened my understanding of several backend concepts.
Database Migrations
Sequelize migrations allowed versionโcontrolled schema changes, eliminating the need for manual table creation.
Model Relationships
Linking expenses to categories via a foreign key clarified how relational databases enforce data integrity.
API Architecture
I organized the project into:
- Routes
- Controllers
- Models
- Migrations
This separation keeps the codebase clean and maintainable.
Error Handling
Common issues encountered included:
- Migration order errors
- Database connection problems
- Incorrect model references
Debugging these improved my grasp of backend behavior.
Using Docker for Development
Docker standardizes the development environment, ensuring the application runs consistently across different systems by packaging the runtime, dependencies, and configuration together.
Future Improvements
Planned enhancements:
- User authentication (JWT) โ already implemented
- Expense filtering by date
- Pagination for large datasets
- Expense analytics endpoints
- API documentation with Swagger