A backend service for managing group expenses, settlements, and user balances, inspired by the functionality of Splitwise. This system allows users to create groups, add members, track shared expenses, calculate balances, and settle up debts within groups.
- Groups: Create groups, add/remove members, and manage group membership.
- Expenses: Add, update, and remove expenses for a group. Split expenses among members and track individual shares.
- Settlements: Settle debts, view settlement history, and calculate optimal settlements to minimize transactions.
- Users: Manage user accounts, including registration, authentication, and user retrieval.
- Python 3.12
- SQLAlchemy
- FastAPI
- PostgreSQL
- Alembic
- Python 3.12
- PostgreSQL
-
Clone the repository:
git clone https://github.com/vin0dkhichar/splitwise-backend.git cd splitwise-backend -
Set up a virtual environment with Python 3.12:
python3.12 -m venv .venv source .venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.envfile in the root directory with the following content:DATABASE_URL=postgresql+psycopg2://postgres:admin@localhost:5432/splitwise SECRET_KEY=your-super-secret-key-here-make-it-long-and-complex ALGORITHM=HS256 ACCESS_TOKEN_EXPIRE_MINUTES=60 -
Database Setup:
# Create database createdb -U postgres splitwise # Initialize Alembic alembic init migrations # Configure alembic.ini with your DATABASE_URL # Update alembic/env.py to import your models # Generate and run migrations alembic revision --autogenerate -m "Initial tables" alembic upgrade head
-
Run the server:
uvicorn app.main:app --reload
The API will be available at
http://localhost:8000and the interactive documentation athttp://localhost:8000/docs.