# netxspider/real-time-multi-threaded-application-simulator architecture

> Architecture diagram of the GitHub repository netxspider/real-time-multi-threaded-application-simulator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/netxspider/real-time-multi-threaded-application-simulator
- Repository: https://github.com/netxspider/real-time-multi-threaded-application-simulator

## Overview

1. **What this repo is**
   - A browser-only React simulator for operating-system thread scheduling, plus a separate thread-synchronization simulator.
   - There is no backend, no database, and no Web Workers; the whole app runs in the client and advances by ticks.

2. **Top-level application shape**
   - `src/main.jsx` boots the app into the Vite-generated `index.html`.
   - `src/App.jsx` appears to assemble the main dashboard layout, which the README describes as a three-column simulator UI with controls on the left, visualizations in the center, and metrics on the right.
   - `src/pages/SyncSimulatorPage.jsx` is the page-level entry for the synchronization simulator flow.

3. **Core architectural boundary: state vs. engine**
   - The central boundary is between UI components and the simulation engine.
   - UI writes user configuration into Zustand stores; the engine consumes that state and produces the next simulation tick and derived metrics.
   - This keeps the simulation deterministic and easy to replay or inspect.

4. **Simulation state stores**
   - `src/store/simulationStore.js` is the main state container for scheduling: thread definitions, current tick, running/ready queues, logs, speed, algorithm choice, and results.
   - `src/store/syncStore.js` holds state for the synchronization simulator.
   - `src/store/navStore.js` likely manages navigation between simulator sections/pages.

5. **Scheduling engine**
   - `src/engine/scheduler.js` contains the pure scheduling logic for FCFS, SJF, Round Robin, SRTF, and Priority.
   - `src/engine/gameLoop.js` drives the main scheduler forward on a timer, likely using `setInterval` with a speed multiplier.
   - `src/engine/threadModel.js` computes the user-thread to kernel-thread mapping used by the thread-model visualization.
   - `src/engine/syncGameLoop.js` is the parallel tick loop for the synchronization simulator.

6. **Main data flow**
   - User edits configuration in the control panel.
   - The store updates thread inputs and algorithm settings.
   - The game loop calls into the scheduler each tick.
   - The scheduler updates thread states, queue order, CPU assignment, and metrics.
   - Those updates propagate to charts, tables, logs, and the results modal.

7. **Scheduling dashboard UI**
   - `src/components/controls/ControlPanel.jsx` is the main entry for algorithm selection, speed control, and thread configuration.
   - `ThreadConfigModal.jsx` handles per-thread arrival, burst, and priority editing.
   - `src/components/scheduling/GanttChart.jsx` renders the timeline of CPU occupancy.
   - `ReadyQueuePanel.jsx` shows the live running thread, ready queue, and arriving threads.

8. **Visual explanation layer**
   - `src/components/visualization/ThreadMapper.jsx` is the thread-model diagram, showing user threads mapped to kernel threads and then to the CPU.
   - `StateLegend.jsx` explains state colors and is part of the simulator’s visual language.
   - These are presentation components fed by simulation state, not independent logic.

9. **Metrics and observability**
   - `src/components/metrics/RightSidebar.jsx` is the dashboard wrapper for live metrics.
   - `CpuUtilChart.jsx` and `ThreadStateChart.jsx` visualize runtime trends with Recharts.
   - `ThreadTable.jsx` presents per-thread live status.
   - `LogConsole.jsx` and `ToastNotification.jsx` provide event feedback and simulator messages.
   - `ResultsModal.jsx` is the post-run summary with per-thread and aggregate scheduling metrics.

10. **Synchronization simulator subsystem**
   - The `src/components/sync/` folder indicates a separate educational module for synchronization concepts.
   - `SyncLeftPanel.jsx`, `SyncCenterPanel.jsx`, and `SyncRightPanel.jsx` suggest a three-panel layout similar to the main scheduler UI.
   - This subsystem is isolated from the scheduling simulator by its own store and loop, which helps keep the two simulations conceptually separate.

11. **Styling and rendering approach**
   - The project uses Tailwind CSS v4 plus local CSS files like `src/index.css` and `src/App.css` for the overall dark-dashboard look and animations.
   - The key visuals, especially the thread mapper and Gantt chart, are SVG-based rather than relying on a diagramming library.
   - Recharts is used only for chart components where standard chart primitives are sufficient.

12. **Tooling and runtime**
   - Vite is the build/dev runtime, which makes this a modern SPA rather than a server-rendered app.
   - ESLint is present for code quality, and `package-lock.json` shows npm-managed dependencies.
   - External libraries that materially affect architecture are React 19, Zustand, Recharts, and Lucide React.

Main entry points: [`src/store/simulationStore.js`](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/store/simulationStore.js) (Sim store), [`src/App.jsx`](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/App.jsx) (Dashboard), [`src/components/metrics/RightSidebar.jsx`](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/RightSidebar.jsx) (Metrics sidebar), [`src/components/sync/SyncLeftPanel.jsx`](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/sync/SyncLeftPanel.jsx) (Sync panels)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_shell["App shell"]
  node_node_main["Main entry<br/>React boot<br/>[main.jsx]"]
  node_node_app["Dashboard<br/>layout shell<br/>[App.jsx]"]
  node_node_styles["Styles<br/>global styling<br/>[App.css]"]
end

subgraph group_group_sched["Scheduling simulator"]
  node_node_scheduler["Scheduler<br/>policy engine<br/>[scheduler.js]"]
  node_node_gameloop["Game loop<br/>tick driver<br/>[gameLoop.js]"]
  node_node_threadmodel["Thread model<br/>mapping engine<br/>[threadModel.js]"]
  node_node_controlpanel["Controls<br/>input panel<br/>[ControlPanel.jsx]"]
  node_node_threadconfig["Thread editor<br/>modal editor"]
  node_node_gantt["Gantt chart<br/>timeline view<br/>[GanttChart.jsx]"]
  node_node_readyqueue["Queue panel<br/>live view"]
  node_node_mapper["Thread mapper<br/>diagram view<br/>[ThreadMapper.jsx]"]
  node_node_legend["State legend<br/>[StateLegend.jsx]"]
  node_node_metrics["Metrics sidebar<br/>dashboard panel<br/>[RightSidebar.jsx]"]
  node_node_cpuchart["CPU chart<br/>recharts chart<br/>[CpuUtilChart.jsx]"]
  node_node_statechart["State chart<br/>recharts chart"]
  node_node_threadtable["Thread table<br/>status table<br/>[ThreadTable.jsx]"]
  node_node_logconsole["Log console<br/>event console<br/>[LogConsole.jsx]"]
  node_node_resultmodal["Results modal<br/>summary modal<br/>[ResultsModal.jsx]"]
end

subgraph group_group_sync["Sync simulator"]
  node_node_syncloop["Sync loop<br/>tick driver<br/>[syncGameLoop.js]"]
  node_node_syncpage["Sync page<br/>page shell"]
  node_node_syncui["Sync panels<br/>three-panel UI<br/>[SyncLeftPanel.jsx]"]
  node_node_synccenter["Sync center<br/>panel"]
  node_node_syncright["Sync right<br/>panel<br/>[SyncRightPanel.jsx]"]
end

subgraph group_group_shared["Shared state"]
  node_node_simstore[("Sim store<br/>Zustand store<br/>[simulationStore.js]")]
  node_node_syncstore[("Sync store<br/>Zustand store<br/>[syncStore.js]")]
  node_node_navstore[("Nav store<br/>Zustand store<br/>[navStore.js]")]
end

node_node_main -->|"boots"| node_node_app
node_node_app -->|"layout"| node_node_controlpanel
node_node_app -->|"layout"| node_node_gantt
node_node_app -->|"layout"| node_node_metrics
node_node_app -->|"navigates"| node_node_syncpage
node_node_controlpanel -->|"writes"| node_node_simstore
node_node_threadconfig -->|"edits"| node_node_simstore
node_node_simstore -->|"drives"| node_node_gameloop
node_node_gameloop -->|"ticks"| node_node_scheduler
node_node_scheduler -->|"updates"| node_node_simstore
node_node_scheduler -->|"summarizes"| node_node_resultmodal
node_node_simstore -->|"feeds"| node_node_gantt
node_node_simstore -->|"feeds"| node_node_readyqueue
node_node_simstore -->|"feeds"| node_node_mapper
node_node_threadmodel -->|"renders"| node_node_mapper
node_node_simstore -->|"feeds"| node_node_legend
node_node_simstore -->|"feeds"| node_node_metrics
node_node_metrics -->|"contains"| node_node_cpuchart
node_node_metrics -->|"contains"| node_node_statechart
node_node_metrics -->|"contains"| node_node_threadtable
node_node_metrics -->|"contains"| node_node_logconsole
node_node_simstore -->|"feeds"| node_node_resultmodal
node_node_navstore -->|"controls"| node_node_app
node_node_syncpage -->|"assembles"| node_node_syncui
node_node_syncpage -->|"uses"| node_node_syncstore
node_node_syncstore -->|"drives"| node_node_syncloop
node_node_syncloop -->|"updates"| node_node_syncstore
node_node_syncui -->|"contains"| node_node_synccenter
node_node_syncui -->|"contains"| node_node_syncright
node_node_styles -->|"styles"| node_node_app
node_node_styles -->|"styles"| node_node_syncui

click node_node_main "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/main.jsx"
click node_node_app "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/App.jsx"
click node_node_simstore "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/store/simulationStore.js"
click node_node_syncstore "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/store/syncStore.js"
click node_node_navstore "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/store/navStore.js"
click node_node_scheduler "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/engine/scheduler.js"
click node_node_gameloop "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/engine/gameLoop.js"
click node_node_threadmodel "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/engine/threadModel.js"
click node_node_controlpanel "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/controls/ControlPanel.jsx"
click node_node_threadconfig "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/controls/ThreadConfigModal.jsx"
click node_node_gantt "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/scheduling/GanttChart.jsx"
click node_node_readyqueue "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/scheduling/ReadyQueuePanel.jsx"
click node_node_mapper "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/visualization/ThreadMapper.jsx"
click node_node_legend "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/visualization/StateLegend.jsx"
click node_node_metrics "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/RightSidebar.jsx"
click node_node_cpuchart "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/CpuUtilChart.jsx"
click node_node_statechart "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/ThreadStateChart.jsx"
click node_node_threadtable "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/ThreadTable.jsx"
click node_node_logconsole "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/LogConsole.jsx"
click node_node_resultmodal "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/ResultsModal.jsx"
click node_node_syncloop "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/engine/syncGameLoop.js"
click node_node_syncpage "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/pages/SyncSimulatorPage.jsx"
click node_node_syncui "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/sync/SyncLeftPanel.jsx"
click node_node_synccenter "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/sync/SyncCenterPanel.jsx"
click node_node_syncright "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/sync/SyncRightPanel.jsx"
click node_node_styles "https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/App.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_node_main,node_node_app,node_node_styles toneBlue
class node_node_scheduler,node_node_gameloop,node_node_threadmodel,node_node_controlpanel,node_node_threadconfig,node_node_gantt,node_node_readyqueue,node_node_mapper,node_node_legend,node_node_metrics,node_node_cpuchart,node_node_statechart,node_node_threadtable,node_node_logconsole,node_node_resultmodal toneAmber
class node_node_syncloop,node_node_syncpage,node_node_syncui,node_node_synccenter,node_node_syncright toneMint
class node_node_simstore,node_node_syncstore,node_node_navstore toneRose
```

## Components

### App shell

Vite/React entry and global layout

- [Main entry](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/main.jsx): React boot · Bootstraps the SPA into the Vite index page · `src/main.jsx`
- [Dashboard](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/App.jsx): layout shell · Assembles the main simulator layout and routes UI regions · `src/App.jsx`
- [Styles](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/App.css): global styling · Global CSS and dashboard theming · `src/App.css`

### Scheduling simulator

Main OS thread scheduling simulation

- [Scheduler](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/engine/scheduler.js): policy engine · Pure tick-level scheduling logic for FCFS, SJF, RR, SRTF, and Priority · `src/engine/scheduler.js`
- [Game loop](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/engine/gameLoop.js): tick driver · Advances the scheduling simulation over time · `src/engine/gameLoop.js`
- [Thread model](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/engine/threadModel.js): mapping engine · Computes user-thread to kernel-thread mapping for visualization · `src/engine/threadModel.js`
- [Controls](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/controls/ControlPanel.jsx): input panel · Algorithm selection, speed control, and thread configuration entry point · `src/components/controls/ControlPanel.jsx`
- [Thread editor](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/controls/ThreadConfigModal.jsx): modal editor · Edits per-thread arrival, burst, and priority values · `src/components/controls/ThreadConfigModal.jsx`
- [Gantt chart](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/scheduling/GanttChart.jsx): timeline view · Renders CPU occupancy over time · `src/components/scheduling/GanttChart.jsx`
- [Queue panel](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/scheduling/ReadyQueuePanel.jsx): live view · Shows running thread, ready queue, and arrivals · `src/components/scheduling/ReadyQueuePanel.jsx`
- [Thread mapper](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/visualization/ThreadMapper.jsx): diagram view · Shows user threads mapped to kernel threads and CPU · `src/components/visualization/ThreadMapper.jsx`
- [State legend](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/visualization/StateLegend.jsx): legend · Explains simulator state colors and symbols · `src/components/visualization/StateLegend.jsx`
- [Metrics sidebar](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/RightSidebar.jsx): dashboard panel · Wraps the live metrics and observability views · `src/components/metrics/RightSidebar.jsx`
- [CPU chart](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/CpuUtilChart.jsx): recharts chart · Visualizes CPU utilization trends · `src/components/metrics/CpuUtilChart.jsx`
- [State chart](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/ThreadStateChart.jsx): recharts chart · Visualizes thread state trends over time · `src/components/metrics/ThreadStateChart.jsx`
- [Thread table](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/ThreadTable.jsx): status table · Shows per-thread live status and metrics · `src/components/metrics/ThreadTable.jsx`
- [Log console](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/LogConsole.jsx): event console · Displays simulator events and messages · `src/components/metrics/LogConsole.jsx`
- [Results modal](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/metrics/ResultsModal.jsx): summary modal · Summarizes per-thread and aggregate scheduling results · `src/components/metrics/ResultsModal.jsx`

### Sync simulator

Thread synchronization simulation

- [Sync loop](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/engine/syncGameLoop.js): tick driver · Advances the synchronization simulator over time · `src/engine/syncGameLoop.js`
- [Sync page](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/pages/SyncSimulatorPage.jsx): page shell · Page-level entry for the synchronization simulator · `src/pages/SyncSimulatorPage.jsx`
- [Sync panels](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/sync/SyncLeftPanel.jsx): three-panel UI · Layout for the synchronization simulator controls, center view, and output · `src/components/sync/SyncLeftPanel.jsx`
- [Sync center](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/sync/SyncCenterPanel.jsx): panel · Central synchronization simulator view · `src/components/sync/SyncCenterPanel.jsx`
- [Sync right](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/components/sync/SyncRightPanel.jsx): panel · Right-side synchronization outputs and metrics · `src/components/sync/SyncRightPanel.jsx`

### Shared state

Cross-cutting client state and navigation

- [Sim store](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/store/simulationStore.js): Zustand store · Holds scheduling simulation state, queues, speed, logs, and results · `src/store/simulationStore.js`
- [Sync store](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/store/syncStore.js): Zustand store · Holds state for the synchronization simulator · `src/store/syncStore.js`
- [Nav store](https://github.com/netxspider/real-time-multi-threaded-application-simulator/blob/main/src/store/navStore.js): Zustand store · Tracks navigation between simulator sections and pages · `src/store/navStore.js`

## Connections

- Main entry → Dashboard: boots · Entry point mounts the root React application
- Dashboard → Controls: layout · Places simulator controls in the left column
- Dashboard → Gantt chart: layout · Places the timeline visualization in the center column
- Dashboard → Metrics sidebar: layout · Places live metrics in the right column
- Dashboard → Sync page: navigates · Can route to the separate synchronization simulator page
- Controls → Sim store: writes · Updates algorithm, speed, and thread inputs
- Thread editor → Sim store: edits · Commits per-thread configuration into the simulation store
- Sim store → Game loop: drives · Provides state and settings to the main tick loop
- Game loop → Scheduler: ticks · Invokes scheduling logic each simulation step
- Scheduler → Sim store: updates · Writes thread state, queue order, CPU assignment, and metrics
- Scheduler → Results modal: summarizes · Produces final results for the run summary
- Sim store → Gantt chart: feeds · Supplies timeline data for rendering
- Sim store → Queue panel: feeds · Supplies live queue and running-thread state
- Sim store → Thread mapper: feeds · Supplies thread-model data for the mapping diagram
- Thread model → Thread mapper: renders · Generates mapping relationships for the visualization
- Sim store → State legend: feeds · Provides state palette and labels to the legend
- Sim store → Metrics sidebar: feeds · Supplies live data to the metrics sidebar
- Metrics sidebar → CPU chart: contains · Hosts CPU utilization chart
- Metrics sidebar → State chart: contains · Hosts thread-state trend chart
- Metrics sidebar → Thread table: contains · Hosts per-thread status table
- Metrics sidebar → Log console: contains · Hosts event log console
- Sim store → Results modal: feeds · Provides aggregate and per-thread results
- Nav store → Dashboard: controls · Supports page and section navigation
- Sync page → Sync panels: assembles · Builds the synchronization simulator layout
- Sync page → Sync store: uses · Reads and writes sync simulation state
- Sync store → Sync loop: drives · Provides state and settings to the sync tick loop
- Sync loop → Sync store: updates · Advances sync state over time
- Sync panels → Sync center: contains · Central panel for sync visualization
- Sync panels → Sync right: contains · Right panel for sync output and metrics
- Styles → Dashboard: styles · Provides the global dashboard look and feel
- Styles → Sync panels: styles · Provides styling for the synchronization layout
