Kapusta Financial Tracker API is a backend application for managing financial transactions, allowing users to register, log in, add income and expenses, and retrieve transaction statistics.
Kapusta Backend offers a robust set of API endpoints to interact with the financial management system. With this backend server, users can:
- Register and Authenticate Users: Allow users to register accounts and securely authenticate them using JWT tokens.
- Manage Transactions: Provide endpoints to add, delete, and retrieve transactions, including income and expenses.
- Retrieve User Data: Enable users to fetch their account information, including balance and transaction history.
- Manage Budgets: Implement functionality to set and update budgets for different expense categories.
Explore the API endpoints and detailed documentation using Swagger for a comprehensive understanding of the server capabilities.
Note
Please be aware that the server responses may experience delays of 50 seconds or more due to inactivity.
- Node.js - JavaScript runtime built on Chrome's V8 JavaScript engine
- Express.js - Fast, unopinionated, minimalist web framework for Node.js
- MongoDB - NoSQL database for storing user and transaction data
- Mongoose - Elegant MongoDB object modeling for Node.js
- JSON Web Token (JWT) - Compact, URL-safe means of representing claims to be transferred between two parties
- Bcrypt - Library to help hash passwords
- Nanoid - Secure, URL-friendly unique string ID generator
- Joi - Powerful schema description language and data validator for JavaScript
- Dotenv - Module to load environment variables from a
.env
file intoprocess.env
To get a local copy up and running, follow these steps.
Ensure you have the following installed on your machine:
- Node.js (v14 or later)
- npm (v6 or later)
- MongoDB (local or hosted)
- Clone the Repository
git clone https://github.com/valik3201/kapusta-nodejs-server.git
cd kapusta-nodejs-server
- Install Dependencies
npm install
Create a .env
file in the root directory and add the following variables:
PORT=3000
DB_URL=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
To start the application in development mode, use:
npm run start:dev
To start the application in production mode, use:
npm start
-
Register:
POST /api/auth/register
- Request body:
{ "email": "user@example.com", "password": "password123" }
- Response:
201 Created
with user data
- Request body:
-
Login:
POST /api/auth/login
- Request body:
{ "email": "user@example.com", "password": "password123" }
- Response:
200 OK
with tokens and user data
- Request body:
-
Logout:
POST /api/auth/logout
- Requires authentication
- Response:
204 No Content
-
Get User Data:
GET /api/user/
- Requires authentication
- Response:
200 OK
with user data and transactions
-
Update Balance:
PATCH /api/user/balance
- Requires authentication
- Request body:
{ "newBalance": 1000 }
- Response:
200 OK
with new balance
-
Add Income:
POST /api/transaction/income
- Requires authentication
- Request body:
{ "date": "2023-01-01", "description": "Salary", "category": "Salary", "amount": 5000 }
- Response:
200 OK
with new transaction and updated balance
-
Add Expense:
POST /api/transaction/expense
- Requires authentication
- Request body:
{ "date": "2023-01-01", "description": "Groceries", "category": "Products", "amount": 100 }
- Response:
200 OK
with new transaction and updated balance
-
Delete Transaction:
DELETE /api/transaction/:transactionId
- Requires authentication
- Response:
200 OK
with updated balance
-
Get Income Transactions:
GET /api/transaction/income
- Requires authentication
- Response:
200 OK
with income transactions and statistics
-
Get Expense Transactions:
GET /api/transaction/expense
- Requires authentication
- Response:
200 OK
with expense transactions and statistics
-
Get Income Categories:
GET /api/transaction/income-categories
- Requires authentication
- Response:
200 OK
with income categories
-
Get Expense Categories:
GET /api/transaction/expense-categories
- Requires authentication
- Response:
200 OK
with expense categories
-
Get Transactions by Date:
GET /api/transaction/period-data?date=YYYY-MM
- Requires authentication
- Response:
200 OK
with transactions grouped by categories
The frontend for this application can be found at Kapusta React Client.