Skip to content
← back to projects
2026·shipped·Creator & Maintainer

FastAPI E-Commerce API

A production-oriented e-commerce backend: full catalog and checkout, Stripe payments and subscriptions, multi-currency pricing, loyalty and gift cards, and a full observability stack.

PythonFastAPIPostgreSQLRedisStripeElasticsearchOpenTelemetry

Architecture

FastAPI app
Catalog, cart, checkout, orders
↓ calls out to
PostgreSQL
Outbox + row locks
Stripe
Payments + subscriptions
ARQ worker
Renewals, alerts, cleanup
Elasticsearch
Product search
OTel + Prometheus
Traces, metrics, logs

Highlights

  • ▸Stripe PaymentIntents and webhooks with idempotency keys on every payment-creating request.
  • ▸Recurring subscription orders billed off-session, with pause, resume, skip, and dunning on failed renewals.
  • ▸Outbox pattern for reliable domain events and row-level locking on stock reservations.
  • ▸Tests run against a real, ephemeral PostgreSQL container via testcontainers instead of SQLite.

Scope

An e-commerce backend built to cover the parts most tutorials skip: what happens after the cart.

  • Accounts: JWT access and refresh tokens, Argon2 hashing, email verification, TOTP-based MFA, and Google and Facebook login.
  • Catalog: variants, brands, hierarchical categories, tax rates, shipping zones, product Q&A, and CSV bulk import and export.
  • Checkout: persistent and guest carts, coupons, promotions, loyalty points, and gift cards, all stackable, with multi-currency display on top of base-currency accounting.
  • Orders: the full lifecycle from pending to delivered, guest order tracking with later account claiming, returns with admin-approved refunds, and PDF invoices.

Reliability

Money and inventory are where e-commerce backends quietly go wrong, so that is where most of the engineering went:

  • Idempotency keys on payment-creating requests, so a retried call never charges twice.
  • Row-level locking on stock reservations, plus a background job that cleans up expired ones.
  • The outbox pattern, so domain events are published reliably and never lost between a commit and a message send.
  • An ARQ worker for subscription renewals, abandoned-cart emails, and back-in-stock and price-drop alerts.

Observability and testing

Structured JSON logs, OpenTelemetry tracing, and Prometheus metrics, with Docker Compose bringing up Grafana, Loki, and Tempo alongside the app. The test suite runs against a real PostgreSQL container, so it exercises the same database engine as production.