{"id":18068408,"url":"https://github.com/aniketwdubey/expense-sharing-application-using-fastapi","last_synced_at":"2025-04-11T23:24:09.666Z","repository":{"id":259215810,"uuid":"876968795","full_name":"aniketwdubey/Expense-Sharing-Application-using-FastAPI","owner":"aniketwdubey","description":"This is a backend service for managing and sharing daily expenses between users. The application allows users to add expenses and split them in three different ways: equally, by exact amounts, or by percentage. It also manages user details, validates input, and generates a downloadable balance sheet.","archived":false,"fork":false,"pushed_at":"2024-10-27T20:17:28.000Z","size":1376,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T19:15:41.562Z","etag":null,"topics":["api","apidevelopment","expense","expense-management","expense-tracker-app","fastapi","sqlalchemy","sqlalchemy-orm"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aniketwdubey.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-22T21:24:34.000Z","updated_at":"2025-03-12T15:40:37.000Z","dependencies_parsed_at":"2024-10-27T21:56:35.737Z","dependency_job_id":null,"html_url":"https://github.com/aniketwdubey/Expense-Sharing-Application-using-FastAPI","commit_stats":null,"previous_names":["aniketwdubey/expense-sharing-application-using-fastapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aniketwdubey%2FExpense-Sharing-Application-using-FastAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aniketwdubey%2FExpense-Sharing-Application-using-FastAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aniketwdubey%2FExpense-Sharing-Application-using-FastAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aniketwdubey%2FExpense-Sharing-Application-using-FastAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aniketwdubey","download_url":"https://codeload.github.com/aniketwdubey/Expense-Sharing-Application-using-FastAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248493689,"owners_count":21113301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","apidevelopment","expense","expense-management","expense-tracker-app","fastapi","sqlalchemy","sqlalchemy-orm"],"created_at":"2024-10-31T08:06:20.526Z","updated_at":"2025-04-11T23:24:09.645Z","avatar_url":"https://github.com/aniketwdubey.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Daily Expenses Sharing Application\n\n## Overview\nThis is a backend service for managing and sharing daily expenses between users. The application allows users to add expenses and split them in three different ways: equally, by exact amounts, or by percentage. It also manages user details, validates input, and generates a downloadable balance sheet.\n\n### Key Features:\n- **User Management:** Create, retrieve, and manage users.\n- **Expense Management:** Add expenses with various split methods.\n- **Balance Sheet:** Track individual expenses, total expenses, and download balance sheets.\n\n## Project Structure\n```\n├── README.md\n├── app\n│   ├── api\n│   │   ├── users.py            # API logic for user management\n│   │   ├── expenses.py         # API logic for expenses\n│   │   └── users.py            # API logic for balance management\n│   ├── core\n│   │   └── database.py         # Database connection setup\n│   ├── main.py                 # Application entry point\n│   ├── models\n│   │   └── models.py           # Database models for users, expenses, and balances\n│   └── schemas\n│       ├── users.py            # Pydantic models for user creation\n│       ├── expenses.py         # Pydantic models for expense creation\n│       └── balance.py          # Pydantic models for balance creation\n└── requirements.txt            # Required Python packages\n```\n\n## Setup and Installation\n\n### 1. Clone the repository\n```\ngit clone \u003crepository-url\u003e\ncd \u003crepository-directory\u003e\n```\n\n### 2. Install dependencies\nEnsure you have Python 3.9+ installed. Install the required packages:\n```\npip install -r requirements.txt\n```\n\n### 3. Database Setup\nThis application uses PostgreSQL as the database. Make sure PostgreSQL is installed and running on your machine.\n\nCreate a new PostgreSQL database and update the `SQLALCHEMY_DATABASE_URL` in `app/core/database.py` to match your PostgreSQL credentials:\n```python\nSQLALCHEMY_DATABASE_URL = \"postgresql://\u003cusername\u003e:\u003cpassword\u003e@localhost:5432/\u003cdatabase\u003e\"\n```\n\n### 4. Run the Application\nStart the FastAPI server:\n```\nuvicorn app.main:app --reload\n```\n\nThe application will be available at `http://127.0.0.1:8000`.\n\n### 6. Data Models\n#### Users\n- **User**: Contains `id`, `name`, `email`, and `mobile`.\n\n#### Expenses\n- **Expense**: Contains `id`, `amount`, `description`, `paid_by`, `split_method`, and `user_ids`.\n\n#### Balance\n- **Balance**: Tracks the balance for each user, including the `user_id`, `user_name`, and `amount_owed`.\n\n### 5. API Endpoints\nThe API endpoints are organized as follows:\n\n#### User Endpoints:\n- `POST /users/`: Create a new user.\n- `GET /users/{user_id}`: Retrieve details of a specific user.\n- `GET /users/`: Retrieve all users.\n\n#### Expense Endpoints:\n- `POST /expenses/`: Add a new expense.\n- `GET /expenses/{user_id}`: Retrieve individual expenses for a user.\n- `GET /expenses/`: Retrieve overall expenses.\n\n#### Balance Sheet Endpoints:\n- `GET /balance/{user_id}`: Retrieve the balance sheet for a specific user.\n- `GET /balance/`: Retrieve overall balances for all users.\n- `GET /download`: Download the balance sheet as a file.\n\n\n### 6. Example Usage\n\n#### Add Users\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 5.46.01 PM.png\u003e)\n\n#### Users Table\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 5.49.17 PM.png\u003e)\n\n#### Add Expenses\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 7.14.39 PM.png\u003e)\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 6.39.26 PM.png\u003e)\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 6.47.22 PM.png\u003e)\n\n#### Expenses Table\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 6.47.43 PM.png\u003e)\n\n#### Retrieve overall expenses.\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 7.24.43 PM.png\u003e)\n\n#### Retrieve individual user expenses.\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 7.23.06 PM.png\u003e)\n\n#### Balance Table\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 6.47.48 PM.png\u003e)\n\n#### Balance Sheet - Show overall expenses for all users.\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 7.28.37 PM.png\u003e)\n\n#### Download Balance Sheet\n![alt text](\u003cscreenshots/Screenshot 2024-10-23 at 7.30.03 PM.png\u003e)\n\n### 7. Interacting with the API\nTo interact with the API, you can use the automatically generated FastAPI documentation, which provides a user-friendly interface to explore and test the endpoints.\n\nFastAPI Documentation UI\nFastAPI provides an interactive documentation UI, which can be accessed at the following paths after running the application:\n\nSwagger UI: Navigate to http://127.0.0.1:8000/docs to access Swagger, which allows you to interact with the API directly from your browser.\nReDoc: Alternatively, you can use http://127.0.0.1:8000/redoc for a different style of documentation.\n\n\u003c!-- ### 7. Data Validation\nThe application ensures the following:\n- **User input validation**: Email and mobile numbers must be unique.\n- **Split validation**: For percentage splits, the total must add up to 100%. --\u003e\n\n\u003c!-- ## Bonus Features\n- **Error handling**: The application includes basic error handling.\n- **Input validation**: Data is validated before being processed.\n- **Downloadable balance sheets**: Users can download a detailed balance sheet.\n  \n### Potential Improvements:\n- **Authentication and Authorization**: Secure the API with user authentication.\n- **Performance Optimization**: Add caching for large datasets.\n- **Testing**: Unit and integration tests can be added for better reliability. --\u003e\n\n## License\nThis project is licensed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faniketwdubey%2Fexpense-sharing-application-using-fastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faniketwdubey%2Fexpense-sharing-application-using-fastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faniketwdubey%2Fexpense-sharing-application-using-fastapi/lists"}