How jonathanvil/protocol-visualizer works
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: stores.js App store · +page.svelte Main page · index.js Simulation engine · vite.config.js SvelteKit/Vite
Components 24
Repository
Top-level docs, demos, and package entry points
- Repo README · Minimal top-level repository entry point
README.md - Demo visual · Standalone hardcoded visualization example
demos/hardcoded-visualisation.html - JS demo · Standalone JavaScript test page
demos/js-test.html
Simulator app
SvelteKit application for the protocol visualizer
- Main page · Primary interactive entry screen
protocol-simulator/src/routes/+page.svelte - Page loader · Initial server-side loading for the page
protocol-simulator/src/routes/+page.server.js
Presentation
Interactive components composing the simulator UI
- Graph view · Visualizes actors, messages, and topology
protocol-simulator/src/lib/components/Graph.svelte - Controls · Primary simulation actions and stepping controls
protocol-simulator/src/lib/components/ControlsPanel.svelte - Settings · Protocol and simulation configuration controls
protocol-simulator/src/lib/components/SettingsPanel.svelte - Event log · Chronological execution history and trace output
protocol-simulator/src/lib/components/EventLog.svelte - Manual message · UI for injecting messages into the simulation
protocol-simulator/src/lib/components/ManualMessageComponent.svelte - Run actor · Triggers actor methods during interactive runs
protocol-simulator/src/lib/components/RunActorMethod.svelte - State editor · Edits actor or simulation state during debugging
protocol-simulator/src/lib/components/EditActorState.svelte - Docs viewer · Displays embedded documentation inside the app
protocol-simulator/src/lib/components/DocumentationViewer.svelte - Navigation · Top-level application navigation
protocol-simulator/src/lib/components/NavigationBar.svelte
State and engine
Shared stores, scheduling, and simulation runtime
- App store · Central shared state for the simulation
protocol-simulator/src/lib/stores.js - Simulation engine · Coordinates protocol execution and event progression
protocol-simulator/src/lib/index.js - Queue · FIFO scheduling support for simulation events
protocol-simulator/src/lib/datastructures/Queue.js - Priority queue · Ordered scheduling support for timed or prioritized events
protocol-simulator/src/lib/datastructures/PriorityQueue.js - Types · Shared protocol and actor data shapes
protocol-simulator/src/lib/types.js
Content assets
Protocol definitions and supporting documentation
- Basics doc · Supporting documentation for using the simulator
docs/BASICS.md - Protocols · Selectable protocol definitions used by the simulator
protocol-simulator/src/protocols/Default.txt
Build and release
Packaging and automation for delivery
- SvelteKit/Vite · Frontend build and development pipeline
protocol-simulator/vite.config.js - Docker · Container packaging for the simulator
protocol-simulator/Dockerfile - Release workflow · Automated release process
.github/workflows/release.yml
Connections 30
- 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