๐Ÿš€ Building My First Backend Project: Expense Tracker API

Published: (March 7, 2026 at 07:36 PM EST)
2 min read
Source: Dev.to

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:

  • id
  • name
  • createdAt
  • updatedAt

Expenses

Expenses represent individual financial records. Each expense contains:

  • id
  • title
  • amount
  • categoryId (foreign key)
  • createdAt
  • updatedAt

The categoryId links each expense to a category, ensuring proper categorization.

API Endpoints

Standard REST endpoints are provided.

Categories

  • POST /categories
  • GET /categories
  • GET /categories/:id
  • PUT /categories/:id
  • DELETE /categories/:id

Expenses

  • POST /expenses
  • GET /expenses
  • GET /expenses/:id
  • PUT /expenses/:id
  • DELETE /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
0 views
Back to Blog

Related posts

Read more ยป

Gestor de Tareas Full-Stack (Go + Angular)

๐Ÿš€ Saliendo de la zona de confort: Mi viaje Fullโ€‘Stack de Go a Angular Como desarrollador Frontโ€‘end, disfruto creando interfaces fluidas y reactivas. Sin embarg...