# jonathanvil/protocol-visualizer architecture

> Architecture diagram of the GitHub repository jonathanvil/protocol-visualizer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jonathanvil/protocol-visualizer
- Repository: https://github.com/jonathanvil/protocol-visualizer

## Overview

1. **Repository shape**
   - The repo is centered on a single application in `protocol-simulator/`, with supporting `docs/` and `demos/` at the root.
   - The root README is minimal, so the architecture is best inferred from the app’s file structure rather than from external documentation.

2. **Primary runtime: SvelteKit single-page simulator**
   - `protocol-simulator/` is a SvelteKit app built with Vite.
   - The browser is the main runtime for the simulator; there is no obvious database or external backend service in the tree.
   - `src/routes/+page.svelte` is the main entry screen, with `+page.server.js` likely responsible for initial loading of protocol content or configuration.

3. **Core domain: protocol execution and visualization**
   - The app is not a generic UI; it is a **distributed-protocol simulator/visualizer**.
   - The domain appears to model actors, messages, execution steps, and protocol-specific state.
   - The main visual output is a live graph/actor/message view rather than a traditional form-driven app.

4. **State management boundary**
   - `src/lib/stores.js` is the central application state boundary.
   - This likely coordinates simulation state across components: active protocol, actors, pending events/messages, logs, settings, and UI mode.
   - The store layer is the main data flow hub between the simulator engine and the Svelte components.

5. **Simulation engine and supporting data structures**
   - `src/lib/datastructures/Queue.js` and `PriorityQueue.js` indicate event/message scheduling semantics.
   - This suggests simulation steps are processed in ordered queues rather than directly in response to UI events.
   - The engine likely uses the priority queue for time- or priority-ordered events and the queue for FIFO message handling.

6. **Protocol definitions as external assets**
   - `src/protocols/*.txt` contains protocol definitions: `Default`, `Bully`, and `Ricart-Agrawala`.
   - These are likely the user-selectable protocol scenarios the simulator can load and visualize.
   - This is an important boundary: protocol logic is data-driven/configured from text assets instead of being hardcoded only in components.

7. **UI composition**
   - `src/lib/components/` contains the main presentation and interaction pieces:
     - `Graph.svelte` for actor/message topology visualization
     - `ControlsPanel.svelte`, `SettingsPanel.svelte` for simulation control and configuration
     - `EventLog.svelte` for execution history
     - `ManualMessageComponent.svelte`, `RunActorMethod.svelte`, `EditActorState.svelte` for interactive simulation actions
     - `DocumentationViewer.svelte`, `InfoToolTip.svelte` for in-app guidance
     - `NavigationBar.svelte`, `ProgressCircle.svelte`, `MonacoEditor.svelte`, and popper components for supporting UX
   - The UI is componentized around the simulation workflow, not around generic page sections.

8. **Main user flow**
   - A user likely loads a protocol, inspects the visual graph, triggers actor actions or manual messages, and watches the event log update.
   - The controls and editor components allow either stepping through or directly manipulating simulation state.
   - The graph, event log, and state editor are the three main synchronized views of the same underlying store.

9. **Static assets and documentation**
   - `docs/BASICS.md` and the root `demos/` HTML files appear to be supporting materials and standalone examples.
   - These are not core runtime subsystems, but they help explain or demonstrate the visualizer.
   - `src/lib/components/DocumentationViewer.svelte` suggests the app can surface documentation inside the UI itself.

10. **Build, packaging, and delivery**
   - The app includes `Dockerfile`, `package.json`, `bun.lock`, `package-lock.json`, and Svelte/Vite config files, showing it can be built in containerized or standard JS toolchains.
   - `.github/workflows/release.yml` indicates release automation.
   - This matters for architecture mainly as a deployment boundary: the simulator is packaged as a front-end artifact, not as a long-running server system.

11. **Likely component interaction model**
   - The store layer drives component rendering.
   - User actions in controls/editor components update stores.
   - Store updates feed the graph, log, and panels.
   - Protocol asset loading and initial page setup happen before the interactive simulation loop begins.

12. **Diagram boundaries to capture**
   - A useful architecture diagram should show:
     - **Protocol assets** (`src/protocols/*.txt`)
     - **Simulation/state core** (`stores.js`, queue structures, protocol logic)
     - **Presentation layer** (`components/`, `routes/+page.svelte`)
     - **Supporting docs/demo assets** (`docs/`, `demos/`)
     - **Build/deploy layer** (`SvelteKit/Vite`, Docker, GitHub Actions)
   - There is no evidence of a separate backend service or persistent datastore in this repository.

Main entry points: [`protocol-simulator/src/lib/stores.js`](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/stores.js) (App store), [`protocol-simulator/src/routes/+page.svelte`](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/routes/+page.svelte) (Main page), [`protocol-simulator/src/lib/index.js`](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/index.js) (Simulation engine), [`protocol-simulator/vite.config.js`](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/vite.config.js) (SvelteKit/Vite)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root["Repository"]
  node_repo_readme["Repo README<br/>overview<br/>[README.md]"]
  node_demo_vis["Demo visual"]
  node_demo_js["JS demo<br/>[js-test.html]"]
end

subgraph group_app["Simulator app"]
  node_page_shell["Main page<br/>svelte page<br/>[+page.svelte]"]
  node_page_loader["Page loader<br/>server load<br/>[+page.server.js]"]
end

subgraph group_ui["Presentation"]
  node_graph_view["Graph view<br/>svelte component<br/>[Graph.svelte]"]
  node_controls_panel["Controls<br/>svelte component"]
  node_settings_panel["Settings<br/>svelte component"]
  node_event_log["Event log<br/>svelte component<br/>[EventLog.svelte]"]
  node_manual_msg["Manual message<br/>svelte component"]
  node_run_method["Run actor<br/>svelte component"]
  node_edit_state["State editor<br/>svelte component"]
  node_docs_viewer["Docs viewer<br/>svelte component"]
  node_nav_bar["Navigation<br/>svelte component"]
end

subgraph group_core["State and engine"]
  node_store_core[("App store<br/>state store<br/>[stores.js]")]
  node_sim_engine["Simulation engine<br/>runtime<br/>[index.js]"]
  node_queue["Queue<br/>datastructure<br/>[Queue.js]"]
  node_pqueue["Priority queue<br/>datastructure<br/>[PriorityQueue.js]"]
  node_protocol_types["Types<br/>[types.js]"]
end

subgraph group_assets["Content assets"]
  node_docs_basics["Basics doc<br/>docs<br/>[BASICS.md]"]
  node_protocol_assets["Protocols<br/>scenario assets<br/>[Default.txt]"]
end

subgraph group_delivery["Build and release"]
  node_build_stack["SvelteKit/Vite<br/>build toolchain<br/>[vite.config.js]"]
  node_container["Docker<br/>delivery"]
  node_release_flow["Release workflow<br/>ci pipeline<br/>[release.yml]"]
end

node_page_loader -->|"loads"| node_protocol_assets
node_page_loader -->|"seeds"| node_store_core
node_page_shell -->|"binds"| node_store_core
node_page_shell -->|"contains"| node_nav_bar
node_page_shell -->|"renders"| node_graph_view
node_page_shell -->|"renders"| node_controls_panel
node_page_shell -->|"renders"| node_settings_panel
node_page_shell -->|"renders"| node_event_log
node_page_shell -->|"renders"| node_docs_viewer
node_controls_panel -->|"updates"| node_store_core
node_settings_panel -->|"configures"| node_store_core
node_manual_msg -->|"injects"| node_store_core
node_run_method -->|"drives"| node_store_core
node_edit_state -->|"edits"| node_store_core
node_graph_view -->|"subscribes"| node_store_core
node_event_log -->|"subscribes"| node_store_core
node_docs_viewer -->|"shows"| node_docs_basics
node_sim_engine -->|"uses"| node_queue
node_sim_engine -->|"uses"| node_pqueue
node_sim_engine -->|"shapes"| node_protocol_types
node_sim_engine -->|"publishes"| node_store_core
node_store_core -->|"loads"| node_protocol_assets
node_store_core -->|"coordinates"| node_sim_engine
node_build_stack -->|"builds"| node_page_shell
node_build_stack -->|"bundles"| node_sim_engine
node_container -->|"packages"| node_build_stack
node_release_flow -->|"publishes"| node_container
node_repo_readme -.->|"points to"| node_page_shell
node_demo_vis -.->|"demonstrates"| node_graph_view
node_demo_js -.->|"demonstrates"| node_sim_engine

click node_repo_readme "https://github.com/jonathanvil/protocol-visualizer/blob/main/README.md"
click node_docs_basics "https://github.com/jonathanvil/protocol-visualizer/blob/main/docs/BASICS.md"
click node_demo_vis "https://github.com/jonathanvil/protocol-visualizer/blob/main/demos/hardcoded-visualisation.html"
click node_demo_js "https://github.com/jonathanvil/protocol-visualizer/blob/main/demos/js-test.html"
click node_page_shell "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/routes/+page.svelte"
click node_page_loader "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/routes/+page.server.js"
click node_store_core "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/stores.js"
click node_sim_engine "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/index.js"
click node_queue "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/datastructures/Queue.js"
click node_pqueue "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/datastructures/PriorityQueue.js"
click node_protocol_types "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/types.js"
click node_protocol_assets "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/protocols/Default.txt"
click node_graph_view "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/Graph.svelte"
click node_controls_panel "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/ControlsPanel.svelte"
click node_settings_panel "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/SettingsPanel.svelte"
click node_event_log "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/EventLog.svelte"
click node_manual_msg "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/ManualMessageComponent.svelte"
click node_run_method "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/RunActorMethod.svelte"
click node_edit_state "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/EditActorState.svelte"
click node_docs_viewer "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/DocumentationViewer.svelte"
click node_nav_bar "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/NavigationBar.svelte"
click node_build_stack "https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/vite.config.js"
click node_container "https://github.com/jonathanvil/protocol-visualizer/tree/main/protocol-simulator/Dockerfile"
click node_release_flow "https://github.com/jonathanvil/protocol-visualizer/blob/main/.github/workflows/release.yml"

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_repo_readme,node_demo_vis,node_demo_js toneBlue
class node_page_shell,node_page_loader toneAmber
class node_graph_view,node_controls_panel,node_settings_panel,node_event_log,node_manual_msg,node_run_method,node_edit_state,node_docs_viewer,node_nav_bar toneMint
class node_store_core,node_sim_engine,node_queue,node_pqueue,node_protocol_types toneRose
class node_docs_basics,node_protocol_assets toneIndigo
class node_build_stack,node_container,node_release_flow toneTeal
```

## Components

### Repository

Top-level docs, demos, and package entry points

- [Repo README](https://github.com/jonathanvil/protocol-visualizer/blob/main/README.md): overview · Minimal top-level repository entry point · `README.md`
- [Demo visual](https://github.com/jonathanvil/protocol-visualizer/blob/main/demos/hardcoded-visualisation.html): demo · Standalone hardcoded visualization example · `demos/hardcoded-visualisation.html`
- [JS demo](https://github.com/jonathanvil/protocol-visualizer/blob/main/demos/js-test.html): demo · Standalone JavaScript test page · `demos/js-test.html`

### Simulator app

SvelteKit application for the protocol visualizer

- [Main page](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/routes/+page.svelte): svelte page · Primary interactive entry screen · `protocol-simulator/src/routes/+page.svelte`
- [Page loader](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/routes/+page.server.js): server load · Initial server-side loading for the page · `protocol-simulator/src/routes/+page.server.js`

### Presentation

Interactive components composing the simulator UI

- [Graph view](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/Graph.svelte): svelte component · Visualizes actors, messages, and topology · `protocol-simulator/src/lib/components/Graph.svelte`
- [Controls](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/ControlsPanel.svelte): svelte component · Primary simulation actions and stepping controls · `protocol-simulator/src/lib/components/ControlsPanel.svelte`
- [Settings](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/SettingsPanel.svelte): svelte component · Protocol and simulation configuration controls · `protocol-simulator/src/lib/components/SettingsPanel.svelte`
- [Event log](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/EventLog.svelte): svelte component · Chronological execution history and trace output · `protocol-simulator/src/lib/components/EventLog.svelte`
- [Manual message](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/ManualMessageComponent.svelte): svelte component · UI for injecting messages into the simulation · `protocol-simulator/src/lib/components/ManualMessageComponent.svelte`
- [Run actor](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/RunActorMethod.svelte): svelte component · Triggers actor methods during interactive runs · `protocol-simulator/src/lib/components/RunActorMethod.svelte`
- [State editor](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/EditActorState.svelte): svelte component · Edits actor or simulation state during debugging · `protocol-simulator/src/lib/components/EditActorState.svelte`
- [Docs viewer](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/DocumentationViewer.svelte): svelte component · Displays embedded documentation inside the app · `protocol-simulator/src/lib/components/DocumentationViewer.svelte`
- [Navigation](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/components/NavigationBar.svelte): svelte component · Top-level application navigation · `protocol-simulator/src/lib/components/NavigationBar.svelte`

### State and engine

Shared stores, scheduling, and simulation runtime

- [App store](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/stores.js): state store · Central shared state for the simulation · `protocol-simulator/src/lib/stores.js`
- [Simulation engine](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/index.js): runtime · Coordinates protocol execution and event progression · `protocol-simulator/src/lib/index.js`
- [Queue](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/datastructures/Queue.js): datastructure · FIFO scheduling support for simulation events · `protocol-simulator/src/lib/datastructures/Queue.js`
- [Priority queue](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/datastructures/PriorityQueue.js): datastructure · Ordered scheduling support for timed or prioritized events · `protocol-simulator/src/lib/datastructures/PriorityQueue.js`
- [Types](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/lib/types.js): domain types · Shared protocol and actor data shapes · `protocol-simulator/src/lib/types.js`

### Content assets

Protocol definitions and supporting documentation

- [Basics doc](https://github.com/jonathanvil/protocol-visualizer/blob/main/docs/BASICS.md): docs · Supporting documentation for using the simulator · `docs/BASICS.md`
- [Protocols](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/src/protocols/Default.txt): scenario assets · Selectable protocol definitions used by the simulator · `protocol-simulator/src/protocols/Default.txt`

### Build and release

Packaging and automation for delivery

- [SvelteKit/Vite](https://github.com/jonathanvil/protocol-visualizer/blob/main/protocol-simulator/vite.config.js): build toolchain · Frontend build and development pipeline · `protocol-simulator/vite.config.js`
- [Docker](https://github.com/jonathanvil/protocol-visualizer/tree/main/protocol-simulator/Dockerfile): delivery · Container packaging for the simulator · `protocol-simulator/Dockerfile`
- [Release workflow](https://github.com/jonathanvil/protocol-visualizer/blob/main/.github/workflows/release.yml): ci pipeline · Automated release process · `.github/workflows/release.yml`

## Connections

- Page loader → Protocols: loads · Selects protocol scenario content during initial page setup
- Page loader → App store: seeds · Initializes shared simulation state
- Main page → App store: binds · Renders against the shared state store
- Main page → Navigation: contains · Composes the top-level navigation
- Main page → Graph view: renders · Main visualization surface
- Main page → Controls: renders · Primary action surface
- Main page → Settings: renders · Configuration surface
- Main page → Event log: renders · Execution trace surface
- Main page → Docs viewer: renders · In-app documentation surface
- Controls → App store: updates · User actions drive state changes
- Settings → App store: configures · Updates simulation parameters
- Manual message → App store: injects · Adds externally triggered messages
- Run actor → App store: drives · Invokes actor behavior through the store
- State editor → App store: edits · Mutates actor or simulation state
- Graph view → App store: subscribes · Visualizes current simulation state
- Event log → App store: subscribes · Shows execution history from state
- Docs viewer → Basics doc: shows · Surfaces repository guidance in the UI
- Simulation engine → Queue: uses · FIFO event handling
- Simulation engine → Priority queue: uses · Ordered event handling
- Simulation engine → Types: shapes · Operates on shared protocol data structures
- Simulation engine → App store: publishes · Writes execution results into shared state
- App store → Protocols: loads · Holds the active protocol scenario
- App store → Simulation engine: coordinates · Controls stepping and execution flow
- SvelteKit/Vite → Main page: builds · Compiles the SvelteKit application
- SvelteKit/Vite → Simulation engine: bundles · Includes the simulator runtime code
- Docker → SvelteKit/Vite: packages · Containerizes the frontend build
- Release workflow → Docker: publishes · Automates release delivery
- Repo README → Main page: points to · Top-level README leads into the simulator app
- Demo visual → Graph view: demonstrates · Standalone visualization example relates to the main graph UI
- JS demo → Simulation engine: demonstrates · Standalone JS example relates to simulation behavior
