An open API service indexing awesome lists of open source software.

https://github.com/isaquedasilva/expense-tracker-api

API designed to simplify expense tracking, offering categorization, filtering and secure authentication.
https://github.com/isaquedasilva/expense-tracker-api

expense-tracker jwt-authentication neon-postgres node-js postgresql refresh-token typescript

Last synced: about 2 months ago
JSON representation

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

Awesome Lists containing this project

README

          

# Expense Tracker API πŸ’°

![typescript][TYPESCRIPT__BADGE]
![node][NODE__BADGE]
![postgres][POSTGRES__BADGE]

[TYPESCRIPT__BADGE]: https://img.shields.io/badge/typescript-D4FAFF?style=for-the-badge&logo=typescript
[NODE__BADGE]: https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white
[POSTGRES__BADGE]: https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white


About β€’
Starting β€’
API Routes β€’
Technologies β€’
Features

πŸ“Œ 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](https://roadmap.sh/projects/expense-tracker-api) from roadmap.sh website.

πŸš€ Starting

### Pre-requirements

- [Node.js](https://nodejs.org/) (v22 or above)
- [Neon Database](https://neon.com)
- [TypeScript](https://www.typescriptlang.org/)

### InstalaΓ§Γ£o

1. Clone the repository
```bash
git clone https://github.com/isaqueDaSilva/Expense-Tracker-API.git
cd Expense-Tracker-API
```

2. Install Dependencies
```bash
npm install
```

3. Configure environment variables
Create a \`.env\` file on root of the project based on \`.env.example\`:

```env
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
```

4. Perform database migrations
```bash
npm run migrate
```

5. Start server
```bash
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
```json
POST /task/create
{
"title": "Monthly Purchases",
"description": "Monthly market",
"value": 500.00,
"date": "2025-10-06",
"category": "category-uuid"
}
```

#### Creates a new Category
```json
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