# kadiryazadzhi/judgex architecture

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

- Interactive diagram: https://gitdiagram.com/kadiryazadzhi/judgex
- Repository: https://github.com/kadiryazadzhi/judgex

## Overview

##### Main Components
- User Interface (UI) / Presentation Layer:
– HTML pages: index.html, profile.html, system.html, test.html (each representing different “views” for home, user profile, and system functionalities).
– CSS directories (Style/For All, Style/Home, Style/Profile, Style/System, etc.) that implement the design and responsive behaviors including dark/light modes.

- Client-Side Logic / Script Layer:
– JavaScript files bundled into functional modules:
▪ For All: General utilities and common functionality (e.g., chat-bot logic, clock, and shared constants).
▪ Home: Controls the home page features such as header features, animations, language cards, leaderboard, map, etc.
▪ Profile: Manages user interactions in the profile area (e.g., badge handling, certificate generation, profile notifications, image modifications).
▪ System: Deals with core judging system functionalities (e.g., code compilation, exercise submissions, problem document downloads, sidebar logic, and interactive elements like timers and validation routines).
▪ Other: Special scripts such as the 404 page logic and external connections (like firebase).

- Exercise Content Repository:
– The “Exercise” directory contains the coding challenges, grouped by difficulty (Easy, Medium, Hard, Insane, Special). Each exercise is stored as a document that possibly provides a problem statement.
– This separation highlights the modular design where different coding challenges are categorized and can be dynamically loaded or referenced by the system.

- JSON Configuration / Data Layer:
– JSON files (found in the “Json” folder) hold key data:
▪ chat-bot phrases,
▪ exercises-answers data,
▪ system information (perhaps guiding dynamic behavior).

- Assets / Static Resources:
– Image directory for badges and other visual elements.
– Static HTML error pages (403.html, 404.html) to handle user navigation errors.

##### Relationships and Interactions
- The UI sends user events (clicks, form inputs, navigation events) to the respective JavaScript modules.
- Each UI section (Home, Profile, System) interacts with its dedicated script set, which processes inputs, controls animations, data loading from JSON, and even dynamic updates of the DOM.
- The Exercise repository provides problem data that the system component (under Script/System) fetches or references to display problems, validate responses, or update solutions.
- The JSON data plays a role in supplying configuration details (such as system parameters, language options, and preset answers) that the scripts can load at runtime.
- Styling (CSS) connects with the UI to render components correctly and to reflect dynamic changes (like theme switching triggered via Script/System).

##### Key Architectural Patterns and Design Principles
- Modularization: Clear separation of concerns where different directories address different UI pages (Home, Profile, System) and separate logic modules.
- Layering: UI (HTML/CSS) is cleanly separated from Client-Side Logic (JS), which further communicates with static data sources (JSON files).
- Reusability: Shared scripts in “For All” enable common functionality across multiple areas.
- Extensibility: The clear segregation of exercises (by difficulty) and dedicated script folders facilitates easy addition of new challenges and features.

##### Elements
- Clear Nodes: Represent each major component (UI Pages, Script Modules for Home, Profile, System, JSON/Exercise Data, Assets).
– User Interaction → UI Page → JavaScript Module.
– JavaScript Module → JSON/Exercise Data (for loading challenge data).
– JavaScript Module → CSS/Style updates (for theme changes and responsive behavior).

– Start with the end-user at the top, driving interactions with the Web Browser.
– The browser displays different pages: Home, Profile, System. Each page is linked to a particular set of CSS and JavaScript modules.
– Next, indicate how these scripts access static JSON data for configuration and exercise details.
– Clearly separate the “Exercise” folder content as a distinct module that serves as the content repository for challenges.
– Also, show that shared utility scripts and assets (images, configuration files) are accessed across modules.
– Finally, include ancillary components (error pages, additional scripts from the “Other” folder) and point out their roles (e.g., handling 404 errors or integrating with third-party services like Firebase).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Web Browser"]:::user

    subgraph "Presentation Layer"
        subgraph "HTML Pages"
            H["Home Page"]:::html
            P["Profile Page"]:::html
            S["System Page"]:::html
            T["Test Page"]:::html
        end
        subgraph "CSS Styles"
            G["Global CSS"]:::css
            HC["Home CSS"]:::css
            PC["Profile CSS"]:::css
            SC["System CSS"]:::css
            EC["404 CSS"]:::css
        end
    end

    subgraph "Client-Side Logic"
        subgraph "Shared Utilities"
            util1["all-const.js"]:::js
            util2["chat-bot-container.js"]:::js
            util3["chat-bot-logic.js"]:::js
            util4["clock.js"]:::js
            util5["decrypte-data.js"]:::js
            util6["pages-start-time.js"]:::js
        end
        HJS["Home Scripts"]:::js
        PJS["Profile Scripts"]:::js
        SJS["System Scripts"]:::js
        subgraph "Other Scripts"
            O1["404.js"]:::js
            O2["firebase-connect.js"]:::js
            O3["prevent-console-modification.js"]:::js
        end
    end

    subgraph "Data/Content Layer"
        subgraph "JSON Configuration"
            J1["chat-bot-phrases.json"]:::json
            J2["exercises-answers-data.json"]:::json
            J3["information-about-system.json"]:::json
        end
        subgraph "Exercise Content Repository"
            E1["Easy Exercises"]:::data
            E2["Medium Exercises"]:::data
            E3["Hard Exercises"]:::data
            E4["Insane Exercises"]:::data
            E5["Special Exercises"]:::data
        end
    end

    subgraph "Assets / Static Resources"
        subgraph "Images"
            I1["Badges Images"]:::asset
            I2["Template Images"]:::asset
        end
        subgraph "Error Pages"
            EP1["403.html"]:::asset
            EP2["404.html"]:::asset
        end
    end

    %% Arrows from Web Browser to Presentation Layer
    A --> H
    A --> P
    A --> S
    A --> T

    %% Arrows from HTML Pages to respective Script Modules
    H --> HJS
    P --> PJS
    S --> SJS
    T --> HJS

    %% Shared Utilities support all script modules
    util1 --- HJS
    util1 --- PJS
    util1 --- SJS

    %% Client-Side Logic interactions with JSON and Exercise Data
    HJS -->|"fetchConfig"| J1
    PJS -->|"updateData"| J2
    SJS -->|"systemInfo"| J3
    SJS -->|"loadExercise"| E3

    %% Other Scripts connection to Error Pages
    O1 --> EP2

    %% Styles integration assumed with HTML Pages (implicit)

    %% Class Definitions
    classDef user fill:#ffd1dc,stroke:#333,stroke-width:2px;
    classDef html fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef css fill:#b3e6b3,stroke:#333,stroke-width:2px;
    classDef js fill:#d1c4e9,stroke:#333,stroke-width:2px;
    classDef json fill:#fff2cc,stroke:#333,stroke-width:2px;
    classDef data fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef asset fill:#e6e6fa,stroke:#333,stroke-width:2px;

    %% Click Events for Presentation Layer
    click H "https://github.com/kadiryazadzhi/judgex/blob/main/index.html"
    click P "https://github.com/kadiryazadzhi/judgex/blob/main/profile.html"
    click S "https://github.com/kadiryazadzhi/judgex/blob/main/system.html"
    click T "https://github.com/kadiryazadzhi/judgex/blob/main/test.html"
    click G "https://github.com/kadiryazadzhi/judgex/tree/main/Style/For All/"
    click HC "https://github.com/kadiryazadzhi/judgex/tree/main/Style/Home/"
    click PC "https://github.com/kadiryazadzhi/judgex/tree/main/Style/Profile/"
    click SC "https://github.com/kadiryazadzhi/judgex/tree/main/Style/System/"
    click EC "https://github.com/kadiryazadzhi/judgex/blob/main/Style/Other/404.css"

    %% Click Events for Client-Side Logic / Script Layer
    click util1 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/For All/all-const.js"
    click util2 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/For All/chat-bot-container.js"
    click util3 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/For All/chat-bot-logic.js"
    click util4 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/For All/clock.js"
    click util5 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/For All/decrypte-data.js"
    click util6 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/For All/pages-start-time.js"
    click HJS "https://github.com/kadiryazadzhi/judgex/tree/main/Script/Home/"
    click PJS "https://github.com/kadiryazadzhi/judgex/tree/main/Script/Profile/"
    click SJS "https://github.com/kadiryazadzhi/judgex/tree/main/Script/System/"
    click O1 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/Other/404.js"
    click O2 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/Other/firebase-connect.js"
    click O3 "https://github.com/kadiryazadzhi/judgex/blob/main/Script/Other/prevent-console-modification.js"

    %% Click Events for Exercise Content Repository
    click E1 "https://github.com/kadiryazadzhi/judgex/tree/main/Exercise/Easy/"
    click E2 "https://github.com/kadiryazadzhi/judgex/tree/main/Exercise/Medium/"
    click E3 "https://github.com/kadiryazadzhi/judgex/tree/main/Exercise/Hard/"
    click E4 "https://github.com/kadiryazadzhi/judgex/tree/main/Exercise/Insane/"
    click E5 "https://github.com/kadiryazadzhi/judgex/tree/main/Exercise/Special/"

    %% Click Events for JSON Configuration
    click J1 "https://github.com/kadiryazadzhi/judgex/blob/main/Json/chat-bot-phrases.json"
    click J2 "https://github.com/kadiryazadzhi/judgex/blob/main/Json/exercises-answers-data.json"
    click J3 "https://github.com/kadiryazadzhi/judgex/blob/main/Json/information-about-system.json"

    %% Click Events for Assets / Static Resources
    click I1 "https://github.com/kadiryazadzhi/judgex/tree/main/Image/Badges"
    click I2 "https://github.com/kadiryazadzhi/judgex/tree/main/Image/Template"
    click EP1 "https://github.com/kadiryazadzhi/judgex/blob/main/403.html"
    click EP2 "https://github.com/kadiryazadzhi/judgex/blob/main/404.html"
```
