A full-stack expense tracking application built with FastAPI (Python) backend and React frontend, similar to Splitwise. This application helps users track shared expenses and manage group finances.
- User Management: Create and manage users in the system
- Group Management: Create groups with multiple users
- Expense Tracking: Add expenses with different split types (equal or percentage)
- Balance Calculation: Automatic calculation of who owes whom
- Settlement System: Record payments between users to settle debts
- User/Group Management: Full CRUD operations with safety checks for outstanding balances
- Responsive Design: Beautiful UI with dark/light theme support
- Precision Currency Handling: All monetary values are precisely rounded to 2 decimal places
- Mathematical Consistency: Expense splits always add up exactly to the total amount
- Data Integrity: Prevention of deletion when outstanding balances exist
- Dark/Light Theme: Toggle between themes with localStorage persistence
- RESTful API: Well-documented FastAPI backend
- Real-time Updates: Automatic balance calculations
- Responsive Design: Mobile-friendly interface using TailwindCSS
- FastAPI: Modern, fast web framework for building APIs
- PostgreSQL: Robust relational database
- SQLAlchemy: Python SQL toolkit and ORM
- Pydantic: Data validation using Python type annotations
- Alembic: Database migration tool
- React 18: Modern React with hooks
- React Router: Client-side routing
- Axios: HTTP client for API calls
- TailwindCSS: Utility-first CSS framework
- Context API: State management for theme
- Docker: Containerization
- Docker Compose: Multi-container orchestration
- Docker and Docker Compose installed on your system
- Git (to clone the repository)
-
Clone the repository
git clone https://github.com/SimpNick6703/Splitwise-Clone cd Splitwise-Clone
-
Start the application
docker-compose up --build
This command will:
- Build the backend and frontend Docker images
- Start PostgreSQL database
- Start the FastAPI backend on port 8000
- Start the React frontend on port 3000
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
-
Initialize with sample data (optional)
# Install Python dependencies for helper scripts pip install -r scripts_requirements.txt # Run the sample data initialization script python init_sample_data.py
For convenience, use the provided startup scripts:
Windows:
start.bat
Linux/Mac:
chmod +x start.sh
./start.sh
To verify all services are running correctly:
python health_check.py
POST /users/
- Create a new userGET /users/
- Get all usersGET /users/{user_id}
- Get specific userPUT /users/{user_id}
- Update user detailsDELETE /users/{user_id}
- Delete user (only if no outstanding balances)GET /users/{user_id}/balances
- Get user's balances across all groups
POST /groups/
- Create a new groupGET /groups/
- Get all groupsGET /groups/{group_id}
- Get group detailsPUT /groups/{group_id}
- Update group detailsDELETE /groups/{group_id}
- Delete group (only if no outstanding balances)GET /groups/{group_id}/balances
- Get group balancesGET /groups/{group_id}/expenses
- Get group expensesPOST /groups/{group_id}/members
- Add members to groupDELETE /groups/{group_id}/members/{user_id}
- Remove member from group
POST /groups/{group_id}/expenses
- Add expense to group
POST /settlements
- Record a payment between usersGET /groups/{group_id}/settlements
- Get all settlements for a group
POST /users/
{
"name": "John Doe",
"email": "john@example.com"
}
POST /groups/
{
"name": "Weekend Trip",
"description": "Our weekend getaway expenses",
"user_ids": [1, 2, 3]
}
POST /groups/1/expenses
{
"description": "Dinner at restaurant",
"amount": 120.00,
"paid_by": 1,
"split_type": "equal",
"splits": []
}
POST /groups/1/expenses
{
"description": "Hotel accommodation",
"amount": 300.00,
"paid_by": 1,
"split_type": "percentage",
"splits": [
{"user_id": 1, "percentage": 50.0},
{"user_id": 2, "percentage": 30.0},
{"user_id": 3, "percentage": 20.0}
]
}
-
Navigate to backend directory
cd backend
-
Install dependencies
pip install -r requirements.txt
-
Set up PostgreSQL database
- Install PostgreSQL
- Create database named
splitwise
- Update
DATABASE_URL
indatabase.py
if needed
-
Run the backend
python main.py
-
Navigate to frontend directory
cd frontend
-
Install dependencies
npm install
-
Start the development server
npm start
- Dashboard: Overview of groups, users, and total expenses
- Groups Page: Manage groups and create new ones
- Group Details: View expenses, balances, and add new expenses
- Users Page: Manage users in the system
- Theme Toggle: Switch between dark and light themes
- Equal Split: Divides expense equally among all group members
- Percentage Split: Allows custom percentage allocation for each member
The application automatically calculates:
- Individual user balances within groups
- Net amounts owed or to be received
- Simplified debt relationships
The project includes several helper scripts to make development and testing easier:
start.bat
(Windows) /start.sh
(Linux/Mac): Automated startup with Docker- Checks for Docker availability
- Builds and starts all services
- Provides status updates and URLs
init_sample_data.py
: Populates the application with sample users, groups, and expenses- Perfect for testing and demo purposes
- Run after the application is started
health_check.py
: Verifies all services are running correctly- Checks backend, frontend, and API documentation availability
- Useful for debugging deployment issues
# Start the application
./start.sh # or start.bat on Windows
# Check if everything is running
python health_check.py
# Add sample data
python init_sample_data.py
- No Authentication: The application doesn't include user authentication for simplicity
- No Payment Processing: Focus is on expense tracking, not actual money transfer
- Simplified Debt Calculation: Uses basic net balance calculation instead of complex debt simplification algorithms
- Single Currency: All amounts are assumed to be in the same currency (INR ₹)
- Group Membership: Users must be added to groups to participate in expenses
backend/
├── main.py # FastAPI application entry point
├── models.py # SQLAlchemy database models
├── schemas.py # Pydantic models for request/response
├── database.py # Database configuration
├── crud.py # Database operations
└── requirements.txt # Python dependencies
frontend/src/
├── components/ # Reusable UI components
├── pages/ # Page components
├── services/ # API service layer
├── context/ # React context providers
├── App.js # Main application component
└── index.js # Application entry point
- Backend: Add new endpoints in
main.py
, models inmodels.py
, and schemas inschemas.py
- Frontend: Create new components in
components/
or pages inpages/
- Database: Use Alembic for database migrations
- Uses TailwindCSS utility classes
- Custom color palette defined in
tailwind.config.js
- Dark/light theme support with CSS variables
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is open source and available under the MIT License.
For issues and questions, please create an issue in the GitHub repository.