Skip to content

A comprehensive API designed to manage and track personal finances. It is built with Node.js, Express, MongoDB, Redis & Docker..

License

Notifications You must be signed in to change notification settings

nmdra/Finance-Tracker-API

Repository files navigation

Finance Tracker API

A comprehensive API designed to manage and track personal finances. This API includes features for user authentication, transaction management, budget tracking, goal setting, and real-time notifications. It is built with Node.js, Express, MongoDB, and Redis.

Important

The Docker Production Image is available for use at: GitHub Container Registry.

For detailed deployment instructions, please refer to the Production Deployment section.

Features

  • User Management: Register, authenticate, and manage user data.
  • Transaction Tracking: Log and track financial transactions.
  • Budget Management: Create and manage financial budgets.
  • Goal Tracking: Set and monitor progress toward financial goals.
  • Notifications: Notifications about spending patterns, deadlines, and goals.
  • Automate Jobs
  • Data Caching (Redis)
  • Email Handling

Libraries and Frameworks

  1. Express - Minimalist web framework for Node.js.
  2. Mongoose - ODM for MongoDB.
  3. Bcryptjs - Library to hash passwords.
  4. Axios,Axios-Retry - Promise-based HTTP client.
  5. JWT - Library for generating JSON Web Tokens.
  6. Pino, Pino-Http, Pino-Pretty - JSON logger.
  7. Http-Status-Codes - HTTP status code constants.
  8. Ioredis - Redis client for Node.js.
  9. Nodemailer + MailTrap - Email Handling.
  10. Croner - Job Scheduling.

🛡 Security Features

Note

The production Docker image uses Chainguard Images, a secure, minimal container image for better security and a lower attack surface.

Trivy Vulnerability Scanning is integrated into the GitHub Actions to scan for vulnerabilities in the Docker image before deployment.

  • Authentication & Authorization → Uses JWT for secure authentication and bcryptjs for password hashing.
  • Input Validation & Sanitization → Implements express-mongo-sanitize to prevent NoSQL injections and helmet for security headers.
  • Rate Limiting & Logging → Uses express-rate-limit to prevent abuse and Pino for high-performance logging.
  • Testing & Mocking → Includes Chai, Mocha, and Nock for API testing.

🌐 API

Tip

The full API documentation can be found here 👉 documenter.getpostman.com/view/33227780/2sAYdoF7xS

  • Health Check: /api/{API_VERSION}/health - Check server status
  • User Routes: /api/{API_VERSION}/user - User registration and authentication
  • Transaction Routes: /api/{API_VERSION}/transaction - Manage transactions
  • Budget Routes: /api/{API_VERSION}/budget - Budget management
  • Goal Routes: /api/{API_VERSION}/goal - Set and track financial goals
  • Notification Routes: /api/{API_VERSION}/notification - Real-time notifications
  • Analytics & Reports routes: /api/{API_VERSION}/analytics - Reports

🏗 Development Setup

Prerequisites

  • Node.js
  • Docker

Clone the repository

git clone https://github.com/nmdra/Finance-Tracker-API.git
cd Finance-Tracker-API

Environment variables

Create a .env file in the root directory based on .env.example

DB_USERNAME=yourMongoDBUsername
DB_PASSWORD=yourMongoDBPassword
API_VERSION=v1

Get Exchange-API Key : https://www.exchangerate-api.com/

Running the application

To start the application in development mode:

docker-compose up

This will start the API Service, MongoDB, Redis, and the MongoDB Dashboard.

  • app: Node.js application container
  • db: MongoDB database container
  • db-dashboard: MongoDB Express dashboard for managing the database
  • redis: Redis cache for the application

Testing

Run following command after running docker compose up:

docker compose exec app npm test

🚀 Production Deployment

The production-ready Docker image for Finance Tracker API is available on GitHub Packages:

📦 Docker Image: GitHub Container Registry

Running with Docker Compose

A production-ready Docker Compose file is available:

📜 File: ./docker-compose-prod.yml

Start the Production Environment

docker-compose -f docker-compose-prod.yml up -d

Stop the Containers

docker-compose -f docker-compose-prod.yml down

Health Check

Verify that the API is running by checking the health check endpoint:

curl http://localhost:5000/api/v1/health

Expected Response:

{
    "service": "Finance API",
    "status": "healthy",
    "timestamp": "2025-03-10T05:05:11.017Z"
}

Logs & Monitoring

To check the logs of your running container:

docker logs -f finance-api

For debugging a running container:

docker exec -it finance-api sh

About

A comprehensive API designed to manage and track personal finances. It is built with Node.js, Express, MongoDB, Redis & Docker..

Topics

Resources

License

Stars

Watchers

Forks

Packages