This application helps to manage the income and expenses of the user. The transactions are saved on the backend using a HTTP restful API.
-
Fronend:
- React:
-
Backend:
- ExpressJS
- MongoDB (Mongoose)
-
Run
npm install
to install all dependencies. -
Run
npm start
to start the app.Note: In your browser, navigate to: http://localhost:3000/
- Run
npm run start
.
The Personal Finance Tracker API is organized around REST. It has a resource-oriented URLs, accept form request body, return JSON response, and uses standard HTTP response to indicate the success or failure of an API request.
This API raise exceptions for many reasons, such as missing required field, network unavailability, etc.
For example, there are 4 required fields: type, categories, escription and value, if one of them is missing the response will be:
{
"error": "transactions validation failed: value: Number field required, description: Description field required, category: Category field required, "NAME OF THE REQUIRED FIELD": Type field required"
}
This API has the following parameters:
{
type:{
type: String,
required: [true, 'Type field required']
},
category:{
type: String,
required: [true, 'Category field required']
},
description:{
type: String,
required: [true, 'Description field required']
},
value:{
type: Number,
required: [true, 'Number field required']
}
}
Those parameters are required in order to insert a new information.
The API has no required parameters and the user can request information by inputing the following fields:
category:{
type: String
},
description:{
type: String
},
value:{
type: Number
}
Example request: GET
http://localhost:5001/api/transactions?value=50&category=food
Response:
[
{
"_id": "6248e768b8c138906eb279a7",
"type": "expense",
"category": "food",
"description": "ifood",
"value": 50,
"__v": 0
}
]
POST
http://localhost:5001/api/transactions
User input
{
"type": "income",
"category": "house",
"description": "rent",
"value": 1000
}
Result:
{
"type": "income",
"category": "house",
"description": "rent",
"value": 1000,
"_id": "6248fbc7351cfdb8c6b1ab5d",
"__v": 0
}