# ulwus/fu-examination-system architecture

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

- Interactive diagram: https://gitdiagram.com/ulwus/fu-examination-system
- Repository: https://github.com/ulwus/fu-examination-system

## Overview

- Frontend: Represent the static assets (Bootstrap, Chart.js, Vanilla JS, Ace Editor) and templates that form the user interface for students and educators.
- Backend: Highlight the Django framework, including key modules:
- Core project (FUExaminationSystem) with global settings, routing (urls.py), and interface endpoints.
- Individual Django apps: “exams”, “competitions”, “dashboard”, “ide”, “users”, and “datasets”. Each app encapsulates its own models, views, forms, and templates.
- Real-time Communication: Include Django Channels (in the “ide” module) for websocket-based communication.
- Database and Storage: Represent MongoDB as the primary database for user and exam data, and Redis as both the cache and message broker.
- External Services and Infrastructure: Include external components such as the web server (Gunicorn), Docker as the containerization environment, and Docker Compose orchestrating the containers.
- Error Handling and Logging: Although not a separate service, note that custom error pages and Django Logging are part of the system’s resilience and monitoring.

##### Relationships and Data Flow
- Centralized Routing: Illustrate how URLs (defined in the core urls.py and those in each app’s urls.py) route requests to the appropriate Django views.
- Database and Cache Interactions: Connect the backend to MongoDB (for persistent data) and to Redis (for caching & message brokering).
- Docker Environment: Enclose the backend, Celery worker, and ancillary services in a container (or a set of containers) as defined in the Dockerfile and docker-compose.yml. This highlights the deployment and isolation of services.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Client Layer
    subgraph "Client Layer"
        UB["User Browser"]:::frontend
    end

    %% Frontend Layer
    subgraph "Frontend Layer"
        FE["Frontend UI\n(Static Assets & Templates)"]:::frontend
    end

    %% Backend Layer (Django MVT)
    subgraph "Backend Layer (Django MVT)"
        CORE["Django Core Project\n(Settings, Routing, Global Interface)"]:::backend
        APP_EXAMS["Exams Module"]:::app
        APP_COMPETITIONS["Competitions Module"]:::app
        APP_DASHBOARD["Dashboard Module"]:::app
        APP_IDE["IDE Module\n(Django Channels)"]:::app
        APP_USERS["Users Module"]:::app
        APP_DATASETS["Datasets Module"]:::app
    end

    %% Asynchronous & Real-time
    subgraph "Asynchronous & Real-time"
        CELERY["Celery Task Queue"]:::async
        CHANNELS["Django Channels (WebSocket)"]:::async
    end

    %% Data Layer
    subgraph "Data Layer"
        MONGO["MongoDB Database"]:::database
        REDIS["Redis Cache/Message Broker"]:::database
    end

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        DOCKER["Docker Container & Compose"]:::container
        GUNICORN["Gunicorn Web Server"]:::container
    end

    %% Error Handling
    subgraph "Error Handling"
        ERRORS["Custom Error Pages"]:::error
    end

    %% Connections: User Interaction and Request Routing
    UB -->|"HTTP_Request"| FE
    FE -->|"Routes_Request"| CORE
    CORE -->|"Encapsulates"| APP_EXAMS
    CORE -->|"Encapsulates"| APP_COMPETITIONS
    CORE -->|"Encapsulates"| APP_DASHBOARD
    CORE -->|"Encapsulates"| APP_IDE
    CORE -->|"Encapsulates"| APP_USERS
    CORE -->|"Encapsulates"| APP_DATASETS

    %% Asynchronous and Real-time Processing
    CORE -->|"Triggers"| CELERY
    APP_EXAMS -->|"Offloads_Task"| CELERY
    APP_IDE -->|"Initiates_WebSocket"| CHANNELS

    %% Database and Cache Interactions
    CORE -->|"Stores_Data"| MONGO
    CORE -->|"Caches_Data"| REDIS

    %% Deployment Integration
    FE -->|"Served_by"| GUNICORN
    CORE -->|"Served_by"| GUNICORN
    CELERY -->|"Runs_in"| DOCKER
    GUNICORN -->|"Runs_in"| DOCKER

    %% Error Handling Flow
    CORE -->|"Handles_Error"| ERRORS

    %% Click Events for Frontend UI
    click FE "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/templates"
    click FE "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/static"
    click FE "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/users/static"

    %% Click Events for Django Core Project
    click CORE "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/FUExaminationSystem/"
    click CORE "https://github.com/ulwus/fu-examination-system/blob/main/FUExaminationSystem/.envexample"

    %% Click Events for Django Apps
    click APP_EXAMS "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/exams"
    click APP_COMPETITIONS "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/competitions"
    click APP_DASHBOARD "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/dashboard"
    click APP_IDE "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/ide"
    click APP_USERS "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/users"
    click APP_DATASETS "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/datasets"

    %% Click Events for Celery Configuration
    click CELERY "https://github.com/ulwus/fu-examination-system/blob/main/FUExaminationSystem/FUExaminationSystem/celery.py"
    click CELERY "https://github.com/ulwus/fu-examination-system/blob/main/FUExaminationSystem/exams/tasks.py"
    click CELERY "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/celerybeat-schedule"

    %% Click Events for Docker Configuration
    click DOCKER "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/Dockerfile"
    click DOCKER "https://github.com/ulwus/fu-examination-system/blob/main/FUExaminationSystem/docker-compose.yml"

    %% Click Event for Error Pages
    click ERRORS "https://github.com/ulwus/fu-examination-system/tree/main/FUExaminationSystem/templates/errors"

    %% Styles
    classDef frontend fill:#fceabb,stroke:#e8a300,stroke-width:2px;
    classDef backend fill:#cce5ff,stroke:#0056b3,stroke-width:2px;
    classDef app fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef async fill:#f8d7da,stroke:#721c24,stroke-width:2px;
    classDef database fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
    classDef container fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef error fill:#f5c6cb,stroke:#721c24,stroke-width:2px;
```
