Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Daily Expenses Sharing Application

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

Features

  • 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%).

Screenshots

  • Create User image
  • Create Expense image
  • Downloaded Balance Sheet image

Prerequisites

  • Python 3.8+

  • SQLite (included with Python)

  • Docker

Installation

  1. Clone the repository:
git clone https://github.com/Addy-codes/expense-calculator.git
cd expense-calculator
  1. Create a .env file and paste the below text:
SQLALCHEMY_DATABASE_URL=sqlite:///./test.db
  1. Run the service using docker
docker build -t daily-expenses-app .
docker run -d -p 8000:8000 --name daily-expenses-container daily-expenses-app

This 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.

Manual Installation

  1. Clone the repository:
git clone https://github.com/Addy-codes/expense-calculator.git
cd expense-calculator
  1. Create a virtual environment and activate it:
python -m venv venv
venv\Scripts\activate
  1. Install the required packages:
pip install -r requirements.txt

Database Setup

  1. Create a .env file and paste the below text:
SQLALCHEMY_DATABASE_URL=sqlite:///./test.db

Running the Application

  1. Start the FastAPI server:
uvicorn app.main:app --reload
  1. Open your browser and navigate to http://127.0.0.1:8000/docs to access the Swagger UI for API documentation and testing.

API Endpoints

User Endpoints

  • Add user: POST /api/v1/user/

  • Retrieve user: GET /api/v1/user/{user_id}

Expense Endpoints

  • 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

Sample Data

Create User

{
"email": "adeeb@convin.in",
"name": "Adeeb",
"mobile_number": "1234567890"
}

Create Expense

  • 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

Equal Split

{
"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}"
}

Exact Split

{
"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}"
}

Percentage Split

{
"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}"
}

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages