# ixc/ixc-django-docker architecture

> Architecture diagram of the GitHub repository ixc/ixc-django-docker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ixc/ixc-django-docker
- Repository: https://github.com/ixc/ixc-django-docker

## Overview

##### Main Components
- Wrapped Django Project Template: Represent the “wrapped” Django application (as seen under project_template/djangosite) that gets imbued with additional functionality from the wrapper.
- Supporting Services: External systems that the project requires:
- Database (PostgreSQL)
- Cache and message brokers (Redis)
- Asynchronous task workers (Celery; see the “celery” subpackage and various celery-related scripts)
- Web Server (Nginx, with gunicorn used to serve the app in production)
- Optional external services like Elasticsearch, Supervisor, and possibly Transcrypt used for encrypted secrets.

##### Relationships and Interactions
- Incoming requests flow from external clients to the web server (Nginx) which proxies traffic to Gunicorn, starting the Django application (ixc_django_docker).
- The main Django wrapper component interacts with the wrapped project’s settings, templates, and URLs. This layering encapsulates the main project-specific logic with shared best practices.
- Configuration scripts and shell commands (found in the “bin” directory) sit at the orchestration layer. They initiate processes such as migrations, static file compilation, running the server, etc.
- When running with Docker, the Docker Compose file becomes the orchestrator of the various containerized services (web, DB, cache, etc.). Highlight directional flows in that layered architecture.
- For local runs, the “go.sh” script sets up the environment so that the same underlying services are reachable even if managed individually (use of Brew services on macOS, for example).

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate the concerns of configuration/environment orchestration (i.e., Docker vs. local execution) from the Django application’s business logic.
- Composable Settings: The use of modular settings (in ixc_django_docker/settings) shows a pattern where different environment configurations (production, staging, test, etc.) are composed based on environment variables. This is key to the project’s flexibility and must be clearly annotated.
- “Wrapper” Pattern: The Django project wrapper enables “wrapping” a standard Django project to add cross-cutting functionalities (logging, secrets handling, monitoring, etc.). This abstraction layer should be highlighted.

##### Specific Technologies, Frameworks, and Tools
- Django and its settings infrastructure for web application logic.
- Celery for asynchronous task processing.
- Gunicorn as the WSGI server.
- Nginx as the reverse proxy and static file server.
- Redis as a caching mechanism and for task queue communication.
- Postgres as the underlying relational database.
- Docker and Docker Compose for container management.
- Transcrypt for handling encrypted secrets.
- Various shell scripts that standardize operations (e.g., migration, testing, building static assets).
- Optional tools such as ddtrace, haystack (with Elasticsearch), and supervisor for process management.

##### Final Assembly
- At the core, illustrate your Django application split into its two main parts: the “wrapper” (handling cross-cutting concerns and shared settings) and the “wrapped project” that holds the business-specific logic.
- Finally, attach all service dependencies to this core which the Django application interacts with.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["Client (Browser/API)"]:::client

    %% Runtime Environment
    subgraph "Runtime Environment"
        subgraph "Docker Environment"
            Dockerfile["Dockerfile & Dockerfile.base"]:::env
            DockerCompose["Docker Compose (docker-compose.yml)"]:::env
        end
        subgraph "Local Environment"
            GoScript["Local Setup (go.sh)"]:::env
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        Nginx["Nginx (Reverse Proxy)"]:::app
        Gunicorn["Gunicorn (WSGI Server)"]:::app
        DjangoWrapper["Django Project Wrapper"]:::app
        TenantApp["Wrapped Django Application"]:::app
        ComposableSettings["Composable Settings"]:::app
        CeleryIntegration["Celery Integration"]:::app
        OrchestrationScripts["Orchestration Scripts"]:::app
    end

    %% External Services
    subgraph "External Services"
        PostgreSQL["PostgreSQL"]:::ext
        Redis["Redis"]:::ext
        CeleryWorker["Celery Worker"]:::ext
    end

    %% Connections: Client to Application Entry Points
    Client -->|"HTTP_Request"| Nginx
    Nginx -->|"Proxy_Request"| Gunicorn
    Gunicorn -->|"WSGI_Call"| DjangoWrapper
    DjangoWrapper -->|"Wraps"| TenantApp

    %% Internal Application Components
    DjangoWrapper -->|"Loads"| ComposableSettings
    DjangoWrapper -->|"Calls_Tasks"| CeleryIntegration
    DjangoWrapper -->|"Runs"| OrchestrationScripts
    CeleryIntegration -->|"Executes_Task"| CeleryWorker

    %% External Service Interactions
    DjangoWrapper -->|"DB_Query"| PostgreSQL
    DjangoWrapper -->|"Cache_Update"| Redis
    DjangoWrapper -->|"Dispatches_Task"| CeleryWorker

    %% Orchestration Connections
    Dockerfile -->|"Builds_Image"| DjangoWrapper
    DockerCompose -->|"Container_Orchestration"| DjangoWrapper
    GoScript -->|"Startup_Script"| DjangoWrapper

    %% Click Events
    click DjangoWrapper "https://github.com/ixc/ixc-django-docker/tree/master/ixc_django_docker"
    click TenantApp "https://github.com/ixc/ixc-django-docker/tree/master/project_template/djangosite"
    click Dockerfile "https://github.com/ixc/ixc-django-docker/tree/master/project_template/Dockerfile"
    click DockerCompose "https://github.com/ixc/ixc-django-docker/blob/master/project_template/docker-compose.yml"
    click GoScript "https://github.com/ixc/ixc-django-docker/blob/master/project_template/go.sh"
    click ComposableSettings "https://github.com/ixc/ixc-django-docker/tree/master/ixc_django_docker/settings"
    click CeleryIntegration "https://github.com/ixc/ixc-django-docker/tree/master/ixc_django_docker/celery"
    click OrchestrationScripts "https://github.com/ixc/ixc-django-docker/tree/master/ixc_django_docker/bin"
    click Nginx "https://github.com/ixc/ixc-django-docker/blob/master/ixc_django_docker/bin/nginx.sh"
    click Gunicorn "https://github.com/ixc/ixc-django-docker/blob/master/ixc_django_docker/bin/gunicorn.sh"

    %% Styles
    classDef client fill:#f9e79f,stroke:#c0392b,stroke-width:2px;
    classDef env fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef app fill:#abebc6,stroke:#27ae60,stroke-width:2px;
    classDef ext fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
```
