This project is a Daily Expenses Sharing Application built with FastAPI, SQLAlchemy, SQLite and Docker. It allows users to share and manage daily expenses with ease, providing multiple ways to split expenses and generating balance sheets for download.
This Backend Web-Service is deployed on Render: https://expense-calculator-tlbo.onrender.com/docs
-
User Management: Add and retrieve users.
-
Expense Management:
-
Add expenses.
-
Retrieve individual user expenses.
-
Retrieve overall expenses.
-
Download balance sheets showing individual and overall expenses.
-
Expense Splitting Methods:
-
Equal: Split equally among all participants.
-
Exact: Specify the exact amount each participant owes.
-
Percentage: Specify the percentage each participant owes (ensuring percentages add up to 100%).
-
Python 3.8+
-
SQLite (included with Python)
-
Docker
- Clone the repository:
git clone https://github.com/Addy-codes/expense-calculator.git
cd expense-calculator- Create a .env file and paste the below text:
SQLALCHEMY_DATABASE_URL=sqlite:///./test.db
- Run the service using docker
docker build -t daily-expenses-app .
docker run -d -p 8000:8000 --name daily-expenses-container daily-expenses-appThis command will start a Docker container from the daily-expenses-app image and map port 8000 on your host to port 8000 in the container.
- Clone the repository:
git clone https://github.com/Addy-codes/expense-calculator.git
cd expense-calculator- Create a virtual environment and activate it:
python -m venv venv
venv\Scripts\activate- Install the required packages:
pip install -r requirements.txt- Create a .env file and paste the below text:
SQLALCHEMY_DATABASE_URL=sqlite:///./test.db- Start the FastAPI server:
uvicorn app.main:app --reload- Open your browser and navigate to
http://127.0.0.1:8000/docsto access the Swagger UI for API documentation and testing.
-
Add user:
POST /api/v1/user/ -
Retrieve user:
GET /api/v1/user/{user_id}
-
Add expense:
POST /api/v1/expenses/ -
Retrieve individual user expenses:
GET /api/v1/expenses/user/{user_id} -
Retrieve overall expenses:
GET /api/v1/expenses/ -
Download balance sheet:
GET /api/v1/expenses/balance-sheet
{
"email": "adeeb@convin.in",
"name": "Adeeb",
"mobile_number": "1234567890"
}- Note: for each instance of {id}, copy the id returned while creating a user. If you're using the deployed version on render, you can use the below two id's
78c3a591-6591-49f0-96e4-fde1322fd074
d3ce59cf-cdd9-4804-b30a-00c22cb94f54
{
"description": "Team lunch",
"amount": 120.0,
"split_type": "equal",
"participants": [
{
"user_id": "{id}",
"amount": null,
"percentage": null
},
{
"user_id": "{id}",
"amount": null,
"percentage": null
}
],
"created_by": "{id}"
}{
"description": "Office supplies",
"amount": 150.0,
"split_type": "exact",
"participants": [
{
"user_id": "{id}",
"amount": 80.0,
"percentage": null
},
{
"user_id": "{id}",
"amount": 70.0,
"percentage": null
}
],
"created_by": "{id}"
}{
"description": "Project celebration dinner",
"amount": 200.0,
"split_type": "percentage",
"participants": [
{
"user_id": "{id}",
"amount": null,
"percentage": 60.0
},
{
"user_id": "{id}",
"amount": null,
"percentage": 40.0
}
],
"created_by": "{id}"
}

