# sambhav1501/cpu-scheduler-simulator architecture

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

- Interactive diagram: https://gitdiagram.com/sambhav1501/cpu-scheduler-simulator
- Repository: https://github.com/sambhav1501/cpu-scheduler-simulator

## Overview

##### Project type and purpose
- This is a static, client-side **Interactive Web Application** (“CPU Scheduler Simulator”) meant for educational use.
- It runs entirely in the browser (no server-side code), visualizes CPU scheduling algorithms in real-time, and provides documentation and about pages.

##### File structure
- Top level
- index.html – Landing page
- docs.html – Documentation
- about.html – Team info
- style.css, docs.css – Global styles
- images/, img/ – Assets
- backend/ – Core simulator module
- backend folder
- css/ – Simulator-specific styles (bootstrap-simplex.css, cpu-scheduler.css, explanation.css)
- js/ – Algorithm engine & UI scripts (cpu-scheduler.js, new.js, bootstrap-slider.js, MathJaxSetup.js)
- ganttcharts.html – Main simulation interface (loads engine, renders Gantt)

##### README for additional insights
- Frontend only: HTML5, CSS3 (Bootstrap), JavaScript (ES6+), Chart.js, MathJax
- Key components called out: Algorithm Engine, Visualization System (Gantt), Calculation Engine, Responsive Design

a. Main components
1. **Static Asset Host** (e.g., GitHub Pages)
2. **Browser (Client)**
- UI Layer (HTML5 + CSS + Bootstrap)
- Controller Layer (Event handlers in JS)
- Model Layer (Process data structures + metrics)
- Algorithm Engine (Preemptive & non-preemptive schedulers)
- Calculation Engine (waiting time, turnaround time, CPU utilization)
- Visualization Engine (Chart.js + Gantt module)
- Documentation Module (docs.html + MathJax explanations)
b. Relationships & data flow
1. User opens index.html → Browser requests static assets from host
2. User navigates to ganttcharts.html → JS Controller initializes Algorithm Engine & UI
3. User inputs processes → Controller stores in Model
4. Controller invokes Algorithm Engine → produces execution sequence
5. Calculation Engine derives performance metrics → updates Model
6. Visualization Engine (Chart.js) reads Model → renders dynamic Gantt chart
7. UI Layer displays metrics, step-by-step explanation (MathJax for formulas)
c. Architectural patterns & principles
- **Modular Frontend**: separation of concerns (Algorithm, Calculation, Visualization, UI, Styling)
- **MVC-like flow**: Model (process data), View (HTML/CSS/Chart), Controller (JS events)
- **Static-site deployment**: simplicity, no backend server
d. Key technologies
- HTML5, CSS3, Bootstrap (UI)
- JavaScript ES6+ (logic)
- Chart.js (Gantt charts)
- MathJax (formula rendering)
- bootstrap-slider (parameter input)

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Host
    StaticHost["Static Asset Host"]:::host

    %% Browser boundary
    subgraph "Client (Browser)"
        direction TB
        User["User"]:::external
        %% UI Layer
        subgraph "UI Layer (HTML/CSS)" 
            direction TB
            Index["index.html"]:::ui
            About["about.html"]:::ui
            DocsPage["docs.html"]:::ui
            GanttPage["ganttcharts.html"]:::ui
            style_css["style.css"]:::ui
            docs_css["docs.css"]:::ui
        end

        %% Simulator-Specific Styles
        subgraph "Simulator Styles (Scheduler CSS)"
            direction TB
            bs_simplex["bootstrap-simplex.css"]:::ui
            cpu_css["cpu-scheduler.css"]:::ui
            explanation_css["explanation.css"]:::ui
        end

        %% Controller Layer
        subgraph "Controller Layer (Event Handlers)"
            direction TB
            NewJS["new.js"]:::controller
            SliderJS["bootstrap-slider.js"]:::controller
        end

        %% Model Layer
        Model["Model (Process Data & Metrics)"]:::model

        %% Algorithm & Calculation Engine
        CPU_JS["cpu-scheduler.js"]:::algorithm
        CalcEngine["Calculation Engine"]:::algorithm

        %% Visualization Engine
        VizEngine["Visualization Engine (Chart.js + Gantt)"]:::viz

        %% Documentation Module
        DocsModule["Documentation Module"]:::doc
    end

    %% Connections
    StaticHost -->|serves assets| GanttPage
    StaticHost -->|serves assets| Index
    StaticHost -->|serves assets| About
    StaticHost -->|serves assets| DocsPage
    StaticHost -->|serves assets| style_css
    StaticHost -->|serves assets| docs_css
    StaticHost -->|serves assets| bs_simplex
    StaticHost -->|serves assets| cpu_css
    StaticHost -->|serves assets| explanation_css
    StaticHost -->|serves assets| NewJS
    StaticHost -->|serves assets| SliderJS
    StaticHost -->|serves assets| CPU_JS
    StaticHost -->|serves assets| MathJaxJS
    StaticHost -->|serves assets| VizEngine
    StaticHost -->|serves assets| DocsModule

    User -->|interacts| Index
    User -->|navigates to| GanttPage
    Index -->|loads CSS| style_css
    DocsPage -->|loads CSS| docs_css
    GanttPage -->|loads JS| NewJS
    GanttPage -->|loads JS| SliderJS
    GanttPage -->|loads JS| CPU_JS
    GanttPage -->|loads JS| VizEngine
    DocsPage -->|loads JS| MathJaxJS

    Index -->|clicks| GanttPage
    GanttPage -->|"initialize()"| NewJS
    NewJS -->|triggers| Model
    SliderJS -->|updates| Model
    Model -->|data| CPU_JS
    CPU_JS -->|executes schedulers| CalcEngine
    CalcEngine -->|computes metrics| Model
    Model -->|provides data| VizEngine
    VizEngine -->|renders chart| GanttPage
    DocsPage -->|"render formulas"| MathJaxJS
    DocsPage -->|displays content| DocsModule

    %% Click Events
    click Index "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/index.html"
    click About "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/about.html"
    click DocsPage "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/docs.html"
    click GanttPage "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/backend/ganttcharts.html"
    click style_css "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/style.css"
    click docs_css "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/docs.css"
    click bs_simplex "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/backend/css/bootstrap-simplex.css"
    click cpu_css "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/backend/css/cpu-scheduler.css"
    click explanation_css "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/backend/css/explanation.css"
    click NewJS "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/backend/js/new.js"
    click SliderJS "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/backend/js/bootstrap-slider.js"
    click CPU_JS "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/backend/js/cpu-scheduler.js"
    click MathJaxJS "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/backend/js/MathJaxSetup.js"
    click DocsModule "https://github.com/sambhav1501/cpu-scheduler-simulator/blob/main/README.md"

    %% Styles
    classDef host fill:#cccccc,stroke:#333,stroke-width:1px
    classDef external fill:#eeeeee,stroke:#888,stroke-width:1px
    classDef ui fill:#a8c8ff,stroke:#1f5fbf,stroke-width:1px
    classDef controller fill:#c8f0ff,stroke:#1faecf,stroke-width:1px
    classDef algorithm fill:#b0f2b0,stroke:#31a631,stroke-width:1px
    classDef model fill:#e0f7f7,stroke:#3ba3a3,stroke-width:1px
    classDef viz fill:#ffdab0,stroke:#ff8c1a,stroke-width:1px
    classDef doc fill:#fff2a8,stroke:#bfa31f,stroke-width:1px
```
