# souhailbourhim/crm_app architecture

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

- Interactive diagram: https://gitdiagram.com/souhailbourhim/crm_app
- Repository: https://github.com/souhailbourhim/crm_app

## Overview

##### Project type and purpose
- This is a full-stack web application: a Django-based CRM (Customer Relationship Management) system called DCRM/CRM_APP.
- Its purpose is to manage customers and leads through secure authenticated CRUD operations, with a responsive Bootstrap UI and SQLite via Django ORM.

##### File structure
- Top-level:
- manage.py – Django CLI entry point
- DCRM/ – Django project settings (asgi.py, wsgi.py, settings.py, urls.py)
- CRM_app/ – Core Django app containing models, views, forms, admin, templates, migrations, tests
- mydb.py – custom database-related script (optional utility)
- CRM_app/templates/ – HTML templates broken out by page (home, add_record, update_record, etc.)
- Config files (settings.py) define database, middleware, installed apps, URL routing.
- Migrations folder manages DB schema changes.

##### README for additional insights
- Tech stack: Django (backend), Bootstrap/HTML/CSS/JS (frontend), SQLite (database).
- Authentication and role-based authorization use Django’s security framework.
- Mentions modular architecture and ORM usage.

##### Main components
a. External client layer
- Web Browser (User)
- HTTP(S)
b. Web server / application layer
- Django development server (or production WSGI/ASGI host)
- URL Router (DCRM/urls.py)
- Middleware (authentication, security)
c. Application logic layer (CRM_app)
- Views (CRM_app/views.py)
- Forms (CRM_app/forms.py)
- Models (CRM_app/models.py)
- Admin site (CRM_app/admin.py)
- Templates (CRM_app/templates/*.html)
d. Data layer
- SQLite database (db.sqlite3)
- Migration scripts (CRM_app/migrations/)
- Optional custom scripts (mydb.py)
e. Static assets (if present)
- CSS/JS (Bootstrap)
f. Testing & CI
- Tests (CRM_app/tests.py)

##### Relationships and interactions
- Browser → (HTTP request) → Django Server
- Django Server → URL Router → appropriate View
- View ↔ Form (input validation)
- View ↔ Model (ORM queries) → SQLite
- View → Template rendering → HTML response → Browser
- Admin module uses same Model layer to CRUD
- Migrations run offline to update schema

##### Architectural patterns & design principles
- MVC (Django is MTV: Model-Template-View)
- Layered architecture with clear separation: presentation (templates), business logic (views/forms), data access (models)
- Modular app structure (single “CRM_app” app—could split further by feature, e.g., leads/agents in the future)
- Use of built-in authentication middleware for security

##### Technologies and frameworks to annotate
- Django (with DCRM as project root)
- Django ORM → SQLite
- Bootstrap / HTML / CSS / JS for UI
- ASGI/WSGI interface
- Python 3 virtual environment

##### Essential details without overcomplicating
- Don’t try to show every single template or view file; group by function (e.g., “CRM_app Views”).
- Data flow: client requests → view logic → database → templating → client response.
- Authentication middleware and admin sub-system as distinct modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    Browser["Web Browser (User)"]:::client

    %% Web Server / Application Layer
    subgraph "Web Server / Application"
        manage["manage.py"]:::app
        asgi["DCRM/asgi.py"]:::app
        wsgi["DCRM/wsgi.py"]:::app
        settings["DCRM/settings.py"]:::app
        pr_router["DCRM/urls.py\n(URL Router)"]:::app
        mw["Middleware\n(authentication, security)"]:::app
        app_router["CRM_app/urls.py\n(App Router)"]:::app
        views["CRM_app/views.py\n(Views)"]:::app
        forms["CRM_app/forms.py\n(Forms)"]:::app
        models["CRM_app/models.py\n(Models/ORM)"]:::app
        admin["CRM_app/admin.py\n(Admin Site)"]:::app

        subgraph "Templates\n(Presentation Layer)"
            base["base.html"]:::app
            home["home.html"]:::app
            add["add_record.html"]:::app
            update["update_record.html"]:::app
            record["record.html"]:::app
            search["search_results.html"]:::app
            register["register.html"]:::app
            navbar["navbar.html"]:::app
        end

        tests["CRM_app/tests.py\n(Test Suite)"]:::app
    end

    %% Static Assets
    static["Bootstrap CSS/JS\n(Static Assets)"]:::static

    %% Data Layer
    subgraph "Data Layer"
        db["SQLite Database\n(db.sqlite3)"]:::data
        migrations["Migrations\n(CRM_app/migrations/)"]:::data
        utility["mydb.py\n(Custom DB Utility)"]:::data
    end

    %% Request Flow
    Browser -->|"HTTP(S) request"| asgi
    Browser -->|"HTTP(S) request"| wsgi
    asgi --> settings
    wsgi --> settings
    settings --> pr_router
    pr_router --> mw
    mw --> app_router
    app_router --> views
    views --> forms
    views --> models
    models -->|ORM queries| db
    views -->|renders| base
    views -->|renders| home
    views -->|renders| add
    views -->|renders| update
    views -->|renders| record
    views -->|renders| search
    views -->|renders| register
    views -->|renders| navbar
    base --> Browser
    home --> Browser
    add --> Browser
    update --> Browser
    record --> Browser
    search --> Browser
    register --> Browser
    navbar --> Browser

    %% Admin Flow
    Browser -->|"Admin UI"| pr_router
    pr_router --> admin
    admin --> models

    %% Migrations
    migrations -->|schema update| db

    %% Utility Script
    utility --> db

    %% Static Assets Delivery
    static --> Browser

    %% Testing
    tests --> views
    tests --> models

    %% Click Events
    click manage "https://github.com/souhailbourhim/crm_app/blob/main/manage.py"
    click asgi "https://github.com/souhailbourhim/crm_app/blob/main/DCRM/asgi.py"
    click wsgi "https://github.com/souhailbourhim/crm_app/blob/main/DCRM/wsgi.py"
    click pr_router "https://github.com/souhailbourhim/crm_app/blob/main/DCRM/urls.py"
    click app_router "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/urls.py"
    click settings "https://github.com/souhailbourhim/crm_app/blob/main/DCRM/settings.py"
    click views "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/views.py"
    click forms "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/forms.py"
    click models "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/models.py"
    click admin "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/admin.py"
    click base "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/templates/base.html"
    click home "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/templates/home.html"
    click add "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/templates/add_record.html"
    click update "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/templates/update_record.html"
    click record "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/templates/record.html"
    click search "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/templates/search_results.html"
    click register "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/templates/register.html"
    click navbar "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/templates/navbar.html"
    click migrations "https://github.com/souhailbourhim/crm_app/blob/main/CRM_app/migrations/0001_initial.py"
    click utility "https://github.com/souhailbourhim/crm_app/blob/main/mydb.py"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366d6,stroke-width:1px
    classDef app fill:#E2F0D9,stroke:#28a745,stroke-width:1px
    classDef data fill:#FDEBD0,stroke:#d97706,stroke-width:1px
    classDef static fill:#E0E0E0,stroke:#6c757d,stroke-width:1px
```
