Skip to content

dusanmlynarcikdev/pro-plan-api

Repository files navigation

⭐️ Pro Plan API

A simple REST API for managing Pro plan subscriptions.

⚡ Highlights

  • Minimalist domain design
  • Ready to run — out of the box with Docker
  • Unit and functional tests — covering domain logic and API behavior

🙎‍♂️ Customers

  • 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.

🔌 API Endpoints

  • Health check — service availability
  • Stripe
    • Create checkout session
    • Handle webhookscheckout.session.completed, customer.subscription.deleted
    • Create billing portal session
  • Get customer — retrieves customer details

💡 Tip: Use success_url parameter when creating a checkout session to perform additional post-payment actions, such as sending a Pro plan welcome email.

🏗️ Stack & Architecture

  • Python + FastAPI
  • Clean Architecture
  • Use-case driven design
  • Rich domain models — organized into domain modules
  • Value objects
  • UUIDs — primary identifiers

⚙️ Getting Started

Requirements

  • Docker
  • Docker Compose

Development

Run the project:

docker compose up -d

This starts the whole project, including database migrations, which run automatically before the API starts.

URLs

API Base URL: http://localhost/api

Tools

Commands

Useful commands are available in the Makefile.

Production

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 -d

🎯 About the Project

An example project demonstrating backend system design.

🧑‍💻 Author

Dušan Mlynarčík — Senior Backend Engineer & App Builder

About

A simple REST API for managing Pro plan subscriptions, built with Clean Architecture and FastAPI in Python.

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Contributors

Languages