# dua-amir/caseease architecture

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

- Interactive diagram: https://gitdiagram.com/dua-amir/caseease
- Repository: https://github.com/dua-amir/caseease

## Overview

##### Main Components
- Web Client (Browser)
- Django Application Server
- ASGI/WGSI entrypoints (asgi.py, wsgi.py)
- URL router (urls.py)
- Two Django apps:
– accounts
– cases
- Core settings & configuration (settings.py)
- Database (SQLite – db.sqlite3)
- Media Storage (local file system under /media)
- Static Assets (local file system under /static)
- Optional reverse proxy or load balancer (e.g., Nginx/Gunicorn)

##### Relationships & Data Flows
- Browser → HTTP(S) requests → Django ASGI/WGSI endpoint
- ASGI/WGSI → URL dispatcher → Appropriate view (accounts.views or cases.views)
- Views ↔ Models (accounts.models.User, cases.models.Case, CaseHistory, etc.)
- ORM queries → SQLite database
- Views → render HTML templates (templates/base.html, accounts/templates, cases/templates)
- File uploads/downloads → Media folder (stored via Django’s default FileSystemStorage)
- Static file serving → Static folder (served by Django in dev or by a web server in production)

##### Architectural Patterns & Principles
- MVC (Model–View–Template) pattern:
- Models in models.py
- Views in views.py (request handling & business logic)
- Templates for presentation
- Separation of concerns between “accounts” and “cases” apps
- Role-based access: middleware and decorators in accounts/middleware.py and views→ templates for Admin/Handler/User
- Auto-generated migrations drive DB schema evolution

##### Technologies & Frameworks
- Python 3.x, Django framework
- Built-in authentication system (customized User model in accounts/models.py)
- SQLite (db.sqlite3) for persistence
- Django’s built-in static and media file handling
- HTML/CSS templates—no SPA or separate frontend framework

##### Detailed Capture of Architectural Elements
- Major URL entrypoints from CaseEase/CaseEase/urls.py and apps’ urls.py
- Middleware layer (accounts/middleware.py) intercepting requests for role enforcement
- File upload flow: register_case view → FileField → /media/case_files
- Migrations folder to represent schema versioning

- Clearly separates frontend, backend, persistence, and infrastructure
- Shows how HTTP requests flow through Django’s ASGI/WGSI entrypoint, URL router, views, models, and templates
- Highlights the two main Django apps (“accounts” and “cases”) and their interaction with the database and storage
- Reflects all essential components as gleaned from the file tree and README of CaseEase

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Web Browser"]:::frontend
        Templates["Templates (base.html, home.html)"]:::frontend
        Static["Static Assets (CSS/JS/Images)"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        subgraph "ASGI & WSGI Entrypoints"
            ASGI["ASGI Entrypoint"]:::backend
            WSGI["WSGI Entrypoint"]:::backend
        end
        Settings["Core Settings & Config"]:::backend
        Dispatcher["URL Dispatcher"]:::backend
        Middleware["Role Enforcement Middleware"]:::backend

        subgraph "Accounts App"
            AcApp["apps.py"]:::backend
            AcURLs["urls.py"]:::backend
            AcViews["views.py"]:::backend
            AcModels["models.py"]:::backend
            AcForms["forms.py"]:::backend
            AcAdmin["admin.py"]:::backend
            AcTemplates["accounts/templates"]:::frontend
        end

        subgraph "Cases App"
            CApp["apps.py"]:::backend
            CURLs["urls.py"]:::backend
            CViews["views.py"]:::backend
            CModels["models.py"]:::backend
            CForms["forms.py"]:::backend
            CAdmin["admin.py"]:::backend
            CTemplates["cases/templates"]:::frontend
        end

        Manage["manage.py (CLI)"]:::backend
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB["SQLite Database"]:::persistence
        MediaRoot["Media Storage"]:::persistence
        CaseFiles["media/case_files/"]:::persistence
        ProfileImages["media/profile_images/"]:::persistence
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        Gunicorn["Gunicorn/uWSGI"]:::infra
        Nginx["Nginx Reverse Proxy"]:::infra
    end

    %% Connections
    Browser -->|"HTTP(S) Request"| Nginx
    Nginx -->|Proxy to| Gunicorn
    Gunicorn -->|"WSGI/ASGI"| ASGI
    Browser -->|"HTTP(S) Request"| ASGI
    ASGI -->|"Loads"| Settings
    ASGI -->|"Dispatch"| Dispatcher
    WSGI -->|"Dispatch"| Dispatcher
    Dispatcher -->|"Pass through"| Middleware
    Middleware -->|"Route to"| AcViews
    Middleware -->|"Route to"| CViews
    Dispatcher -->|"accounts URLs"| AcURLs
    Dispatcher -->|"cases URLs"| CURLs
    AcViews -->|"Uses"| AcModels
    CViews -->|"Uses"| CModels
    AcModels -->|"ORM Query"| DB
    CModels -->|"ORM Query"| DB
    AcViews -->|"Render"| AcTemplates
    CViews -->|"Render"| CTemplates
    AcViews -->|"Upload/Download"| MediaRoot
    CViews -->|"Upload/Download"| MediaRoot
    MediaRoot -->|"Store in"| CaseFiles
    MediaRoot -->|"Store in"| ProfileImages
    Browser -->|"Fetch"| Static
    Static -->|"Served from"| Static

    Manage --- Dispatcher

    %% Click Events
    click ASGI "https://github.com/dua-amir/caseease/blob/main/CaseEase/CaseEase/asgi.py"
    click WSGI "https://github.com/dua-amir/caseease/blob/main/CaseEase/CaseEase/wsgi.py"
    click Dispatcher "https://github.com/dua-amir/caseease/blob/main/CaseEase/CaseEase/urls.py"
    click Settings "https://github.com/dua-amir/caseease/blob/main/CaseEase/CaseEase/settings.py"
    click AcApp "https://github.com/dua-amir/caseease/blob/main/CaseEase/accounts/apps.py"
    click AcURLs "https://github.com/dua-amir/caseease/blob/main/CaseEase/accounts/urls.py"
    click AcViews "https://github.com/dua-amir/caseease/blob/main/CaseEase/accounts/views.py"
    click AcModels "https://github.com/dua-amir/caseease/blob/main/CaseEase/accounts/models.py"
    click AcForms "https://github.com/dua-amir/caseease/blob/main/CaseEase/accounts/forms.py"
    click AcAdmin "https://github.com/dua-amir/caseease/blob/main/CaseEase/accounts/admin.py"
    click AcTemplates "https://github.com/dua-amir/caseease/tree/main/CaseEase/accounts/templates/accounts/"
    click Middleware "https://github.com/dua-amir/caseease/blob/main/CaseEase/accounts/middleware.py"
    click CApp "https://github.com/dua-amir/caseease/blob/main/CaseEase/cases/apps.py"
    click CURLs "https://github.com/dua-amir/caseease/blob/main/CaseEase/cases/urls.py"
    click CViews "https://github.com/dua-amir/caseease/blob/main/CaseEase/cases/views.py"
    click CModels "https://github.com/dua-amir/caseease/blob/main/CaseEase/cases/models.py"
    click CForms "https://github.com/dua-amir/caseease/blob/main/CaseEase/cases/forms.py"
    click CAdmin "https://github.com/dua-amir/caseease/blob/main/CaseEase/cases/admin.py"
    click CTemplates "https://github.com/dua-amir/caseease/tree/main/CaseEase/cases/templates/cases/"
    click DB "https://github.com/dua-amir/caseease/blob/main/CaseEase/db.sqlite3"
    click MediaRoot "https://github.com/dua-amir/caseease/tree/main/CaseEase/media/"
    click CaseFiles "https://github.com/dua-amir/caseease/tree/main/CaseEase/media/case_files/"
    click ProfileImages "https://github.com/dua-amir/caseease/tree/main/CaseEase/media/profile_images/"
    click Static "https://github.com/dua-amir/caseease/tree/main/CaseEase/static/"
    click Templates "https://github.com/dua-amir/caseease/blob/main/CaseEase/templates/base.html"
    click Manage "https://github.com/dua-amir/caseease/blob/main/CaseEase/manage.py"

    %% Styles
    classDef frontend fill:#d4f1be,stroke:#2f6627,stroke-width:1px
    classDef backend fill:#c0e4ff,stroke:#1a6fb3,stroke-width:1px
    classDef persistence fill:#fff3b0,stroke:#b38f00,stroke-width:1px
    classDef infra fill:#e0e0e0,stroke:#6b6b6b,stroke-width:1px
```
