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

https://github.com/johnnyfr26/api.thinktech

Api build with nodeJs for financial management service
https://github.com/johnnyfr26/api.thinktech

api-rest fastify nodejs prisma-orm test-automation typescript

Last synced: about 2 months ago
JSON representation

Api build with nodeJs for financial management service

Awesome Lists containing this project

README

          

# ๐Ÿ“ˆ Financial Management API

A robust financial management and expense control API built with **Fastify**, **Prisma**, **Zod**, **JWT**, and **Bcrypt**. This API allows secure authentication, user management, and financial transaction tracking to support financial management applications.

---

## ๐Ÿš€ Features
- **User Authentication:** Secure login with **JWT**.
- **Data Validation:** Strong validation using **Zod**.
- **Password Security:** Hashing and verification with **Bcrypt**.
- **Database ORM:** **Prisma** for robust and easy database management.
- **Fast and Lightweight:** Built with **Fastify** for performance.
- **Financial Management:** Manage income, expenses, and budget efficiently.

---

## ๐Ÿ› ๏ธ Tech Stack
- **Node.js**
- **Fastify**
- **Prisma**
- **Zod**
- **JWT (JsonWebToken)**
- **Bcrypt**
- **PostgreSQL**

---

## ๐Ÿ“‚ Project Structure
```
financial-management-api/
โ”œโ”€ controllers/ # Business logic
โ”œโ”€ lib/ # External library configurations (e.g., Prisma client)
โ”œโ”€ middlewares/ # Authentication and validation middleware
โ”œโ”€ models/ # Interfaces of TS
โ”œโ”€ routes/ # API endpoints
โ”œโ”€ tests/ # Unit and integration tests
โ””โ”€ index.ts # Application entry point
```

---

## ๐Ÿ”ฅ Getting Started
### 1. **Clone the repository:**
```sh
git clone https://github.com/johnnyFR26/api.thinktech.git
cd api.thinktech
```

### 2. **Install dependencies:**
```sh
npm install
```

### 3. **Set up environment variables:**
Create a `.env` file in the root directory with the following variables:
```env
DATABASE_URL="file:./dev.db" # For SQLite (or use a PostgreSQL connection string)
JWT_SECRET="your_secret_key"
```

### 4. **Run Prisma migrations:**
```sh
npx prisma migrate dev --name init
```

### 5. **Start the server:**
```sh
npm run dev
```
Access at: [http://localhost:3000](http://localhost:3000)

---

## ๐Ÿšฆ **API Endpoints**
### Authentication
- `POST /auth/login` - Authenticate a user and receive a JWT.

### User Management
- `GET /users` - Get all users.
- `POST /users` - Create a new user.

### Financial Transactions
- `GET /transactions` - Get all financial transactions.
- `POST /transactions` - Create a new transaction.
- `DELETE /transactions/:id` - Delete a transaction.

---

## ๐Ÿงช **Running Tests**
```sh
npm run test
```

---

## ๐Ÿ”’ **Security Best Practices**
- Store secrets in environment variables.
- Hash passwords before saving to the database.
- Validate all input with **Zod**.
- Use HTTPS in production.

---

## ๐Ÿ“„ **License**
This project is licensed under the MIT License.

---

## ๐Ÿ‘จโ€๐Ÿ’ป **Contributing**
Feel free to open issues or submit pull requests to help improve this project!