# houssemkhoildi/docker-django architecture

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

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

## Overview

##### Project Type and Purpose
- This is a Dockerized Django web application (“pfe_routier”) managed via Docker Compose, backed by a PostgreSQL database, and integrated with Jenkins for CI/CD.

##### File-Structure Analysis
- Top-level files:
- Dockerfile – builds the Django application image
- docker-compose.yml – orchestrates services (web + db)
- Jenkinsfile + jenkins.sh – defines CI/CD pipeline
- manage.py, requirements.txt – standard Django entrypoints
- db.sqlite3 – local/dev fallback DB (likely unused in Compose)
- commandes.txt – project‐specific commands or scripts
- Django project directory (`pfe_routier/`):
- settings.py, urls.py, wsgi.py, asgi.py – Django configuration and entrypoints
- `postgresql/` directory:
- Full PG data directory (volumed into the container) and configuration files (pg_hba.conf, postgresql.conf, pg_ident.conf)

##### README Insights
- Title “docker-django” confirms the primary goal: run Django inside Docker.
- No additional sections, so architecture isn’t documented here.

a. Main Components
- Developer (Git) → Jenkins (CI/CD)
- Docker Registry (optional)
- Docker Compose Stack:
– Django Web Service (Gunicorn or runserver)
– PostgreSQL Database Service
- Host machine (ports & volumes)
b. Relationships & Data Flow
- Developer pushes code to Git → triggers Jenkins pipeline → builds Docker image → (optionally) pushes to Registry → deploys/updates Docker Compose on target host.
- Docker Compose creates an internal network:
– Django container connects to `db` container on port 5432
– Exposes Django port (e.g. 8000 or 80) to the host
– Mounts `postgresql/` directory as a persistent volume for PG data
c. Architectural Patterns & Principles
- Separation of concerns:
– CI/CD layer (Jenkins) vs. runtime layer (Docker Compose) vs. data layer (PostgreSQL)
- Infrastructure as code: Dockerfile + docker-compose.yml + Jenkinsfile
- Immutable container images for repeatability
d. Key Technologies
- Python/Django framework
- Gunicorn or Django dev server inside Docker
- PostgreSQL as a service container (configurable via pg_*.conf)
- Jenkins for automated build/test/deploy
- Docker Compose for service orchestration

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actors
    subgraph "External Actors"
        Dev["Developer"]:::external
        Browser["Web Browser"]:::external
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        Git["Git Repository"]:::external
        Jenkins["Jenkins"]:::ci
        ImageBuild["Docker Image Build"]:::ci
        Registry["Docker Registry (optional)"]:::ci
        Jenkinsfile["Jenkinsfile"]:::ci
        JenkinsHelper["jenkins.sh"]:::ci
    end

    %% Runtime Environment
    subgraph "Host Machine"
        Compose["Docker Compose"]:::runtime
        DockerYml["docker-compose.yml"]:::runtime

        subgraph "Django Application"
            Manage["manage.py"]:::runtime
            Requirements["requirements.txt"]:::runtime
            Commands["commandes.txt"]:::runtime
            ProjectDir["pfe_routier/"]:::runtime
            Settings["settings.py"]:::runtime
            URLs["urls.py"]:::runtime
            WSGI["wsgi.py"]:::runtime
            ASGI["asgi.py"]:::runtime
        end

        subgraph "PostgreSQL Service"
            DB["PostgreSQL DB"]:::db
            VolumeDir["postgresql/"]:::db
            ConfMain["postgresql.conf"]:::db
            ConfAuth["pg_hba.conf"]:::db
            ConfMap["pg_ident.conf"]:::db
        end

        FileDb["db.sqlite3"]:::runtime
        Readme["README.md"]:::external
    end

    %% Connections
    Dev -->|push code| Git
    Git -->|trigger| Jenkins
    Jenkins -->|uses| Jenkinsfile
    Jenkins -->|runs| JenkinsHelper
    Jenkins -->|builds| ImageBuild
    ImageBuild -->|uses| Dockerfile
    ImageBuild -->|pushes| Registry
    Jenkins -->|deploys| Compose
    Compose -->|reads| DockerYml
    Compose -->|mounts| VolumeDir
    VolumeDir --> ConfMain
    VolumeDir --> ConfAuth
    VolumeDir --> ConfMap
    Compose -->|starts| DB
    Compose -->|starts| ProjectDir
    ProjectDir --> Settings
    ProjectDir --> URLs
    ProjectDir --> WSGI
    ProjectDir --> ASGI
    Compose -->|runs| Manage
    Compose -->|installs| Requirements
    Compose -->|runs commands| Commands
    Browser -->|HTTP/HTTPS| ProjectDir
    ProjectDir -->|ORM queries| DB
    Compose -->|fallback| FileDb
    Dev -.->|reads| Readme

    %% Click Events
    click Dockerfile "https://github.com/houssemkhoildi/docker-django/tree/master/Dockerfile"
    click DockerYml "https://github.com/houssemkhoildi/docker-django/blob/master/docker-compose.yml"
    click Jenkinsfile "https://github.com/houssemkhoildi/docker-django/tree/master/Jenkinsfile"
    click JenkinsHelper "https://github.com/houssemkhoildi/docker-django/blob/master/jenkins.sh"
    click Manage "https://github.com/houssemkhoildi/docker-django/blob/master/manage.py"
    click Requirements "https://github.com/houssemkhoildi/docker-django/blob/master/requirements.txt"
    click FileDb "https://github.com/houssemkhoildi/docker-django/blob/master/db.sqlite3"
    click Commands "https://github.com/houssemkhoildi/docker-django/blob/master/commandes.txt"
    click ProjectDir "https://github.com/houssemkhoildi/docker-django/tree/master/pfe_routier/"
    click Settings "https://github.com/houssemkhoildi/docker-django/blob/master/pfe_routier/settings.py"
    click URLs "https://github.com/houssemkhoildi/docker-django/blob/master/pfe_routier/urls.py"
    click WSGI "https://github.com/houssemkhoildi/docker-django/blob/master/pfe_routier/wsgi.py"
    click ASGI "https://github.com/houssemkhoildi/docker-django/blob/master/pfe_routier/asgi.py"
    click VolumeDir "https://github.com/houssemkhoildi/docker-django/tree/master/postgresql/"
    click ConfMain "https://github.com/houssemkhoildi/docker-django/blob/master/postgresql/postgresql.conf"
    click ConfAuth "https://github.com/houssemkhoildi/docker-django/blob/master/postgresql/pg_hba.conf"
    click ConfMap "https://github.com/houssemkhoildi/docker-django/blob/master/postgresql/pg_ident.conf"
    click Readme "https://github.com/houssemkhoildi/docker-django/blob/master/README.md"

    %% Styles
    classDef external fill:#DDDDDD,stroke:#333,stroke-width:1px
    classDef ci fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef runtime fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFD700,stroke:#333,stroke-width:1px
```
