A simple REST API for managing Pro plan subscriptions.
- Minimalist domain design
- Ready to run — out of the box with Docker
- Unit and functional tests — covering domain logic and API behavior
- One Pro plan per customer
- Identified by external ID — a unique identifier provided by your app
- Simple management — no states, just an active Pro plan flag
💡 Tip: If you manage users for multiple apps at once, add a prefix to the customer external ID, e.g.
myapp:user-1.
- Health check — service availability
- Stripe
- Create checkout session
- Handle webhooks —
checkout.session.completed,customer.subscription.deleted - Create billing portal session
- Get customer — retrieves customer details
💡 Tip: Use
success_urlparameter when creating a checkout session to perform additional post-payment actions, such as sending a Pro plan welcome email.
- Python + FastAPI
- Clean Architecture
- Use-case driven design
- Rich domain models — organized into domain modules
- Value objects
- UUIDs — primary identifiers
- Docker
- Docker Compose
Run the project:
docker compose up -dThis starts the whole project, including database migrations, which run automatically before the API starts.
API Base URL: http://localhost/api
- API Docs: http://localhost/docs
Useful commands are available in the Makefile.
Run the project with the environment variables from .env.dist set to production values. Also set DATABASE_PASSWORD for the database container to match the password in DATABASE_URL:
API_TOKEN='...' \
DATABASE_PASSWORD='...' \
DATABASE_URL='...' \
STRIPE_API_KEY='...' \
STRIPE_PRICE_ID_MONTHLY='...' \
STRIPE_PRICE_ID_YEARLY='...' \
STRIPE_WEBHOOK_SECRET='...' \
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -dAn example project demonstrating backend system design.
Dušan Mlynarčík — Senior Backend Engineer & App Builder