# adigunsherif/cbt architecture

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

- Interactive diagram: https://gitdiagram.com/adigunsherif/cbt
- Repository: https://github.com/adigunsherif/cbt

## Overview

##### Project type and purpose
- This is a full-stack Django web application implementing a Computer-Based Testing (CBT) system.
- Its primary purpose is to allow administrators to create exams, manage question banks, assign exams to students, auto-time and submit tests, and display student scores.

##### File structure
- Top-level directories:
- apps/core – “core” business logic (users, sessions/terms, staff/student lists)
- apps/exam – exam functionality (questions, assignments, take-test flows, scoring)
- cbt – Django project settings (asgi.py, wsgi.py, settings.py, urls.py)
- static – vendor-provided assets (Bootstrap, jQuery, Summernote, FontAwesome, etc.)
- templates – project-level HTML templates (base.html, dashboard.html, error pages)
- Configuration/build files: manage.py, requirements.txt, .env example, flake8/.isort configs
- Patterns:
- MVC/MVT pattern with Django apps separating views, models, forms, templates
- Use of Django middleware and context processors for cross-cutting concerns
- Database migrations under each app
- Modular “apps” approach (core vs exam)

##### README for additional insights
- Tech stack: Django 4, Bootstrap 5, Summernote, FontAwesome, jQuery
- Features: timezone awareness, unlimited exams/questions, question bank, auto timeout/submit, configurable options

##### Main components of the system
a. Client (browser/mobile browser) – renders HTML/CSS/JS, interacts via HTTP(S)
b. Web Server & Application Server – e.g., Nginx (static files) + Gunicorn/Uvicorn (Django ASGI/WSGI)
c. Django Application – cbt project + two apps (core, exam)
d. Template Engine & Static Assets – HTML templates, Bootstrap, Summernote, jQuery, FontAwesome
e. Database – relational DB (PostgreSQL/MySQL/SQLite via Django ORM)
f. External/Infrastructure services (optional) – caching layer (Redis/Memcached), email/SMTP, environment variables

##### Relationships & interactions
- Browser → HTTP Request → Web Server → Django URL dispatcher → view (apps/core or apps/exam) → ORM → Database → view → Template → HTTP Response → Browser
- Middleware & context processors intercept requests/responses for authentication, settings, etc.
- Static assets served directly by Web Server or via Django’s static files handler.
- Migrations update DB schema; tests exercise models/views.

##### Architectural patterns & design principles
- Django’s MVT (Model-View-Template) pattern
- Separation of concerns via “apps”
- Reusable components (forms, filters, context processors, middleware)
- Configurable settings via .env and Django settings.py
- Modular and layered: presentation (templates/static), business logic (views/forms), data (models/ORM)

##### Relevant technologies/frameworks/libraries
- Django 4 framework
- Python packages from requirements.txt
- Bootstrap 5 (CSS grid, components)
- Summernote rich-text editor integration
- jQuery & countdown plugin for timing
- Optional caching (Redis/Memcached) and reverse proxy (Nginx)

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Client Layer
  Browser["User Browser\n(HTML/CSS/JS)"]:::frontend

  %% Edge Layer
  subgraph "Edge Layer"
    WebServer["Nginx/Apache\n(Static & Proxy)"]:::backend
    Cache["Redis/Memcached"]:::service
    SMTP["SMTP Service"]:::external
    Env["Env Store"]:::external
  end

  %% Application Server
  AppServer["Gunicorn/Uvicorn"]:::backend

  %% Django Application
  subgraph "Django Application"
    direction TB

    subgraph "Project Entry"
      Settings["settings.py"]:::config
      ASGI["asgi.py"]:::config
      WSGI["wsgi.py"]:::config
      URLS["urls.py"]:::backend
    end

    Middleware["Middleware & Context Processors"]:::service
    Views["Views"]:::backend
    ORM["Django ORM"]:::service
    DB["Database\n(PostgreSQL/MySQL)"]:::datastore
    TemplateEngine["Template Engine"]:::frontend

    subgraph "Apps"
      direction TB

      subgraph "Core App"
        CoreModels["models.py"]:::backend
        CoreViews["views.py"]:::backend
        CoreForms["forms.py"]:::backend
        CoreTemplates["templates/core/"]:::frontend
        CoreURLs["urls.py"]:::backend
        CoreMigs["migrations/"]:::datastore
        CoreTests["tests/"]:::service
      end

      subgraph "Exam App"
        ExamModels["models.py"]:::backend
        ExamViews["views.py"]:::backend
        ExamForms["forms.py"]:::backend
        ExamFilters["filters.py"]:::backend
        ExamTemplates["templates/exam/"]:::frontend
        ExamURLs["urls.py"]:::backend
        ExamMigs["migrations/"]:::datastore
        ExamTests["tests.py"]:::service
      end
    end

    Settings --> URLS
    ASGI --> URLS
    WSGI --> URLS
    AppServer --> URLS
    URLS --> Middleware
    Middleware --> Views
    Views --> ORM --> DB
    Views --> TemplateEngine
    TemplateEngine --> Static

  end

  %% Static Assets
  Static["Static Asset Handler\n(bootstrap, jQuery, Summernote, FontAwesome)"]:::frontend

  %% Application Launcher
  manage["manage.py"]:::service

  %% Flows
  Browser -->|"HTTP/HTTPS"| WebServer
  WebServer -->|"WSGI/ASGI"| AppServer
  WebServer -->|"Serves Static"| Static
  AppServer --> manage
  Browser -->|AJAX/Form Post| ExamViews

  %% Click Events
  click Settings "https://github.com/adigunsherif/cbt/blob/master/cbt/settings.py"
  click ASGI "https://github.com/adigunsherif/cbt/blob/master/cbt/asgi.py"
  click WSGI "https://github.com/adigunsherif/cbt/blob/master/cbt/wsgi.py"
  click URLS "https://github.com/adigunsherif/cbt/blob/master/cbt/urls.py"
  click Middleware "https://github.com/adigunsherif/cbt/blob/master/apps/core/middleware.py"
  click Middleware "https://github.com/adigunsherif/cbt/blob/master/apps/core/context_processors.py"
  click CoreModels "https://github.com/adigunsherif/cbt/blob/master/apps/core/models.py"
  click CoreViews "https://github.com/adigunsherif/cbt/blob/master/apps/core/views.py"
  click CoreForms "https://github.com/adigunsherif/cbt/blob/master/apps/core/forms.py"
  click CoreTemplates "https://github.com/adigunsherif/cbt/tree/master/apps/core/templates/core/"
  click CoreURLs "https://github.com/adigunsherif/cbt/blob/master/apps/core/urls.py"
  click CoreMigs "https://github.com/adigunsherif/cbt/tree/master/apps/core/migrations/"
  click CoreTests "https://github.com/adigunsherif/cbt/tree/master/apps/core/tests/"
  click ExamModels "https://github.com/adigunsherif/cbt/blob/master/apps/exam/models.py"
  click ExamViews "https://github.com/adigunsherif/cbt/blob/master/apps/exam/views.py"
  click ExamForms "https://github.com/adigunsherif/cbt/blob/master/apps/exam/forms.py"
  click ExamFilters "https://github.com/adigunsherif/cbt/blob/master/apps/exam/filters.py"
  click ExamTemplates "https://github.com/adigunsherif/cbt/tree/master/apps/exam/templates/exam/"
  click ExamURLs "https://github.com/adigunsherif/cbt/blob/master/apps/exam/urls.py"
  click ExamMigs "https://github.com/adigunsherif/cbt/tree/master/apps/exam/migrations/"
  click ExamTests "https://github.com/adigunsherif/cbt/blob/master/apps/exam/tests.py"
  click manage "https://github.com/adigunsherif/cbt/blob/master/manage.py"

  %% Styles
  classDef frontend fill:#E8F4FC,stroke:#2B579A,color:#2B579A
  classDef backend fill:#F3F3F3,stroke:#333,color:#333
  classDef service fill:#FFF4E5,stroke:#D9822B,color:#D9822B
  classDef datastore fill:#E8F8F5,stroke:#17A589,color:#117A65
  classDef external fill:#F0F0F0,stroke:#A6ACAF,color:#424949
  classDef config fill:#FBEFF2,stroke:#C74E75,color:#87003C
```
