Open the editor

Django stack architecture

Python's batteries-included framework, with PostgreSQL, Redis and Celery for background work.

Django stack architecture diagram: Nginx, Django on Gunicorn, PostgreSQL, Redis, Celery workers

Django is a Python web framework that includes most of what an application needs: an ORM with migrations, an admin interface, authentication, forms, templates and security defaults. A production Django stack usually adds PostgreSQL as the database, Gunicorn or Uvicorn as the application server behind Nginx, Redis as a cache and message broker, and Celery for background tasks.

Django can render HTML pages itself or serve a JSON API with Django REST Framework or Django Ninja for a React or mobile front end.

What the stack is made of

Nginx
Terminates TLS, serves static and media files, and proxies other requests to Gunicorn.
Django on Gunicorn
The application: URLs, views, ORM models, admin and templates.
PostgreSQL
Django's best-supported database.
Redis
Cache, session store and Celery's message broker.
Celery workers
Run slow or scheduled jobs (emails, reports, imports) outside the request.

How a request flows through it

  1. Nginx receives a request and passes it to a Gunicorn worker running Django.
  2. Django routes it to a view, which uses the ORM to query PostgreSQL.
  3. For a slow job, such as generating an invoice PDF, the view queues a Celery task in Redis and returns at once.
  4. A Celery worker picks up the task, does the work and saves the result to PostgreSQL.

When to use it, and when not to

Good fit

  • Data-heavy web apps, admin back offices, content sites and SaaS products.
  • Teams that already use Python for data or machine learning.
  • You want an admin interface and authentication on day one.

Think twice

  • Thousands of long-lived connections (chat, live updates) without adding Django Channels or a separate service.
  • Tiny JSON-only services, where FastAPI or Flask are lighter.

Edit this diagram

Click Open the diagram in the editor to get your own copy, saved in your browser. Rename the boxes to match your system, swap any technology for the one you use from the icon palette, then export a PNG, SVG or PDF, or share a link. No sign-up.