Technologies • Getting Started • API Endpoints • Contribute
An API that controls daily income and expenses from a user!
- Java
- Springboot
- Mysql
- Java Development Kit (JDK)
-
Clone the Repository
git clone https://github.com/luizfiliperm/finance-api.git
-
Make sure to create a MYSQL database and configure the path, login and password at the application.properties file
-
Navigate to the project directory
cd <project-directory>
- Build the project
.\mvnw clean install
- Run the application
.\mvnw spring-boot:run
Route | Description |
---|---|
POST auth/register | Registers a new user. details |
POST auth/login | Authenticates a user. details |
PUT /users | Updates logged user information. details |
DELETE /users | Delete logged user. details |
GET /wallet | Retrieve wallet info. details |
POST /wallet/incomes | Add a new Income. details |
GET /wallet/incomes | Find All Incomes. details |
DELETE /wallet/incomes/{id} | Delete a Income By Id. details |
PUT /wallet/incomes/{id} | Update a Income By Id. details |
POST wallet/categories | Create a new category. details |
GET wallet/categories | Get All Categories. details |
GET /categories/{id} | Retrieve a category by Id. details |
PUT /categories/{id} | Update a category by Id. details |
DELETE /categories/{id} | Delete a category by Id. details |
POST /wallet/expenses | Add a new Expense. details |
GET /wallet/expenses | Find All Expenses. details |
DELETE /wallet/expenses/{id} | Delete an Expense By Id. details |
PUT /wallet/expenses/{id} | Update an Expense By Id. details |
GET /admin/users | Find All Users. details |
Registers a new user and returns the user data and the JWT Token
- URL: /auth/register
- Method: POST
- Authentication: Not required
Request Body
Parameter | Type | Description | Required |
---|---|---|---|
name | string | Name of the user | Yes |
string | Email address of the user | Yes | |
password | string | Password for the user account | Yes |
personalInformation | object | Additional personal information | Yes |
personalInformation.phoneNumber | string | Phone number of the user | Yes |
personalInformation.birthDate | string | Birth date of the user | Yes |
personalInformation.nationality | string | Nationality of the user | Yes |
Registers a new user and returns the user data and the JWT Token
- URL: /auth/login
- Method: POST
- Authentication: Not required
Parameter | Type | Description | Required |
---|---|---|---|
string | Email address of the user | Yes | |
password | string | Password for the user account | Yes |
Response (same for register and login)
- 200 OK
- Content: JSON
{ "user": { "id": 1, "name": "user", "email": "luiz@example.com", "role": "ROLE_USER", "personalInformation": { "phoneNumber": "123456789", "birthDate": "17/04/2004", "nationality": "Brazilian" }, "wallet": { "balance": 0 } }, "token": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJsdWl6QGV4YW1wbGUuY29tIiwiaWF0IjoxNzEwMzI0MTMwLCJleHAiOjE3MTA0MTA1MzB9.DwKfj34-QXttfAqDtlRIuksuQ8loXIbI7R7O64MkJkA" }
Updates the logged User
- URL: /users
- Method: PUT
- Authentication: Logged
Request Body
Parameter | Type | Description | Required |
---|---|---|---|
name | string | Name of the user | Yes |
currentPassword | string | Current password for verification | Yes |
newPassword | string | New password for the user | Yes |
personalInformation | object | Additional personal information | Yes |
personalInformation.phoneNumber | string | Phone number of the user | Yes |
personalInformation.birthDate | string | Birth date of the user | Yes |
personalInformation.nationality | string | Nationality of the user | Yes |
Response
- 200 OK
- Content: Json
{ "id": 4, "name": "Luiz Filipe", "email": "luiz@example.com", "role": "ROLE_USER", "personalInformation": { "phoneNumber": "123456729", "birthDate": "17/04/2004", "nationality": "Brazilian" }, "wallet": { "balance": 0.00 } }
Deletes the currently logged-in user.
- URL: /users
- Method: DELETE
- Authentication: Required
Request Body
This endpoint does not require a request body.
Responses
- 204 No Content
Retrieves the wallet balance of the currently logged-in user.
- URL: /wallet
- Method: GET
- Authentication: Required
Request Body
This endpoint does not require a request body.
Responses
- 200 OK
- Content: JSON
{ "balance": 0.00 }
- URL: /wallet/incomes
- Method: POST
- Authentication: Required
Request Body
Parameter | Type | Description | Required |
---|---|---|---|
name | string | Name of the income | Yes |
amount | number | Amount of the income | Yes |
incomeType | string | Type of income ('monthly' or 'sporadic') | Yes |
dateTime | string | Date and time of the income (format: dd/MM/yyyy HH:mm) | Yes |
Response
- 200 OK
- Content: Json
{ "id": 8, "name": "Monthly salary", "amount": 1330.50, "incomeType": "MONTHLY", "dateTime": "13/03/2024 11:00" }
- URL: /wallet/incomes
- Method: GET
- Authentication: Required
Query Parameters
Parameter | Type | Description | Required | Default |
---|---|---|---|---|
pageNo | number | Page number for pagination | No | 0 |
pageSize | number | Number of items per page | No | 10 |
sortBy | string | Field to sort the results | No | dateTime |
sortDir | string | Sorting direction ('asc' or 'desc') | No | desc |
Response
- 200 OK
- Content: Json
{ "content": [ { "id": 8, "name": "Monthly salary", "amount": 1330.50, "incomeType": "MONTHLY", "dateTime": "13/03/2024 11:00" } ], "pageNo": 0, "pageSize": 10, "totalElements": 1, "totalPages": 1, "last": true }
Deletes the specified income from the wallet of the logged-in user.
- URL: /wallet/incomes/{incomeId}
- Method: DELETE
- Authentication: Required
Path Parameters
Parameter | Type | Description | Required |
---|---|---|---|
incomeId | number | ID of the income to delete | Yes |
Responses
- 204 No Content
Updates the details of the specified income in the wallet of the logged-in user.
- URL: /wallet/incomes/{incomeId}
- Method: PUT
- Authentication: Required
Path Parameters
Parameter | Type | Description | Required |
---|---|---|---|
IncomeId | number | ID of the income to update | Yes |
Request Body
Parameter | Type | Description | Required |
---|---|---|---|
name | string | New name of the income | Yes |
amount | number | New amount of the income | Yes |
incomeType | string | New type of income ('monthly' or 'sporadic') | Yes |
dateTime | string | New date and time of the income (format: dd/MM/yyyy HH:mm) | Yes |
Response
- 200 OK
- Content: Json
{ "id": 9, "name": "Monthly salary", "amount": 1230.50, "incomeType": "MONTHLY", "dateTime": "11/03/2024 20:57" }
- URL: /wallet/categories
- Method: POST
- Authentication: Required
Request Body
Parameter | Type | Description | Required |
---|---|---|---|
name | string | Name of the category | Yes |
description | string | Description of the category | Yes |
Responses
- 200 OK
- Content: Json
{ "id": 8, "name": "Games", "description": "Anything that I buy related to games" }
Retrieves a list of categories from the wallet of the logged-in user.
- URL: /wallet/categories
- Method: GET
- Authentication: Required
Query Parameters
Parameter | Type | Description | Required | Default |
---|---|---|---|---|
pageNo | number | Page number for pagination | No | 0 |
pageSize | number | Number of items per page | No | 10 |
sortBy | string | Field to sort the results | No | id |
sortDir | string | Sorting direction ('asc' or 'desc') | No | asc |
Response
- 200 OK
- Content: Json
{ "content": [ { "id": 8, "name": "Games", "description": "Anything that I buy related to games" } ], "pageNo": 0, "pageSize": 10, "totalElements": 1, "totalPages": 1, "last": true }
Retrieves the details of a specific category from the wallet of the logged-in user.
- URL: /wallet/categories/{categoryId}
- Method: GET
- Authentication: Required
Path Parameters
Parameter | Type | Description | Required |
---|---|---|---|
categoryId | number | ID of the category | Yes |
Response
- 200 OK
- Content: Json
{ "id": 8, "name": "Games", "description": "Anything that I buy related to games" }
Updates the details of a specific category in the wallet of the logged-in user.
- URL: /wallet/categories/{categoryId}
- Method: PUT
- Authentication: Required
Path Parameters
Parameter | Type | Description | Required |
---|---|---|---|
categoryId | number | ID of the category | Yes |
Request Body
Parameter | Type | Description | Required |
---|---|---|---|
name | string | New name of the category | Yes |
description | string | New description of the category | Yes |
Deletes the specified category from the wallet of the logged-in user.
- URL: /wallet/categories/{categoryId}
- Method: Delete
- Authentication: Required
Path Parameters
Parameter | Type | Description | Required |
---|---|---|---|
categoryId | number | ID of the category | Yes |
Response
- 204 No Content
Adds a new expense to the wallet of the logged-in user.
- URL: /wallet/expenses
- Method: POST
- Authentication: Required
Request Body
Parameter | Type | Description | Required |
---|---|---|---|
name | string | Name of the expense | Yes |
amount | number | Amount of the expense | Yes |
paymentMethod | string | Payment method ('Debit' or 'Credit') | Yes |
dateTime | string | Date and time of the expense (format: dd/MM/yyyy HH:mm) | Yes |
categoryId | number | ID of the category for the expense | Yes |
Responses
- 200 OK
- Content: Json
{ "id": 5, "name": "Dark souls 3", "amount": 180, "paymentMethod": "DEBIT", "dateTime": "12/03/2024 10:00", "category": { "id": 8, "name": "Games", "description": "Anything that I buy related to games" } }
Retrieves a list of expenses from the wallet of the logged-in user.
- URL: /wallet/expenses
- Method: GET
- Authentication: Required
Query Parameters
Parameter | Type | Description | Required | Default |
---|---|---|---|---|
pageNo | number | Page number for pagination | No | 0 |
pageSize | number | Number of items per page | No | 10 |
sortBy | string | Field to sort the results | No | dateTime |
sortDir | string | Sorting direction ('asc' or 'desc') | No | desc |
Response
- 200 OK
- Content: Json
{ "content": [ { "id": 5, "name": "Dark souls 3", "amount": 180.00, "paymentMethod": "DEBIT", "dateTime": "12/03/2024 10:00", "category": { "id": 8, "name": "Games", "description": "Anything that I buy related to games" } } ], "pageNo": 0, "pageSize": 10, "totalElements": 1, "totalPages": 1, "last": true }
Deletes the specified expense from the wallet of the logged-in user.
- URL: /wallet/expenses/{expenseId}
- Method: DELETE
- Authentication: Required
Path parameters
Parameter | Type | Description | Required |
---|---|---|---|
expenseId | number | ID of the expense | Yes |
Response
- 204 No content
Updates the details of a specific expense in the wallet of the logged-in user.
- URL: wallet/expenses/{expenseId}
- Method: PUT
- Authentication: Required
Path Parameters
Parameter | Type | Description | Required |
---|---|---|---|
expenseId | number | ID of the expense | Yes |
Request Body
Parameter | Type | Description | Required |
---|---|---|---|
name | string | New name of the expense | Yes |
amount | number | New amount of the expense | Yes |
paymentMethod | string | New payment method ('Debit' or 'Credit') | Yes |
dateTime | string | New date and time of the expense (format: dd/MM/yyyy HH:mm) | Yes |
categoryId | number | New ID of the category for the expense | Yes |
Response
- 200 OK
- Content: Json
{ "id": 5, "name": "Dark souls 2", "amount": 180, "paymentMethod": "DEBIT", "dateTime": "12/03/2024 10:00", "category": { "id": 8, "name": "Games", "description": "Anything that I buy related to games" } }
Retrieves a list of users with administrator privileges.
- URL: /admin/users
- Method: Get
- Authentication: Required(ROLE_MANAGER)
Query Parameters
Parameter | Type | Description | Required | Default |
---|---|---|---|---|
pageNo | number | Page number for pagination | No | 0 |
pageSize | number | Number of items per page | No | 10 |
sortBy | string | Field to sort the results | No | id |
sortDir | string | Sorting direction ('asc' or 'desc') | No | asc |
Response
- 200 OK
- Content: Json
{ "content": [ { "id": 1, "name": "Luiz Filipe", "email": "admin@example.com", "role": "ROLE_MANAGER", "personalInformation": { "phoneNumber": "123456729", "birthDate": "17/04/2004", "nationality": "Brazilian" }, "wallet": { "balance": 3965.93 } }, { "id": 3, "name": "user", "email": "user@example.com", "role": "ROLE_USER", "personalInformation": { "phoneNumber": "123456789", "birthDate": "17/04/2004", "nationality": "Brazilian" }, "wallet": { "balance": 0.00 } }, { "id": 4, "name": "Luiz Filipe", "email": "luiz@example.com", "role": "ROLE_USER", "personalInformation": { "phoneNumber": "123456729", "birthDate": "17/04/2004", "nationality": "Brazilian" }, "wallet": { "balance": 1050.50 } } ], "pageNo": 0, "pageSize": 3, "totalElements": 3, "totalPages": 1, "last": true }
Feel Free to contribute to our project! Follow these steps:
git clone https://github.com/luizfiliperm/finance-api.git
git checkout -b feature/NAME
- Make your changes and commits. Be sure to adhere to our contribution guidelines, if available.
- Push your branch to GitHub:
git push origin feature/NAME
- Open a Pull Request explaining the problem solved or feature made, if exists, append screenshot of visual modifications and wait for the review!
Thank you for contributing!