Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/kanika637/expense-sharing-application


https://github.com/kanika637/expense-sharing-application

Last synced: 7 days ago
JSON representation

Awesome Lists containing this project

README

        

This backend service is designed to manage a daily expenses sharing application. Users can add expenses and split them using three different methods: equal amounts, exact amounts, and percentages. The application also manages user details, validates inputs, and generates downloadable balance sheets.

# Features

1.User Management without passwords (using mobile number, email, and name).
2.Add and manage expenses.
3.Split expenses equally, by exact amounts, or by percentages.
4.Retrieve individual and overall expenses.
5.Generate and download balance sheets.

# Setup
Clone the Repository:

```git clone https://github.com/your-username/daily-expenses-sharing-app.git```
```cd daily-expenses-sharing-app```

# Install Dependencies:

```
npm install
```

# Run the Application:

```
npm start
```

# API Endpoints

## User Endpoints

**Create User:**

**Endpoint:** POST /api/users

**Body:**

```
{
"name": "Arya",
"email": "[email protected]",
"mobile": "1234567890"
}
```

**Response**

```{
"message": "User created successfully",
"user": {
"id": "66a68add6f888f0dd3b66034",
"email": "[email protected]",
"name": "Arya",
"mobile": "1234567890"
}
}
```

![image](https://github.com/user-attachments/assets/d37d00b5-630f-4870-a2b3-6c67911aad71)

**Retrieve User Details:**

Endpoint: GET /api/users/:name

![image](https://github.com/user-attachments/assets/1528e429-1d34-4c48-aa13-8a2c6d06c40f)

## Expense Endpoints

**Add Expense:**

Endpoint: POST /api/expenses

1. Equal

Body:

```{
"description": "Dinner",
"amount": 3000,
"paidBy": {
"name": "Trisha",
"email": "[email protected]",
"mobile": "1234567890"
},
"participants": [
{
"name": "Helen",
"email": "[email protected]",
"mobile": "0987654321"
},
{
"name": "Mesha",
"email": "[email protected]",
"mobile": "1112223333"
},
{
"name": "Karthik",
"email": "[email protected]",
"mobile": "4445556666"
}
],
"splitType": "equal"
}
```

Response:

```{
"_id": "66a68bff6f888f0dd3b66043",
"description": "Dinner",
"amount": 3000,
"paidBy": {
"_id": "66a68bff6f888f0dd3b66038",
"email": "[email protected]",
"name": "Trisha"
},
"participants": [
{
"userId": {
"_id": "66a68bff6f888f0dd3b6603d",
"email": "[email protected]",
"name": "Helen"
},
"amount": 1000,
"_id": "66a68bff6f888f0dd3b66044"
},
{
"userId": {
"_id": "66a68bff6f888f0dd3b6603f",
"email": "[email protected]",
"name": "Mesha"
},
"amount": 1000,
"_id": "66a68bff6f888f0dd3b66045"
},
{
"userId": {
"_id": "66a68bff6f888f0dd3b66041",
"email": "[email protected]",
"name": "Karthik"
},
"amount": 1000,
"_id": "66a68bff6f888f0dd3b66046"
}
],
"splitType": "equal",
"createdAt": "2024-07-28T18:20:47.575Z",
"updatedAt": "2024-07-28T18:20:47.575Z",
"__v": 0
}
```

![image](https://github.com/user-attachments/assets/ef3dc7f5-3d05-4ddd-b015-a7671e502b08)

2. Exact

Body:

```{
"description": "Shopping",
"amount": 4299,
"paidBy": {
"name": "abhishek",
"email": "[email protected]",
"mobile": "1234567890"
},
"participants": [
{
"name": "amisha",
"email": "[email protected]",
"mobile": "0987654321",
"amount": 799
},
{
"name": "charu",
"email": "[email protected]",
"mobile": "1112223333",
"amount": 2000
},
{
"name": "ansh",
"email": "[email protected]",
"mobile": "1234567890",
"amount": 1500
}
],
"splitType": "exact"
}
```

Response:

```{
"_id": "66a68c856f888f0dd3b6605a",
"description": "Shopping",
"amount": 4299,
"paidBy": {
"_id": "66a68c856f888f0dd3b6604f",
"email": "[email protected]",
"name": "abhishek"
},
"participants": [
{
"userId": {
"_id": "66a68c856f888f0dd3b66054",
"email": "[email protected]",
"name": "amisha"
},
"amount": 799,
"_id": "66a68c856f888f0dd3b6605b"
},
{
"userId": {
"_id": "66a68c856f888f0dd3b66056",
"email": "[email protected]",
"name": "charu"
},
"amount": 2000,
"_id": "66a68c856f888f0dd3b6605c"
},
{
"userId": {
"_id": "66a68c856f888f0dd3b66058",
"email": "[email protected]",
"name": "ansh"
},
"amount": 1500,
"_id": "66a68c856f888f0dd3b6605d"
}
],
"splitType": "exact",
"createdAt": "2024-07-28T18:23:01.182Z",
"updatedAt": "2024-07-28T18:23:01.182Z",
"__v": 0
}
```

![image](https://github.com/user-attachments/assets/6ef0f2ad-5fcb-40ca-bfe2-066fea2ebaa7)

3. Percentage

Body:

```{
"description": "Party",
"amount": 1000,
"paidBy": {
"name": "Misha",
"email": "[email protected]",
"mobile": "1234567890"
},
"participants": [
{
"name": "Misha",
"email": "[email protected]",
"mobile": "1234567890",
"amount": 50
},
{
"name": "Madhav",
"email": "[email protected]",
"mobile": "0987654321",
"amount": 25
},
{
"name": "Rupali",
"email": "[email protected]",
"mobile": "1112223333",
"amount": 25
}
],
"splitType": "percentage"
}
```

Response:

```{
"_id": "66a68cf56f888f0dd3b6606f",
"description": "Party",
"amount": 1000,
"paidBy": {
"_id": "66a68cf56f888f0dd3b66066",
"email": "[email protected]",
"name": "Misha"
},
"participants": [
{
"userId": {
"_id": "66a68cf56f888f0dd3b66066",
"email": "[email protected]",
"name": "Misha"
},
"amount": 500,
"_id": "66a68cf56f888f0dd3b66070"
},
{
"userId": {
"_id": "66a68cf56f888f0dd3b6606d",
"email": "[email protected]",
"name": "Madhav"
},
"amount": 250,
"_id": "66a68cf56f888f0dd3b66071"
},
{
"userId": {
"_id": "66a68cf56f888f0dd3b6606b",
"email": "[email protected]",
"name": "Rupali"
},
"amount": 250,
"_id": "66a68cf56f888f0dd3b66072"
}
],
"splitType": "percentage",
"createdAt": "2024-07-28T18:24:53.910Z",
"updatedAt": "2024-07-28T18:24:53.910Z",
"__v": 0
}
```

![image](https://github.com/user-attachments/assets/405d3c06-719e-40af-8cfa-2df78a2d0933)

**Retrieve individual user expenses**

**Endpoint:** GET /api/expenses/user/:name

**Response:**

```[
{
"description": "Party",
"totalAmount": 1000,
"paidBy": {
"name": "Misha",
"email": "[email protected]"
},
"userShare": {
"name": "Rupali",
"email": "[email protected]",
"amount": 250
},
"splitType": "percentage",
"createdAt": "2024-07-28T18:24:53.910Z",
"updatedAt": "2024-07-28T18:24:53.910Z"
}
]
```

![image](https://github.com/user-attachments/assets/d46f97d7-7206-4ed6-a4de-d3a4508fee6b)

**Retrieve Overall Expenses**

**Endpoint:** GET /api/expenses/all

**Response**

```[
{
"_id": "66a63f3bd5842b25dc33744d",
"description": "Party",
"amount": 1000,
"paidBy": {
"name": "Manisha",
"email": "[email protected]"
},
"participants": [
{
"name": "Manisha",
"email": "[email protected]",
"amount": 500
},
{
"name": "Pragya",
"email": "[email protected]",
"amount": 250
},
{
"name": "Esha",
"email": "[email protected]",
"amount": 250
}
],
"splitType": "percentage",
"createdAt": "2024-07-28T12:53:15.916Z",
"updatedAt": "2024-07-28T12:53:15.916Z"
},
{
"_id": "66a67d83d5842b25dc3374ef",
"description": "Dinner",
"amount": 3000,
"paidBy": {
"name": "Roshini",
"email": "[email protected]"
},
"participants": [
{
"name": "Poojs",
"email": "[email protected]",
"amount": 1000
},
{
"name": "Ruhi",
"email": "[email protected]",
"amount": 1000
},
{
"name": "Asha",
"email": "[email protected]",
"amount": 1000
}
],
"splitType": "equal",
"createdAt": "2024-07-28T17:18:59.549Z",
"updatedAt": "2024-07-28T17:18:59.549Z"
},
{
"_id": "66a67da1d5842b25dc337506",
"description": "Shopping",
"amount": 4299,
"paidBy": {
"name": "Hemant",
"email": "[email protected]"
},
"participants": [
{
"name": "Chirag",
"email": "[email protected]",
"amount": 799
},
{
"name": "Ayush",
"email": "[email protected]",
"amount": 2000
},
{
"name": "Jai",
"email": "[email protected]",
"amount": 1500
}
],
"splitType": "exact",
"createdAt": "2024-07-28T17:19:29.545Z",
"updatedAt": "2024-07-28T17:19:29.545Z"
},
{
"_id": "66a68bff6f888f0dd3b66043",
"description": "Dinner",
"amount": 3000,
"paidBy": {
"name": "Trisha",
"email": "[email protected]"
},
"participants": [
{
"name": "Helen",
"email": "[email protected]",
"amount": 1000
},
{
"name": "Mesha",
"email": "[email protected]",
"amount": 1000
},
{
"name": "Karthik",
"email": "[email protected]",
"amount": 1000
}
],
"splitType": "equal",
"createdAt": "2024-07-28T18:20:47.575Z",
"updatedAt": "2024-07-28T18:20:47.575Z"
},
{
"_id": "66a68c856f888f0dd3b6605a",
"description": "Shopping",
"amount": 4299,
"paidBy": {
"name": "abhishek",
"email": "[email protected]"
},
"participants": [
{
"name": "amisha",
"email": "[email protected]",
"amount": 799
},
{
"name": "charu",
"email": "[email protected]",
"amount": 2000
},
{
"name": "ansh",
"email": "[email protected]",
"amount": 1500
}
],
"splitType": "exact",
"createdAt": "2024-07-28T18:23:01.182Z",
"updatedAt": "2024-07-28T18:23:01.182Z"
},
{
"_id": "66a68cf56f888f0dd3b6606f",
"description": "Party",
"amount": 1000,
"paidBy": {
"name": "Misha",
"email": "[email protected]"
},
"participants": [
{
"name": "Misha",
"email": "[email protected]",
"amount": 500
},
{
"name": "Madhav",
"email": "[email protected]",
"amount": 250
},
{
"name": "Rupali",
"email": "[email protected]",
"amount": 250
}
],
"splitType": "percentage",
"createdAt": "2024-07-28T18:24:53.910Z",
"updatedAt": "2024-07-28T18:24:53.910Z"
}
]
```

![image](https://github.com/user-attachments/assets/aa0185b5-144a-477f-9b95-2df6e430e014)

**Download Balance Sheet**

**Endpoint:** api/expenses/balance-sheet

![image](https://github.com/user-attachments/assets/62b15bfe-4f2b-45a6-a1b1-070788746feb)