# mcop81/optimise-transport-marchandise-ml architecture

> Architecture diagram of the GitHub repository mcop81/optimise-transport-marchandise-ml, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mcop81/optimise-transport-marchandise-ml
- Repository: https://github.com/mcop81/optimise-transport-marchandise-ml

## Overview

##### Project type and purpose
- This is a full-stack web application built with Django (Python) that provides a UI for managing deliveries, trucks, chauffeurs and predicting delivery delays using a pre-trained Random Forest model.
- Key purpose: user registration/authentication, CRUD operations on deliveries/trucks/chauffeurs, map visualizations, and ML-based delay predictions.

##### File structure
- Top level:
- core/ – Django project configuration (settings.py, urls.py, wsgi.py, asgi.py)
- apps/ – Django “apps”:
– authentication/ (login, registration forms, views, URLs, models)
– home/ (delivery/truck management, map pages, ML integration)
– static/ (CSS/JS/images; Argon Dashboard theme)
– templates/ (layouts, includes, per-app HTML templates)
- media/ – user-uploaded files (if any)
- staticfiles/ – collected static assets
- Dockerfile, docker-compose.yml, nginx/ – containerization and reverse-proxy
- Procfile, runtime.txt, requirements.txt – deployment (Heroku) and dependencies
- core/models/*.pkl – serialized Random Forest ML models

##### README for additional insights
- Confirms SQLite usage in development, Django migrations, “home” app serves authenticated pages, “authentication” app handles user login/register.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Clients
    Browser["Client (Browser/Mobile)"]:::client

    %% Containers and Services
    subgraph "Container: NGINX"
        NGINX["NGINX Reverse Proxy"]:::proxy
    end
    subgraph "Container: Gunicorn"
        GUNICORN["Gunicorn WSGI Server"]:::server
    end
    subgraph "Container: Django App"
        subgraph "Core Configuration"
            SETTINGS["settings.py"]:::config
            URLS["urls.py"]:::config
            ASGI["asgi.py"]:::config
            WSGI["wsgi.py"]:::config
        end
        subgraph "Authentication App"
            AUTH_MODELS["models.py"]:::app
            AUTH_FORMS["forms.py"]:::app
            AUTH_VIEWS["views.py"]:::app
            AUTH_URLS["urls.py"]:::app
            AUTH_ADMIN["admin.py"]:::app
            AUTH_MIGRATIONS["migrations/"]:::app
        end
        subgraph "Home App"
            HOME_MODELS["models.py"]:::app
            HOME_FORMS["forms.py"]:::app
            HOME_VIEWS["views.py"]:::app
            HOME_URLS["urls.py"]:::app
            HOME_ADMIN["admin.py"]:::app
            HOME_CONFIG["config.py"]:::app
            HOME_MIGRATIONS["migrations/"]:::app
        end
        subgraph "Templates"
            TEMPLATES["templates/"]:::template
        end
        subgraph "Static Assets (Source)"
            STATIC_SRC["assets/"]:::static
        end
        subgraph "Collected Static Files"
            STATIC_COLLECTED["staticfiles/"]:::static
        end
        subgraph "ML Models"
            ML1["random_forest_model.pkl"]:::ml
            ML2["Random Forest_model_retard.pkl"]:::ml
        end
    end

    %% Database
    DB["SQLite/Postgres Database"]:::db

    %% External Services
    GeoAPI["Geolocation API"]:::external
    EmailAPI["Email/SMS Service"]:::external

    %% Interactions
    Browser -->|"HTTP(S) Request"| NGINX
    NGINX -->|"Serve Static"| STATIC_COLLECTED
    NGINX -->|"Proxy Dynamic"| GUNICORN
    GUNICORN -->|"WSGI Call"| SETTINGS
    SETTINGS --> URLS
    GUNICORN -->|"Invoke Views"| AUTH_VIEWS
    GUNICORN -->|"Invoke Views"| HOME_VIEWS
    AUTH_VIEWS --> AUTH_MODELS
    HOME_VIEWS --> HOME_MODELS
    AUTH_VIEWS --> TEMPLATES
    HOME_VIEWS --> TEMPLATES
    AUTH_VIEWS --> DB
    HOME_VIEWS --> DB
    HOME_VIEWS -->|"Load Model"| ML1
    HOME_VIEWS -->|"Load Model"| ML2
    HOME_VIEWS --> GeoAPI
    AUTH_VIEWS --> EmailAPI
    STATIC_SRC -->|"Build Pipeline"| STATIC_COLLECTED

    %% Click Events
    click SETTINGS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/core/settings.py"
    click URLS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/core/urls.py"
    click ASGI "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/core/asgi.py"
    click WSGI "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/core/wsgi.py"
    click AUTH_MODELS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/authentication/models.py"
    click AUTH_FORMS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/authentication/forms.py"
    click AUTH_VIEWS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/authentication/views.py"
    click AUTH_URLS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/authentication/urls.py"
    click AUTH_ADMIN "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/authentication/admin.py"
    click AUTH_MIGRATIONS "https://github.com/mcop81/optimise-transport-marchandise-ml/tree/master/apps/authentication/migrations/"
    click HOME_MODELS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/home/models.py"
    click HOME_FORMS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/home/forms.py"
    click HOME_VIEWS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/home/views.py"
    click HOME_URLS "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/home/urls.py"
    click HOME_ADMIN "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/home/admin.py"
    click HOME_CONFIG "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/apps/home/config.py"
    click HOME_MIGRATIONS "https://github.com/mcop81/optimise-transport-marchandise-ml/tree/master/apps/home/migrations/"
    click TEMPLATES "https://github.com/mcop81/optimise-transport-marchandise-ml/tree/master/apps/templates/"
    click STATIC_SRC "https://github.com/mcop81/optimise-transport-marchandise-ml/tree/master/apps/static/assets/"
    click STATIC_COLLECTED "https://github.com/mcop81/optimise-transport-marchandise-ml/tree/master/core/staticfiles/"
    click ML1 "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/core/models/random_forest_model.pkl"
    click ML2 "https://github.com/mcop81/optimise-transport-marchandise-ml/blob/master/core/models/Random Forest_model_retard.pkl"

    %% Styles
    classDef client fill:#C3E6FF,stroke:#006BA6,color:#000
    classDef proxy fill:#FFE5B4,stroke:#FF8C00,color:#000
    classDef server fill:#E0FFE0,stroke:#008000,color:#000
    classDef config fill:#FFD1DC,stroke:#FF1493,color:#000
    classDef app fill:#E8E8FF,stroke:#0000CD,color:#000
    classDef template fill:#FFFACD,stroke:#DAA520,color:#000
    classDef static fill:#F0F8FF,stroke:#4682B4,color:#000
    classDef ml fill:#FFEFD5,stroke:#FF7F50,color:#000
    classDef db fill:#D3D3D3,stroke:#696969,color:#000
    classDef external fill:#F5F5F5,stroke:#A9A9A9,color:#000
```
