- 📘 Introduction
- ✨ Features
- 💻 Technologies Used
- 🚀 Getting Started
▶️ Running the Application- 🔗 API Endpoints
- 🗄️ Database Structure
The Daily Expenses Sharing Application allows users to add expenses and split them among participants using three different methods: equal splits, exact amounts, and percentages. The application also provides features for user management and generates downloadable balance sheets.
- 👤Create and retrieve user details.
- 💸 Add expenses and split them in multiple ways.
- ✅ Validate inputs to ensure data integrity.
- 📊 Generate balance sheets for individual users and overall expenses.
Before you begin, ensure you have the following installed:
- Clone the Repository:
git clone https://github.com/syamreddy99/Daily-Expenses-Sharing-Application cd Daily-Expense-Sharing-Application
Create a database named "dailyexpenses".
-
spring.application.name=
Daily-Expenses-Sharing-Application
-
server.port=
9982
- This property sets the port number on which the Spring Boot application will run.By default, Spring Boot applications run on port 8080, but this can be changed as needed.
-
spring.datasource.url=
jdbc:mysql://localhost:3306/DailyExpenses
- This property defines the JDBC URL for connecting to the MySQL database. It specifies the database type, host, port, and the nameof the database.
-
spring.datasource.username=
root
- Defines the username for the database connection .
-
spring.datasource.password=
root
- Specifies the password for the database connection.
-
spring.datasource.driver-class-name=
com.mysql.cj.jdbc.Driver
- Specifies the fully qualified name of the JDBC driver.
-
spring.jpa.hibernate.ddl-auto=
update
- Defines the behavior of the Hibernate's automatic schema generation. update creates the schema if it doesn't exist and updates it if it does.
-
spring.jpa.show-sql=
true
- Enables logging of SQL statements generated by Hibernate.
-
logging.level.org.springframework=
DEBUG
- Sets the logging level for Spring framework classes.
- Import the Project: Unzip the project file and import it into your IDE (e.g., Eclipse).
- Create the Database: Create a MySQL database named DailyExpenses.
- Adjust Configuration: Modify the application.properties as needed.
- Run the Application: Start the application from your IDE.
http://localhost:9982
- Method: POST
- URL:
/api/users
- Description: Creates a new user.
-
{
-
"email": "john.doe@example.com",
-
"name": "John Doe",
-
"mobile": "1234567890"
-
}
-
Response: Status: 201 Created
-
Body: UserDTO object
- Method: GET
- URL:
/api/users/{id}
- Description: Retrieves details of a user by ID.
- Example URL:
/api/users/1
- Response: Status: 200 OK
- Body: UserDTO object
- Method: POST
- URL:
/api/expenses
- Description: Adds a new expense.
-
{
-
"description": "Dinner",
-
"amount": 120.50,
-
"date": "2023-07-27",
-
"userId": 1,
-
"splits": [
-
{
-
"userId": 1,
-
"amount": 40.17,
-
"splitType": "EQUAL"
-
}
-
{
-
"userId": 2,
-
"amount": 40.17,
-
"splitType": "EQUAL"
-
}
-
{
-
"userId": 3,
-
"amount": 40.16,
-
"splitType": "EQUAL"
-
}
-
]
-
Response: Status: 201 Created
-
Body: ExpenseDTO object
-
Method: GET
-
URL:
/api/expenses/user/{userId}
-
Description: Retrieves all expenses for a specific user by user ID.
-
Example URL:
/api/expenses/user/1
-
Response: Status: 200 OK
-
Body: List of ExpenseDTO objects
- Method: GET
- URL:
/api/expenses/overall
- Description: Retrieves all expenses in the system.
- Response: Status: 200 OK
- Body: List of ExpenseDTO objects
- Method: GET
- URL:
/api/expenses/download/{userId}
- Description: Generates and downloads a balance sheet for a specific user.
- Example URL:
/api/expenses/download/1
- Response: Status: 200 OK
- Headers:
- Content-Disposition: attachment; filename=balance_sheet.csv
- Content-Type:
application/csv
- Body: CSV file
- The database structure consists of the following tables:
- Stores user details such as email, name, and mobile number.
- Stores expense details including description, amount, date, and user ID.
- Stores information about how expenses are split among users.