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.
- Host: GitHub
- URL: https://github.com/isaquedasilva/expense-tracker-api
- Owner: isaqueDaSilva
- License: mit
- Created: 2025-09-17T18:04:41.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2025-10-06T17:59:53.000Z (9 months ago)
- Last Synced: 2025-10-06T19:28:46.899Z (9 months ago)
- Topics: expense-tracker, jwt-authentication, neon-postgres, node-js, postgresql, refresh-token, typescript
- Language: TypeScript
- Homepage:
- Size: 115 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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