# dhruvvit/cpu-scheduler architecture

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

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

## Overview

This is a browser-based CPU scheduling simulator. Users enter processes and scheduling options, validate the inputs, run one of five scheduling policies, and inspect the resulting timeline, per-process results, metrics, and ready-queue events. The React app coordinates that workflow; a framework-independent algorithm entry point dispatches to the selected scheduler and adds aggregate metrics. The source index and excerpts support the main orchestration and several algorithm details; other algorithm implementations are represented by their indexed paths, without assuming unsampled behavior beyond the documented dispatch.

Main entry points: [`src/App.tsx`](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/App.tsx) (Simulation app), [`src/algorithms/index.ts`](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/index.ts) (Algorithm dispatcher), [`src/types/scheduler.ts`](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/types/scheduler.ts) (Scheduler data types), [`src/components/GanttChart.tsx`](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/GanttChart.tsx) (Gantt chart)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Simulation workflow"]
  node_app["Simulation app<br/>[App.tsx]"]
  node_process_table["Process inputs<br/>[ProcessTable.tsx]"]
  node_algorithm_selector["Algorithm options"]
end

subgraph group_scheduling["Scheduling algorithms"]
  node_runner["Algorithm dispatcher<br/>[index.ts]"]
  node_fcfs["FCFS scheduler<br/>[fcfs.ts]"]
  node_sjf["SJF scheduler<br/>[sjf.ts]"]
  node_srtf["SRTF scheduler<br/>[srtf.ts]"]
  node_rr["Round Robin scheduler<br/>[roundRobin.ts]"]
  node_priority["Priority scheduler<br/>[priority.ts]"]
end

subgraph group_results["Results and display"]
  node_gantt["Gantt chart<br/>[GanttChart.tsx]"]
  node_metrics_panel["Metrics panel<br/>[MetricsPanel.tsx]"]
  node_ready_queue["Ready queue<br/>[ReadyQueue.tsx]"]
end

subgraph group_shared["Shared logic"]
  node_validation["Input validation<br/>[validation.ts]"]
  node_metrics["Metrics calculation<br/>[metrics.ts]"]
  node_colors["Process colors<br/>[colors.ts]"]
  node_scheduler_types["Scheduler data types<br/>[scheduler.ts]"]
end

node_user(("User"))

node_user -->|"edits processes"| node_process_table
node_user -->|"chooses options"| node_algorithm_selector
node_process_table -->|"updates inputs"| node_app
node_algorithm_selector -->|"updates config"| node_app
node_app -->|"validates inputs"| node_validation
node_app -->|"runs simulation"| node_runner
node_runner -->|"dispatches FCFS"| node_fcfs
node_runner -->|"dispatches SJF"| node_sjf
node_runner -->|"dispatches SRTF"| node_srtf
node_runner -->|"dispatches RR"| node_rr
node_runner -->|"dispatches priority"| node_priority
node_runner -->|"calculates metrics"| node_metrics
node_app -->|"renders inputs"| node_process_table
node_app -->|"renders options"| node_algorithm_selector
node_app -->|"renders schedule"| node_gantt
node_app -->|"renders metrics"| node_metrics_panel
node_app -->|"renders events"| node_ready_queue
node_gantt -->|"builds color map"| node_colors
node_metrics_panel -->|"builds color map"| node_colors
node_ready_queue -->|"uses process colors"| node_colors
node_app -->|"uses data types"| node_scheduler_types
node_runner -->|"uses data types"| node_scheduler_types
node_metrics -->|"uses result types"| node_scheduler_types
node_gantt -->|"reads schedule types"| node_scheduler_types
node_metrics_panel -->|"reads output types"| node_scheduler_types
node_ready_queue -->|"reads event types"| node_scheduler_types

click node_app "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/App.tsx"
click node_process_table "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/ProcessTable.tsx"
click node_algorithm_selector "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/AlgorithmSelector.tsx"
click node_validation "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/utils/validation.ts"
click node_runner "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/index.ts"
click node_fcfs "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/fcfs.ts"
click node_sjf "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/sjf.ts"
click node_srtf "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/srtf.ts"
click node_rr "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/roundRobin.ts"
click node_priority "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/priority.ts"
click node_metrics "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/utils/metrics.ts"
click node_gantt "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/GanttChart.tsx"
click node_metrics_panel "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/MetricsPanel.tsx"
click node_ready_queue "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/ReadyQueue.tsx"
click node_colors "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/utils/colors.ts"
click node_scheduler_types "https://github.com/dhruvvit/cpu-scheduler/blob/main/src/types/scheduler.ts"

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_app,node_process_table,node_algorithm_selector,node_user toneBlue
class node_runner,node_fcfs,node_sjf,node_srtf,node_rr,node_priority toneAmber
class node_gantt,node_metrics_panel,node_ready_queue toneMint
class node_validation,node_metrics,node_colors,node_scheduler_types toneRose
```

## Components

### Simulation workflow

- [Simulation app](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/App.tsx): `src/App.tsx`
- [Process inputs](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/ProcessTable.tsx): `src/components/ProcessTable.tsx`
- [Algorithm options](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/AlgorithmSelector.tsx): `src/components/AlgorithmSelector.tsx`

### Scheduling algorithms

- [Algorithm dispatcher](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/index.ts): `src/algorithms/index.ts`
- [FCFS scheduler](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/fcfs.ts): `src/algorithms/fcfs.ts`
- [SJF scheduler](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/sjf.ts): `src/algorithms/sjf.ts`
- [SRTF scheduler](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/srtf.ts): `src/algorithms/srtf.ts`
- [Round Robin scheduler](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/roundRobin.ts): `src/algorithms/roundRobin.ts`
- [Priority scheduler](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/algorithms/priority.ts): `src/algorithms/priority.ts`

### Results and display

- [Gantt chart](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/GanttChart.tsx): `src/components/GanttChart.tsx`
- [Metrics panel](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/MetricsPanel.tsx): `src/components/MetricsPanel.tsx`
- [Ready queue](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/components/ReadyQueue.tsx): `src/components/ReadyQueue.tsx`

### Shared logic

- [Input validation](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/utils/validation.ts): `src/utils/validation.ts`
- [Metrics calculation](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/utils/metrics.ts): `src/utils/metrics.ts`
- [Process colors](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/utils/colors.ts): `src/utils/colors.ts`
- [Scheduler data types](https://github.com/dhruvvit/cpu-scheduler/blob/main/src/types/scheduler.ts): `src/types/scheduler.ts`

### Other components

- **User**

## Connections

- User → Process inputs: edits processes (evidence: `src/components/ProcessTable.tsx`)
- User → Algorithm options: chooses options (evidence: `src/components/AlgorithmSelector.tsx`)
- Process inputs → Simulation app: updates inputs (evidence: `src/App.tsx`)
- Algorithm options → Simulation app: updates config (evidence: `src/App.tsx`)
- Simulation app → Input validation: validates inputs (evidence: `src/App.tsx`)
- Simulation app → Algorithm dispatcher: runs simulation (evidence: `src/App.tsx`)
- Algorithm dispatcher → FCFS scheduler: dispatches FCFS (evidence: `src/algorithms/index.ts`)
- Algorithm dispatcher → SJF scheduler: dispatches SJF (evidence: `src/algorithms/index.ts`)
- Algorithm dispatcher → SRTF scheduler: dispatches SRTF (evidence: `src/algorithms/index.ts`)
- Algorithm dispatcher → Round Robin scheduler: dispatches RR (evidence: `src/algorithms/index.ts`)
- Algorithm dispatcher → Priority scheduler: dispatches priority (evidence: `src/algorithms/index.ts`)
- Algorithm dispatcher → Metrics calculation: calculates metrics (evidence: `src/algorithms/index.ts`)
- Simulation app → Process inputs: renders inputs (evidence: `src/App.tsx`)
- Simulation app → Algorithm options: renders options (evidence: `src/App.tsx`)
- Simulation app → Gantt chart: renders schedule (evidence: `src/App.tsx`)
- Simulation app → Metrics panel: renders metrics (evidence: `src/App.tsx`)
- Simulation app → Ready queue: renders events (evidence: `src/App.tsx`)
- Gantt chart → Process colors: builds color map (evidence: `src/components/GanttChart.tsx`)
- Metrics panel → Process colors: builds color map (evidence: `src/components/MetricsPanel.tsx`)
- Ready queue → Process colors: uses process colors (evidence: `src/components/ReadyQueue.tsx`)
- Simulation app → Scheduler data types: uses data types (evidence: `src/App.tsx`)
- Algorithm dispatcher → Scheduler data types: uses data types (evidence: `src/algorithms/index.ts`)
- Metrics calculation → Scheduler data types: uses result types (evidence: `src/utils/metrics.ts`)
- Gantt chart → Scheduler data types: reads schedule types (evidence: `src/components/GanttChart.tsx`)
- Metrics panel → Scheduler data types: reads output types (evidence: `src/components/MetricsPanel.tsx`)
- Ready queue → Scheduler data types: reads event types (evidence: `src/components/ReadyQueue.tsx`)
