Scale-Trip is a backend API for managing shared expenses among friends on trips. It allows users to create trips, add participants, log expenses, and track balances. Built with Python, FastAPI, SQLModel, and PostgreSQL, it is async-ready and can be containerized with Docker.
- Create, list, and retrieve Users
- Create, list, and retrieve Trips
- Add Expenses to trips
- Async database operations with PostgreSQL
- Automatic database table creation on startup
- Interactive API documentation via Swagger (
/docs)
- Python 3.12+
- FastAPI – backend framework
- SQLModel – ORM + Pydantic for models and validation
- PostgreSQL – relational database
- asyncpg – async PostgreSQL driver
- Uvicorn – ASGI server
- Docker & Docker Compose – containerization for local development and deployment
- Clone the repository:
git clone https://github.com/wineshuga/scale-trip.git
cd scale-trip- Create a virtual environment and activate it:
python3 -m venv .venv
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Create a .env file with your database URL:
POSTGRES_USER=user
POSTGRES_PASSWORD=password
POSTGRES_DB=dbname
DATABASE_URL=postgresql+asyncpg://username:password@db:5432/scale_trip
SECRET_KEY=secret
ALGORITHM=algorithm
ACCESS_TOKEN_EXPIRE_MINUTES=minutes
You can run the app and PostgreSQL together using Docker Compose.
- Build and start containers:
docker-compose up --buildAccess the API at http://127.0.0.1:8000
Interactive API docs: http://127.0.0.1:8000/docs
- To stop containers:
docker-compose downNotes:
The docker-compose.yml sets up both the FastAPI app and PostgreSQL database.
Database data is persisted using Docker volumes.
Environment variables are read from .env automatically in the containers.
scale-trip/
├── app/
| ├── routers/ # Application routers and endpoints
| ├── services/ # Application logic
| ├── auth.py # User authentication
│ ├── main.py # FastAPI app and routes
│ ├── models.py # SQLModel database models
│ ├── database.py # DB engine and async session setup
| ├── schemas.py
│ └── config.py # Environment configuration
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Dockerfile for the FastAPI app
├── .env # Environment variables
├── requirements.txt # Python dependencies
└── README.md # Project documentation-
Users
- POST /users → create a new user
- GET /users → list all users
- GET /users/{user_id} → retrieve a single user
-
Trips
- POST /trips → create a new trip
- GET /trips → list all trips
- GET /trips/{trip_id} → retrieve a single trip
-
Expenses
- POST /expenses → create a new expense
- GET /expenses → list all expenses
- GET /expenses/{expense_id} → retrieve a single expense
-
Payments
- GET /wallet/{user_id} → get user wallet details
- POST /wallet/topup-request → mock paystack wallet top up
- POST /wallet/confirm → Admin/dev endpoint for topup confirmation
- POST /wallet/pay → execute payment using calculated balance
- Dockerized production deployment on AWS ECS/Fargate
- Track user payment status and history
- Integrate wallets and 3rd-party payment (Paystack)