Skip to content

isaqueDaSilva/Expense-Tracker-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

143 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Expense Tracker API 💰

typescript node postgres

AboutStarting API RoutesTechnologiesFeatures

📌 About

The Expense Tracker API is a RESTful service designed to help users efficiently manage and monitor their personal or business finances. It offers features for tracking expenses and categorizing spending.

This project is my solution for Expense tracker from roadmap.sh website.

🚀 Starting

Pre-requirements

Instalação

  1. Clone the repository
git clone https://github.com/isaqueDaSilva/Expense-Tracker-API.git
cd Expense-Tracker-API
  1. Install Dependencies
npm install
  1. Configure environment variables Create a `.env` file on root of the project based on `.env.example`:
DATABASE_URL=postgres://your_user:your_password@localhost:5432/expense_tracker
PORT=3000
HOSTNAME='127.0.0.1'
JWT_ACCESS_SECRET=secret_for_access_jwt_token
JWT_REFRESH_SECRET=secret_for_refresh_jwt_token
JWT_ISSUER=secret_for_jwt_issuer_identifier
  1. Perform database migrations
npm run migrate
  1. Start server
npm run build

📍 API Routes

Authentication

Route Method Description
/auth/signup POST Create a new account
/auth/signin POST Log in
/token/verify GET Verify access token
/token/refresh PUT Refresh access token
/auth/signout DELETE Log out
/auth/delete-account DELETE Deletes user account

Categories

Route Method Description
/category/create POST Create a new category
/category/all/:page GET List categories (paginated)
/category/get/:id GET Get a category by ID
/category/:id/update PATCH Updates a category
/category/:id/delete DELETE Deletes a category

Expenses

Route Method Description
/task/create POST Creates a new expense
/task/all/:page GET List expenses (paginated)
/task/all/:category/:page GET List expenses by categories (paginated)
/task/byDate/:page GET List expenses by date range (paginated)
/task/get/:id GET Gets an expense by ID
/task/update/:id PATCH updates an expense
/task/:id/delete DELETE deletes an expense

Request Examples

Creates a new expense

POST /task/create
{
    "title": "Monthly Purchases",
    "description": "Monthly market",
    "value": 500.00,
    "date": "2025-10-06",
    "category": "category-uuid"
}

Creates a new Category

POST /category/create
{
    "title": "Food"
}

🛠 Technologies

  • TypeScript
  • Node.js
  • PostgreSQL (via Neon Serverless)
  • Zod (Validations)
  • JSON Web Token (Authentication)
  • bcrypt (password hash)

⭐ Features

  • ✅ Secure authentication with JWT
  • ✅ Complete expense and category CRUD
  • ✅ Expense categorization
  • ✅ Date and category filters
  • ✅ Results pagination
  • ✅ Standard category system
  • ✅ Robust data validation
  • ✅ Route protection
  • ✅ Token refresh

Security

  • Passwords stored with bcrypt hash
  • JWT tokens with expiration
  • Token refresh system
  • Data validation with Zod
  • SQL injection protection
  • Token deactivation system

Data Model

  • Users: Account Management
  • Categories: Expense Management
  • Expenses: Expense Tracking
  • Tokens: Session Control

About

Designed to simplify expense tracking, offering categorization, filtering and secure authentication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors