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

https://github.com/kiritocode1/fintech-proj


https://github.com/kiritocode1/fintech-proj

Last synced: 20 days ago
JSON representation

Awesome Lists containing this project

README

          

# FinEdge - Personal Finance & Expense Tracker API

Type-safe RESTful API backend built with Node.js, Express, and TypeScript.

## Features

- **MVC Architecture**: Clean separation of concerns
- **Type Safety**: Full TypeScript with strict mode
- **RESTful API**: Standard HTTP methods and status codes
- **File Persistence**: JSON-based data storage using fs/promises
- **Caching**: In-memory cache with TTL for summary endpoint
- **Middleware**: Error handling, logging, validation, rate limiting, CORS
- **Custom Errors**: Structured error handling

## Project Structure

```
src/
├── app.ts # Express app configuration
├── index.ts # Entry point
├── controllers/ # Request handlers
│ ├── TransactionController.ts
│ ├── UserController.ts
│ └── SummaryController.ts
├── services/ # Business logic
│ ├── TransactionService.ts
│ └── UserService.ts
├── models/ # Data access layer
│ ├── BaseModel.ts
│ ├── TransactionModel.ts
│ └── UserModel.ts
├── routes/ # Route definitions
│ ├── transactionRoutes.ts
│ ├── userRoutes.ts
│ └── summaryRoutes.ts
├── middleware/ # Custom middleware
│ ├── errorHandler.ts
│ ├── logger.ts
│ └── validator.ts
├── types/ # TypeScript types
│ ├── index.ts
│ └── express.d.ts
└── utils/ # Utilities
├── cache.ts
└── errors.ts
```

## Setup

1. Install dependencies:

```bash
pnpm install
```

2. Create `.env` file (optional):

```bash
PORT=3000
NODE_ENV=development
```

3. Run development server:

```bash
pnpm dev
```

4. Build for production:

```bash
pnpm build
pnpm start
```

## API Endpoints

### Health Check

- `GET /health` - Server status

### Users

- `POST /users` - Register new user
```json
{
"name": "John Doe",
"email": "john@example.com"
}
```

### Transactions

- `POST /transactions` - Create transaction
```json
{
"userId": "user_123",
"type": "expense",
"category": "Food",
"amount": 50.0,
"date": "2024-01-15",
"description": "Lunch"
}
```
- `GET /transactions` - Get all transactions (optional: `?userId=user_123`)
- `GET /transactions/:id` - Get single transaction
- `PATCH /transactions/:id` - Update transaction
- `DELETE /transactions/:id` - Delete transaction

### Summary

- `GET /summary` - Get income/expense summary (optional: `?userId=user_123`)
```json
{
"success": true,
"data": {
"totalIncome": 5000,
"totalExpenses": 2000,
"balance": 3000,
"transactionCount": 10
},
"cached": false
}
```

## Technologies

- **Express.js** - Web framework
- **TypeScript** - Type safety
- **CORS** - Cross-origin resource sharing
- **express-rate-limit** - Rate limiting
- **dotenv** - Environment variables

## Data Storage

Data is persisted in `data/db.json` (automatically created). This file is gitignored.

## License

ISC