Skip to content
Back to work

Case study

Shared Django Backend

One Django backend that runs the APIs for all four apps.

PythonDjangoDRFPostgreSQLDocker
Shared Django Backend

The problem

Four apps, one developer. Running a separate backend per app would mean four copies of auth, payments, deploys and on-call. I needed one backend that every app could use without their data and rules leaking into each other.

What I built

  • •One Django REST Framework project. Each product is its own Django app under products/ (ryddar, decorifai, cartoonifai, mood2drink) with its own models, migrations, admin, URLs and tests.
  • •One shared User model with JWT authentication (SimpleJWT, rotating refresh tokens, a blacklist) and Sign in with Apple and Google. Apps that work without an account start with an anonymous device installation, which is linked to the user when they sign in.
  • •A credits ledger: every purchase, refund, reward and generation is an entry with a unique reference.
  • •RevenueCat webhooks for subscriptions and consumable packs, including refunds that take credits back.
  • •Docker images deployed to a Hetzner server behind Caddy, with GitHub Actions running the tests and deploying to production.

The hard part

Credits that never double-count

Payment providers retry webhooks, users double-tap and networks drop responses. Each ledger entry carries a unique reference (for example the store transaction ID), so a retried event can't add credits twice. Balance changes run inside transaction.atomic with select_for_update on the account row, so two requests can't spend the same credit at the same time.

Results

  • Runs the APIs for 4 App Store apps from a single deployment
  • Adding a product means adding a Django app; auth, payments and deploys are already there
  • Test suites per product, run in CI before every deploy

The code is private because it runs production apps. Happy to walk through it in an interview.