# adilmohak/django-lms architecture

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

- Interactive diagram: https://gitdiagram.com/adilmohak/django-lms
- Repository: https://github.com/adilmohak/django-lms

## Overview

##### Project type and purpose
- This is a full-stack, monolithic Django-based Learning Management System (LMS).
- It combines server-side rendered pages (Django templates + SCSS/JS) with a RESTful API layer (Django REST Framework).
- Key use cases: user/account management (students, lecturers, parents, admins), course catalog & enrollment, quizzes, results, payments, search, PDF/CSV exports.

##### Main system components
A. Presentation Layer
- Web server (Nginx/Apache)
- Django application server (Gunicorn/Uvicorn via ASGI or WSGI)
- Static assets (CSS, JS, fonts, images) served from /static
- Media file storage for uploads (/media)
- Django templates under /templates
B. Application Layer
- Django “config” module: settings, URL routing, WSGI/ASGI entrypoints
- Django apps (each one a self-contained module):
- accounts (user registration, authentication, profiles)
- core (dashboard, sessions, semesters, news/events)
- course (programs, course creation & allocation)
- quiz (question bank, sittings, templating)
- result (grading, assessment reports, PDF generation)
- payments (Stripe, PayPal, Coinbase, Paylike integrations)
- search (simple DB-backed search utilities)
- REST API submodules (accounts/api, core/api, …) powered by Django REST Framework
C. Data Layer
- Relational database (PostgreSQL/MySQL/SQLite)
- Django ORM models in each app, migrations under /migrations
D. External Services
- Payment gateways: Stripe, PayPal, Coinbase, Paylike
- Email service (SMTP or transactional provider for confirmations)
- (Optional) Caching layer (Redis or Memcached) for session & query caching
- (Optional) Task queue (Celery/RabbitMQ) if background tasks are needed

##### Component interactions and data flow
- User → HTTP(S) → Load Balancer → Nginx → Gunicorn → Django URL router
- Router dispatches to:
a. Template-based views (accounts/views.py, course/views.py, etc.)
b. API views (accounts/api/views.py, …)
- Business logic triggers ORM calls → Database
- Payments views call external payment gateway APIs → responses returned to front end
- Media uploads go to /media or S3/Cloud storage
- Search queries hit search/models.py or external search engine if added
- Localization loaded via Django’s i18n (locale folders)

##### Architectural patterns and design principles
- Modular monolith: each feature in its own Django app
- MVC/MVT: Models (models.py) ↔ Views (views.py, APIViews) ↔ Templates/Serializers
- RESTful API layer coexisting with server-side rendering
- Separation of concerns: business logic in utils, decorators, filters; validation in forms, serializers, validators
- Configurable environments via .env, config/settings.py and environment–specific requirement files

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Web Cluster" 
        direction TB
        LB["Load Balancer"]:::presentation
        NG["Nginx/Apache"]:::presentation
        GW["Gunicorn/Uvicorn"]:::presentation
    end

    subgraph "Presentation Layer"
        direction TB
        Static["Static Assets"]:::storage
        Media["Media Storage"]:::storage
        Templates["Django Templates"]:::presentation
    end

    LB -->|HTTPS| NG
    NG -->|WSGI/ASGI| GW
    GW -->|serves| Static
    GW -->|serves| Media
    GW -->|renders| Templates

    %% Application Layer
    subgraph "Django Monolith"
        direction TB
        Config["config module"]:::application

        subgraph "Accounts App"
            direction TB
            AccMod["accounts/models.py"]:::application
            AccViews["accounts/views.py"]:::application
            AccForms["accounts/forms.py"]:::application
            AccURLs["accounts/urls.py"]:::application
            AccAPI["accounts/api"]:::application
        end

        subgraph "Core App"
            direction TB
            CoreMod["core/models.py"]:::application
            CoreViews["core/views.py"]:::application
            CoreForms["core/forms.py"]:::application
            CoreURLs["core/urls.py"]:::application
            CoreAPI["core/api"]:::application
        end

        subgraph "Course App"
            direction TB
            CourseMod["course/models.py"]:::application
            CourseViews["course/views.py"]:::application
            CourseForms["course/forms.py"]:::application
            CourseURLs["course/urls.py"]:::application
            CourseAPI["course/api"]:::application
        end

        subgraph "Quiz App"
            direction TB
            QuizMod["quiz/models.py"]:::application
            QuizViews["quiz/views.py"]:::application
            QuizForms["quiz/forms.py"]:::application
            QuizURLs["quiz/urls.py"]:::application
            QuizAPI["quiz/api"]:::application
        end

        subgraph "Result App"
            direction TB
            ResultMod["result/models.py"]:::application
            ResultViews["result/views.py"]:::application
            ResultURLs["result/urls.py"]:::application
            ResultAPI["result/api"]:::application
        end

        subgraph "Payments App"
            direction TB
            PayMod["payments/models.py"]:::application
            PayViews["payments/views.py"]:::application
            PayStripe["payments/views_stripe.py"]:::application
            PayURLs["payments/urls.py"]:::application
        end

        subgraph "Search App"
            direction TB
            SearchMod["search/models.py"]:::application
            SearchViews["search/views.py"]:::application
            SearchURLs["search/urls.py"]:::application
        end
    end

    GW -->|HTTP| Config
    Config --> AccountsApp(("accounts/")):::application
    Config --> CoreApp(("core/")):::application
    Config --> CourseApp(("course/")):::application
    Config --> QuizApp(("quiz/")):::application
    Config --> ResultApp(("result/")):::application
    Config --> PaymentsApp(("payments/")):::application
    Config --> SearchApp(("search/")):::application

    %% Infrastructure Layer
    subgraph "Infrastructure"
        direction TB
        DB["Relational DB (PostgreSQL)"]:::data
        Cache["Cache (Redis)"]:::infra
        Broker["Message Broker (RabbitMQ)"]:::infra
        Storage["Object Storage"]:::storage
    end

    GW -->|SQL/ORM| DB
    GW -->|cache| Cache
    GW -->|tasks| Broker
    Media -->|uploads| Storage
    Static -->|deploy| Storage

    %% External Services
    subgraph "External Services"
        direction TB
        Stripe["Stripe"]:::external
        PayPal["PayPal"]:::external
        Coinbase["Coinbase"]:::external
        Paylike["Paylike"]:::external
        Email["Email Service"]:::external
    end

    PayViews -->|API calls| Stripe
    PayViews -->|API calls| PayPal
    PayViews -->|API calls| Coinbase
    PayViews -->|API calls| Paylike
    Config -->|SMTP| Email

    %% User Flow
    User["User"]:::external
    User -->|HTTPS| LB
    User -->|select gateway| PayViews
    Stripe -->|callback| PayViews

    %% Legend
    classDef presentation fill:#cce5ff,stroke:#004085;
    classDef application fill:#d4edda,stroke:#155724;
    classDef data fill:#ffe5b4,stroke:#b35900;
    classDef storage fill:#e2d6f6,stroke:#5a3e85;
    classDef external fill:#e2e3e5,stroke:#6c757d;
    classDef infra fill:#f8d7da,stroke:#721c24;

    %% Click events
    click Static "https://github.com/adilmohak/django-lms/tree/main/static/"
    click Media "https://github.com/adilmohak/django-lms/tree/main/media/"
    click Templates "https://github.com/adilmohak/django-lms/tree/main/templates/"
    click Config "https://github.com/adilmohak/django-lms/tree/main/config/"
    click AccMod "https://github.com/adilmohak/django-lms/blob/main/accounts/models.py"
    click AccViews "https://github.com/adilmohak/django-lms/blob/main/accounts/views.py"
    click AccForms "https://github.com/adilmohak/django-lms/blob/main/accounts/forms.py"
    click AccURLs "https://github.com/adilmohak/django-lms/blob/main/accounts/urls.py"
    click AccAPI "https://github.com/adilmohak/django-lms/tree/main/accounts/api/"
    click CoreMod "https://github.com/adilmohak/django-lms/blob/main/core/models.py"
    click CoreViews "https://github.com/adilmohak/django-lms/blob/main/core/views.py"
    click CoreForms "https://github.com/adilmohak/django-lms/blob/main/core/forms.py"
    click CoreURLs "https://github.com/adilmohak/django-lms/blob/main/core/urls.py"
    click CoreAPI "https://github.com/adilmohak/django-lms/tree/main/core/api/"
    click CourseMod "https://github.com/adilmohak/django-lms/blob/main/course/models.py"
    click CourseViews "https://github.com/adilmohak/django-lms/blob/main/course/views.py"
    click CourseForms "https://github.com/adilmohak/django-lms/blob/main/course/forms.py"
    click CourseURLs "https://github.com/adilmohak/django-lms/blob/main/course/urls.py"
    click CourseAPI "https://github.com/adilmohak/django-lms/tree/main/course/api/"
    click QuizMod "https://github.com/adilmohak/django-lms/blob/main/quiz/models.py"
    click QuizViews "https://github.com/adilmohak/django-lms/blob/main/quiz/views.py"
    click QuizForms "https://github.com/adilmohak/django-lms/blob/main/quiz/forms.py"
    click QuizURLs "https://github.com/adilmohak/django-lms/blob/main/quiz/urls.py"
    click QuizAPI "https://github.com/adilmohak/django-lms/tree/main/quiz/api/"
    click ResultMod "https://github.com/adilmohak/django-lms/blob/main/result/models.py"
    click ResultViews "https://github.com/adilmohak/django-lms/blob/main/result/views.py"
    click ResultURLs "https://github.com/adilmohak/django-lms/blob/main/result/urls.py"
    click ResultAPI "https://github.com/adilmohak/django-lms/tree/main/result/api/"
    click PayMod "https://github.com/adilmohak/django-lms/blob/main/payments/models.py"
    click PayViews "https://github.com/adilmohak/django-lms/blob/main/payments/views.py"
    click PayStripe "https://github.com/adilmohak/django-lms/blob/main/payments/views_stripe.py"
    click PayURLs "https://github.com/adilmohak/django-lms/blob/main/payments/urls.py"
    click SearchMod "https://github.com/adilmohak/django-lms/blob/main/search/models.py"
    click SearchViews "https://github.com/adilmohak/django-lms/blob/main/search/views.py"
    click SearchURLs "https://github.com/adilmohak/django-lms/blob/main/search/urls.py"
```
