Skip to content

🏗️ What's Inside

The Apptork Root System isn't just a skeleton — it is a heavily engineered, production-ready backend designed to save your team hundreds of hours of infrastructure, architecture, and integration work.

⏱️ The "Hours Saved" Breakdown

We've already done the hard work of building and battle-testing the complex systems every modern AI or SaaS platform needs.

About these estimates

The numbers below reflect the time required to build the complete, production-grade implementation — including admin UI integration, tests, error handling, edge cases, caching, and documentation. They do not represent the time to build a "weekend prototype".

System What's Included Est. Hours
Immutable Wallet select_for_update locking, audit trail, expiry periods, refund deduplication 80–120
Payment Integration RevenueCat + LemonSqueezy webhooks, signature verification, entitlement sync, daily reconciliation 60–80
AI Orchestration Transformer registry, provider registry, DAG engine, SSE streaming, cost management, auto-refunds 100–140
Auth System OTP + OAuth (Google/Apple), disposable email blocking, alias normalization, App Store test bypass 50–70
File Management Dual storage (public/private), SmartFileField, metadata backfill, orphaned file cleanup 40–50
Feature Management Platform/locale/time-window scoped flags, translatable system messages, admin UI 25–35
Device Intelligence Auto-extraction middleware with write throttle, per-device tracking, FCM tokens 15–25
DevOps Docker Compose with 5-stage boot, Nginx SSE config, CI/CD pipeline, health probes 30–40
Internationalization 10-language support with django-parler, locale middleware, country detection 15–25
Total ~415–585

🛠️ The Complete Technology Stack

We didn't just choose popular technologies; we chose an ecosystem that eliminates entire categories of work. Here is the full architecture and what each piece replaces:

Core Infrastructure

Component Why We Chose It
Django 5.2 The ultimate heavy-lifter. Gives us a secure ORM, automatic migrations, and a free admin back-office dashboard out of the box.
PostgreSQL ACID-compliant transactional guarantees for the wallet ledger, plus powerful ArrayField and JSONField support for feature flags and AI metadata.
Redis Multi-database architecture. Acts as our Celery message broker, high-speed cache, and pub/sub engine for real-time SSE streaming.
Celery Distributed task queue for asynchronous AI generation, webhook processing, and background maintenance.
MinIO / AWS S3 Enterprise-grade object storage. MinIO provides 100% S3 compatibility for local development, meaning zero code changes when moving to AWS in production.
Docker Compose Strict containerized environments ensuring absolute parity between your laptop and the production server.

🤖 Native AI Integrations

The boilerplate ships with native, production-ready BaseProviderClient implementations for the industry's leading AI platforms:

Provider What It Unlocks
Replicate Instant access to open-source powerhouses like Llama 3, Stable Diffusion, and Flux, plus thousands of community fine-tuned models for highly specialized tasks without managing GPUs.
OpenAI Industry-standard language models (GPT-4o) and image generation (DALL-E 3), seamlessly integrated with the Prompt Improver pipeline.

The Python Ecosystem

Package What It Eliminates
django-parler Building a custom, brittle translation system for your database models
django-storages Writing custom abstraction layers for S3/MinIO uploads
drf-spectacular Manual OpenAPI schema maintenance (you get Swagger + ReDoc for free)
drf-standardized-errors Inconsistent error formats breaking your mobile client
django-celery-beat Relying on external crons and writing custom scheduling logic
django-health-check Writing bespoke probe endpoints for your Database, Redis, Celery, and S3
django-eventstream The massive complexity of managing raw WebSockets for real-time updates
langdetect + OpenAI Building prompt translation pipelines from scratch

🚦 Why Gunicorn + Uvicorn (Not Daphne)

If you're running heavy AI inference on a limited-RAM server, you've probably watched your containers die silently due to massive memory leaks. The culprit is often how you serve asynchronous Python.

Many teams default to Daphne for long-lived connections. But under the heavy memory pressure of streaming AI payloads, Daphne's single-process architecture becomes a severe bottleneck. The process swells up and fails to release RAM back to the OS.

The Fix: A Managed Worker Pool

We use Gunicorn with Uvicorn workers. This shifts you from a monolithic process to a managed pool of isolated workers.

The real magic here is Gunicorn's --max-requests parameter (and Celery's --max-tasks-per-child). By forcing workers to systematically recycle themselves after handling a set number of requests, we guarantee memory is reclaimed at the OS level:

gunicorn config.asgi:application -k uvicorn.workers.UvicornWorker --workers 2
(As seen in our production Dockerfile)

As a final safeguard, we enforce hard memory limits (e.g., mem_limit: 768M) in our Docker configurations. If a worker starts bloating, Docker will kill and restart that specific container long before it threatens the host OS.


🗄️ Redis: Four Isolated Databases

We use Redis as our Swiss Army knife, but we strictly isolate its responsibilities to prevent different types of traffic from interfering with each other:

  • DB0 (Cache): Ephemeral caching for feature flags, active system messages, and API responses.
  • DB1 (Broker): Celery task queues.
  • DB2 (Results): Celery task results and states.
  • DB4 (EventStream): Dedicated pub/sub channels for our Server-Sent Events (SSE).

By isolating the EventStream to DB4, we ensure that high-volume real-time streaming traffic doesn't evict critical items from your cache or slow down your background task broker.