# amritesh-mishra-15/schedsync architecture

> Architecture diagram of the GitHub repository amritesh-mishra-15/schedsync, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amritesh-mishra-15/schedsync
- Repository: https://github.com/amritesh-mishra-15/schedsync

## Overview

#### Purpose and Runtime
SchedSync is an Electron desktop simulator for demonstrating how CPU scheduling and memory paging interact, including configurable page-fault stalls. It runs entirely as a local HTML/CSS/vanilla-JavaScript renderer application; no backend or external runtime services are indicated. Electron 28 is the material platform, launched through `main.js`, with a renderer bridge at `preload.js`.

#### Application Entry and Renderer Composition
Electron creates the desktop window and loads the renderer page. The renderer’s structural entry point is `src/index.html`; its application bootstrap and UI wiring are in `src/js/app.js`. The app is organized as an input/configuration sidebar plus visualization and control surfaces, styled by `src/styles/base.css`, `src/styles/input-panel.css`, and `src/styles/visualization.css`.

#### Process and Configuration Boundary
Process creation, validation, removal, and local process-list state belong to `src/js/process-manager.js`. Renderer form handling in `src/js/app.js` collects CPU algorithm, paging algorithm, frame count, fault-stall duration, and scheduling-specific options such as quantum. This is the boundary between user-authored workload/configuration and simulation execution.

#### Simulation Orchestrator
`src/js/simulation-engine.js` is the core stateful coordinator. On each simulation tick, it determines process eligibility/running state, invokes the selected scheduler, performs page access, applies hit/fault outcomes, and inserts configured stall ticks for faults. It produces the execution state consumed by visualizations and performance metrics, including waiting/turnaround timing, fault counts, and idle time.

#### CPU Scheduling Strategy Layer
Scheduling policy is separated into algorithm modules selected by the engine:
- `src/js/algorithms/fcfs.js`
- `src/js/algorithms/sjf.js`
- `src/js/algorithms/srtf.js`
- `src/js/algorithms/round-robin.js`
- `src/js/algorithms/priority.js`

These modules define dispatch/preemption behavior while the engine retains integrated time, process, and paging-stall control. This separation allows CPU policy changes without rewriting memory or rendering logic.

#### Memory Paging Strategy Layer
Page-frame replacement is likewise isolated:
- `src/js/algorithms/fifo-paging.js`
- `src/js/algorithms/lru-paging.js`

For a running process’s reference string, the engine asks the chosen policy to identify a hit or fault and update frame contents. Faults feed back into CPU execution through the stall mechanism, rather than being rendered as independent memory-only events.

#### Controls, Visualization, and Presentation
`src/js/controls.js` maps Step, Play/Pause, Reset, and speed selection to engine advancement, including timer-driven auto-run. Incremental renderer modules project engine state without owning scheduling decisions:
- `src/js/visualization/gantt-chart.js`
- `src/js/visualization/ready-queue.js`
- `src/js/visualization/memory-frames.js`

The Gantt timeline reflects execution and stalls; ready queue reflects running/waiting state; memory frames show accesses, hits/faults, and page log. `src/js/theme.js` manages persisted light/dark UI state, with tokens in `src/styles/variables.css`.

Main entry points: [`src/js/simulation-engine.js`](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/simulation-engine.js) (Simulation engine), [`src/js/app.js`](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/app.js) (App bootstrap), [`main.js`](https://github.com/amritesh-mishra-15/schedsync/blob/master/main.js) (Electron main process), [`src/index.html`](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/index.html) (Renderer page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_electron["Electron Shell"]
  node_electron_main{{"Electron main process<br/>Electron entry<br/>[main.js]"}}
  node_preload["Renderer bridge<br/>Electron preload<br/>[preload.js]"]
end

subgraph group_renderer["Renderer App"]
  node_index["Renderer page<br/>HTML entry<br/>[index.html]"]
  node_app["App bootstrap<br/>renderer bootstrap<br/>[app.js]"]
  node_process_manager["Process manager<br/>workload state<br/>[process-manager.js]"]
  node_controls["Simulation controls<br/>control adapter<br/>[controls.js]"]
  node_engine{{"Simulation engine<br/>stateful orchestrator"}}
end

subgraph group_scheduling["CPU Scheduling"]
  node_fcfs["FCFS<br/>scheduler strategy<br/>[fcfs.js]"]
  node_sjf["SJF<br/>scheduler strategy<br/>[sjf.js]"]
  node_srtf["SRTF<br/>scheduler strategy<br/>[srtf.js]"]
  node_round_robin["Round Robin<br/>scheduler strategy<br/>[round-robin.js]"]
  node_priority["Priority<br/>scheduler strategy<br/>[priority.js]"]
end

subgraph group_paging["Memory Paging"]
  node_fifo["FIFO paging<br/>paging strategy<br/>[fifo-paging.js]"]
  node_lru["LRU paging<br/>paging strategy<br/>[lru-paging.js]"]
end

subgraph group_presentation["Presentation"]
  node_gantt["Gantt chart<br/>execution view<br/>[gantt-chart.js]"]
  node_ready_queue["Ready queue<br/>queue view<br/>[ready-queue.js]"]
  node_memory_frames["Memory frames<br/>memory view<br/>[memory-frames.js]"]
  node_theme["Theme state<br/>UI preference<br/>[theme.js]"]
  node_styles["UI styles<br/>CSS layers<br/>[variables.css]"]
end

node_electron_main -->|"attaches"| node_preload
node_electron_main -->|"loads"| node_index
node_index -->|"boots"| node_app
node_app -->|"submits workload"| node_process_manager
node_app -->|"wires actions"| node_controls
node_app -->|"configures simulation"| node_engine
node_process_manager -->|"provides processes"| node_engine
node_controls -->|"advance, reset, auto-run"| node_engine
node_engine -.->|"selects policy"| node_fcfs
node_engine -.->|"selects policy"| node_sjf
node_engine -.->|"selects policy"| node_srtf
node_engine -.->|"selects policy"| node_round_robin
node_engine -.->|"selects policy"| node_priority
node_engine -.->|"selects policy"| node_fifo
node_engine -.->|"selects policy"| node_lru
node_engine -->|"execution and stalls"| node_gantt
node_engine -->|"queue state"| node_ready_queue
node_engine -->|"frame and access state"| node_memory_frames
node_app -->|"initializes"| node_theme
node_theme -->|"applies theme tokens"| node_styles

click node_electron_main "https://github.com/amritesh-mishra-15/schedsync/blob/master/main.js"
click node_preload "https://github.com/amritesh-mishra-15/schedsync/blob/master/preload.js"
click node_index "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/index.html"
click node_app "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/app.js"
click node_process_manager "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/process-manager.js"
click node_controls "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/controls.js"
click node_engine "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/simulation-engine.js"
click node_fcfs "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/fcfs.js"
click node_sjf "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/sjf.js"
click node_srtf "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/srtf.js"
click node_round_robin "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/round-robin.js"
click node_priority "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/priority.js"
click node_fifo "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/fifo-paging.js"
click node_lru "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/lru-paging.js"
click node_gantt "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/visualization/gantt-chart.js"
click node_ready_queue "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/visualization/ready-queue.js"
click node_memory_frames "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/visualization/memory-frames.js"
click node_theme "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/theme.js"
click node_styles "https://github.com/amritesh-mishra-15/schedsync/blob/master/src/styles/variables.css"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_electron_main,node_preload toneBlue
class node_index,node_app,node_process_manager,node_controls,node_engine toneAmber
class node_fcfs,node_sjf,node_srtf,node_round_robin,node_priority toneMint
class node_fifo,node_lru toneRose
class node_gantt,node_ready_queue,node_memory_frames,node_theme,node_styles toneIndigo
```

## Components

### Electron Shell

- [Electron main process](https://github.com/amritesh-mishra-15/schedsync/blob/master/main.js): Electron entry · Creates the desktop window and loads the renderer. · `main.js`
- [Renderer bridge](https://github.com/amritesh-mishra-15/schedsync/blob/master/preload.js): Electron preload · `preload.js`

### Renderer App

- [Renderer page](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/index.html): HTML entry · `src/index.html`
- [App bootstrap](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/app.js): renderer bootstrap · Wires configuration, controls, engine, and views. · `src/js/app.js`
- [Process manager](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/process-manager.js): workload state · Creates, validates, removes, and stores processes. · `src/js/process-manager.js`
- [Simulation controls](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/controls.js): control adapter · Maps step, auto-run, reset, and speed actions to engine advancement. · `src/js/controls.js`
- [Simulation engine](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/simulation-engine.js): stateful orchestrator · Coordinates ticks, dispatch, page access, fault stalls, and metrics. · `src/js/simulation-engine.js`

### CPU Scheduling

- [FCFS](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/fcfs.js): scheduler strategy · `src/js/algorithms/fcfs.js`
- [SJF](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/sjf.js): scheduler strategy · `src/js/algorithms/sjf.js`
- [SRTF](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/srtf.js): scheduler strategy · `src/js/algorithms/srtf.js`
- [Round Robin](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/round-robin.js): scheduler strategy · `src/js/algorithms/round-robin.js`
- [Priority](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/priority.js): scheduler strategy · `src/js/algorithms/priority.js`

### Memory Paging

- [FIFO paging](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/fifo-paging.js): paging strategy · `src/js/algorithms/fifo-paging.js`
- [LRU paging](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/algorithms/lru-paging.js): paging strategy · `src/js/algorithms/lru-paging.js`

### Presentation

- [Gantt chart](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/visualization/gantt-chart.js): execution view · Shows execution intervals and fault stalls. · `src/js/visualization/gantt-chart.js`
- [Ready queue](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/visualization/ready-queue.js): queue view · Shows running and waiting processes. · `src/js/visualization/ready-queue.js`
- [Memory frames](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/visualization/memory-frames.js): memory view · Shows frames, hit/fault outcomes, and page log. · `src/js/visualization/memory-frames.js`
- [Theme state](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/js/theme.js): UI preference · Persists light/dark renderer state. · `src/js/theme.js`
- [UI styles](https://github.com/amritesh-mishra-15/schedsync/blob/master/src/styles/variables.css): CSS layers · Defines shared tokens, input panel, and visualization styling. · `src/styles/variables.css`

## Connections

- Electron main process → Renderer bridge: attaches
- Electron main process → Renderer page: loads
- Renderer page → App bootstrap: boots
- App bootstrap → Process manager: submits workload
- App bootstrap → Simulation controls: wires actions
- App bootstrap → Simulation engine: configures simulation
- Process manager → Simulation engine: provides processes
- Simulation controls → Simulation engine: advance, reset, auto-run
- Simulation engine → FCFS: selects policy
- Simulation engine → SJF: selects policy
- Simulation engine → SRTF: selects policy
- Simulation engine → Round Robin: selects policy
- Simulation engine → Priority: selects policy
- Simulation engine → FIFO paging: selects policy
- Simulation engine → LRU paging: selects policy
- Simulation engine → Gantt chart: execution and stalls
- Simulation engine → Ready queue: queue state
- Simulation engine → Memory frames: frame and access state
- App bootstrap → Theme state: initializes
- Theme state → UI styles: applies theme tokens
