A full-stack application for effortlessly splitting expenses among friends by uploading receipt images. The system uses Google's Gemini AI to extract item details and integrates with Splitwise for expense management.
This project consists of two main components:
/
├── backend/ # FastAPI backend application
│ ├── fastapi-env/ # Python virtual environment
│ ├── models/ # Pydantic data models
│ ├── utils/ # Backend utilities
│ ├── img/ # Temporary receipt storage
│ ├── main.py # FastAPI app entry point
│ └── README.md # Backend documentation
│
├── frontend/ # Next.js frontend application
│ ├── app/ # Next.js app router pages
│ ├── components/ # React components
│ └── README.md # Frontend documentation
│
└── README.md # This file
- Backend: Processes receipt images with Gemini AI, calculates expense splits, and integrates with Splitwise API
- Frontend: Provides a user-friendly interface for uploading images, assigning items to people, and creating expenses
- Python 3.10+ for the backend
- Node.js 18+ for the frontend
- Splitwise API credentials
- Google Gemini API key
# Navigate to backend directory
cd backend
# Create and activate virtual environment
python -m venv fastapi-env
source fastapi-env/bin/activate # On Windows: fastapi-env\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file with your API keys
cp .env.example .env
# Edit .env with your actual API keys
# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# or
yarn install
# or
pnpm install
# Create environment file
cp .env.example .env.local
# Set SPLIT_API_BASE_URL to point to your backend
cd backend
source fastapi-env/bin/activate # On Windows: fastapi-env\Scripts\activate
uvicorn main:app --reload --host 0.0.0.0 --port 8000
cd frontend
npm run dev
# or
yarn dev
# or
pnpm dev
Then open http://localhost:3000 in your browser.
The backend requires the following environment variables to be set:
# In backend/.env file
SPLITWISE_API_KEY=your_splitwise_api_key
GOOGLE_API_KEY=your_google_gemini_api_key
Important: Make sure there are no extra spaces at the beginning of lines in the .env
file.
cd backend
.\venv\Scripts\activate
$env:SPLITWISE_API_KEY="your_api_key"
$env:GOOGLE_API_KEY="your_gemini_key"
uvicorn main:app --reload
Or use the provided scripts:
# Windows
.\start_server.bat
# PowerShell
.\start_server.ps1
- Make changes to backend (FastAPI)
- Test API endpoints using browser or tools like curl/Postman
- Make changes to frontend (Next.js)
- Test the end-to-end flow
For local development, you may want to use proxy settings in the frontend to avoid CORS issues:
In frontend/next.config.js
:
/** @type {import('next').NextConfig} */
const nextConfig = {
async rewrites() {
return [
{
source: '/api/:path*',
destination: 'http://localhost:8000/:path*',
},
]
},
}
module.exports = nextConfig
- Backend tests can be run with
pytest
- Frontend tests can be run with
npm test
orjest
- Backend can be deployed on any Python-supported server (AWS, GCP, DigitalOcean)
- Frontend can be deployed on Vercel, Netlify, or any Next.js-supported hosting
- Ensure API URLs are correctly configured for production