Skip to content

Architecture

Revel's backend is a Django application that uses Django Ninja for the API layer, Celery for async tasks, and PostgreSQL (with PostGIS) for storage. The codebase follows a clear separation between controllers (API endpoints), services (business logic), and models (data layer).

graph LR
    Client -->|HTTP/JWT| API[Django Ninja API]
    API --> Controllers
    Controllers --> Services
    Services --> Models
    Services --> Celery[Celery Tasks]
    Celery --> Services
    Models --> PostgreSQL[(PostgreSQL)]
    Celery --> Redis[(Redis)]

Core Principles

  • Service layer owns business logic: controllers are thin, models are data-only
  • Hybrid service pattern: functions for stateless ops, classes for stateful workflows
  • Explicit over magic: no DI container, no framework lock-in beyond Django Ninja
  • Type safety: strict mypy, typed schemas, model enums as source of truth

Sections

Topic What You'll Learn
Service Layer When to use functions vs. classes, controller integration
Controllers Django Ninja Extra patterns, auth, throttling
Permissions & Roles Organization roles, event-level access control
Eligibility Pipeline The gate-by-gate system that determines event access
Membership Eligibility The gate-by-gate pipeline behind joining an organization, with the advance-on-read application state machine
Advanced Waitlist Batched, time-limited offers with reserved capacity for waitlist members
Series Passes Season tickets covering every event in a series, with pro-rata pricing
Protected Files HMAC-signed URLs with Caddy (and why not S3)
Notifications Multi-channel delivery: in-app, email, Telegram
Email Sending & Opt-Out Organization sender, mail users can't opt out of, one-click unsubscribe, per-org mute, suppression list
File Security EXIF stripping, ClamAV malware scanning, quarantine
Questionnaires LLM-powered evaluation, prompt injection protection
Billing & VAT VAT calculations, VIES validation, invoice generation, PDF rendering
Membership Subscriptions Recurring membership billing — OFFLINE/ONLINE hybrid, Stripe Connect, dunning, revival
White-Label Tenant resolution, custom-domain lifecycle, dynamic CORS, brand-theme derivation, org-aware URLs and the account-token security rule
XLSX Exports Async Excel exports with FileExport lifecycle and email delivery