# bbright99/hdl-studio-2 architecture

> Architecture diagram of the GitHub repository bbright99/hdl-studio-2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bbright99/hdl-studio-2
- Repository: https://github.com/bbright99/hdl-studio-2

## Overview

OMRANI HDL Studio is a browser-based HDL editing and digital-circuit simulation environment, with an Electron desktop shell offering native file access and external simulator support. The main workflow is to create or load a project, edit HDL, build it into diagnostics and modules, simulate it, then inspect the resulting waveform and console output. The excerpts establish several UI-to-library relationships, but omit parts of the main route and desktop bridge; uncertain links are left out or marked unverified.

Main entry points: [`src/routes/index.tsx`](https://github.com/bbright99/hdl-studio-2/blob/main/src/routes/index.tsx) (Studio workflow), [`src/lib/hdl/project.ts`](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/project.ts) (Project and build), [`src/lib/hdl/parser.ts`](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/parser.ts) (Verilog parser), [`src/components/studio/CodeEditor.tsx`](https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/CodeEditor.tsx) (HDL editor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_studio["Studio UI"]
  node_root["App shell<br/>[__root.tsx]"]
  node_studio_route["Studio workflow<br/>[index.tsx]"]
  node_editor["HDL editor<br/>[CodeEditor.tsx]"]
  node_explorer["Project explorer"]
  node_problems["Diagnostics panel<br/>[ProblemsPanel.tsx]"]
  node_console["Build console<br/>[ConsolePanel.tsx]"]
  node_waveform["Waveform viewer<br/>[WaveformViewer.tsx]"]
end

subgraph group_project["Project and Build"]
  node_project_model["Project and build<br/>[project.ts]"]
  node_templates["Project templates<br/>[templates.ts]"]
end

subgraph group_hdl["HDL Runtime"]
  node_parser["Verilog parser<br/>[parser.ts]"]
  node_lexer["HDL lexer<br/>[lexer.ts]"]
  node_ast["HDL syntax model<br/>[ast.ts]"]
  node_sim_engine["Built-in simulator<br/>[sim.ts]"]
  node_icarus["External simulation<br/>[icarus.ts]"]
  node_format["Waveform formatting<br/>[format.ts]"]
  node_highlight["Syntax highlighting<br/>[highlight.ts]"]
end

subgraph group_desktop["Desktop Integration"]
  node_desktop_shell["Electron shell<br/>[main.cjs]"]
  node_preload["Desktop bridge<br/>[preload.cjs]"]
end

node_user(("Engineer"))
node_local_storage[("Browser storage")]
node_native_files[("Native file system")]
node_simulators["Installed simulators"]

node_user -->|"uses"| node_studio_route
node_root -->|"renders"| node_studio_route
node_studio_route -->|"renders"| node_editor
node_studio_route -->|"renders"| node_explorer
node_studio_route -->|"renders"| node_problems
node_studio_route -->|"renders"| node_console
node_studio_route -->|"renders"| node_waveform
node_studio_route -->|"loads and saves"| node_project_model
node_project_model -->|"reads and writes"| node_local_storage
node_project_model -->|"creates from"| node_templates
node_explorer -->|"uses project helpers"| node_project_model
node_editor -->|"uses"| node_highlight
node_editor -->|"uses"| node_parser
node_project_model -->|"parses project files"| node_parser
node_parser -->|"tokenizes with"| node_lexer
node_parser -->|"produces syntax model"| node_ast
node_studio_route -.->|"simulates project"| node_sim_engine
node_studio_route -.->|"runs selected simulator"| node_icarus
node_icarus -.->|"invokes installed tools"| node_simulators
node_waveform -->|"formats values"| node_format
node_studio_route -.->|"uses desktop bridge"| node_desktop_shell
node_desktop_shell -.->|"exposes native features"| node_preload
node_preload -.->|"accesses files"| node_native_files

click node_root "https://github.com/bbright99/hdl-studio-2/blob/main/src/routes/__root.tsx"
click node_studio_route "https://github.com/bbright99/hdl-studio-2/blob/main/src/routes/index.tsx"
click node_editor "https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/CodeEditor.tsx"
click node_explorer "https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/ProjectExplorer.tsx"
click node_problems "https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/ProblemsPanel.tsx"
click node_console "https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/ConsolePanel.tsx"
click node_waveform "https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/WaveformViewer.tsx"
click node_project_model "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/project.ts"
click node_templates "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/templates.ts"
click node_parser "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/parser.ts"
click node_lexer "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/lexer.ts"
click node_ast "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/ast.ts"
click node_sim_engine "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/sim.ts"
click node_icarus "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/icarus.ts"
click node_format "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/format.ts"
click node_highlight "https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/highlight.ts"
click node_desktop_shell "https://github.com/bbright99/hdl-studio-2/blob/main/desktop/main.cjs"
click node_preload "https://github.com/bbright99/hdl-studio-2/blob/main/desktop/preload.cjs"

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_root,node_studio_route,node_editor,node_explorer,node_problems,node_console,node_waveform toneBlue
class node_project_model,node_templates,node_local_storage,node_native_files toneAmber
class node_parser,node_lexer,node_ast,node_sim_engine,node_icarus,node_format,node_highlight toneMint
class node_desktop_shell,node_preload toneRose
class node_user,node_simulators toneIndigo
```

## Components

### Studio UI

- [App shell](https://github.com/bbright99/hdl-studio-2/blob/main/src/routes/__root.tsx): `src/routes/__root.tsx`
- [Studio workflow](https://github.com/bbright99/hdl-studio-2/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [HDL editor](https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/CodeEditor.tsx): `src/components/studio/CodeEditor.tsx`
- [Project explorer](https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/ProjectExplorer.tsx): `src/components/studio/ProjectExplorer.tsx`
- [Diagnostics panel](https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/ProblemsPanel.tsx): `src/components/studio/ProblemsPanel.tsx`
- [Build console](https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/ConsolePanel.tsx): `src/components/studio/ConsolePanel.tsx`
- [Waveform viewer](https://github.com/bbright99/hdl-studio-2/blob/main/src/components/studio/WaveformViewer.tsx): `src/components/studio/WaveformViewer.tsx`

### Project and Build

- [Project and build](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/project.ts): `src/lib/hdl/project.ts`
- [Project templates](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/templates.ts): `src/lib/hdl/templates.ts`

### HDL Runtime

- [Verilog parser](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/parser.ts): `src/lib/hdl/parser.ts`
- [HDL lexer](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/lexer.ts): `src/lib/hdl/lexer.ts`
- [HDL syntax model](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/ast.ts): `src/lib/hdl/ast.ts`
- [Built-in simulator](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/sim.ts): `src/lib/hdl/sim.ts`
- [External simulation](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/icarus.ts): `src/lib/hdl/icarus.ts`
- [Waveform formatting](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/format.ts): `src/lib/hdl/format.ts`
- [Syntax highlighting](https://github.com/bbright99/hdl-studio-2/blob/main/src/lib/hdl/highlight.ts): `src/lib/hdl/highlight.ts`

### Desktop Integration

- [Electron shell](https://github.com/bbright99/hdl-studio-2/blob/main/desktop/main.cjs): `desktop/main.cjs`
- [Desktop bridge](https://github.com/bbright99/hdl-studio-2/blob/main/desktop/preload.cjs): `desktop/preload.cjs`

### Other components

- **Engineer**
- **Browser storage**
- **Native file system**
- **Installed simulators**

## Connections

- Engineer → Studio workflow: uses (evidence: `src/routes/index.tsx`)
- App shell → Studio workflow: renders
- Studio workflow → HDL editor: renders (evidence: `src/routes/index.tsx`)
- Studio workflow → Project explorer: renders (evidence: `src/routes/index.tsx`)
- Studio workflow → Diagnostics panel: renders (evidence: `src/routes/index.tsx`)
- Studio workflow → Build console: renders (evidence: `src/routes/index.tsx`)
- Studio workflow → Waveform viewer: renders (evidence: `src/routes/index.tsx`)
- Studio workflow → Project and build: loads and saves (evidence: `src/routes/index.tsx`)
- Project and build → Browser storage: reads and writes (evidence: `src/lib/hdl/project.ts`)
- Project and build → Project templates: creates from (evidence: `src/lib/hdl/project.ts`)
- Project explorer → Project and build: uses project helpers (evidence: `src/components/studio/ProjectExplorer.tsx`)
- HDL editor → Syntax highlighting: uses (evidence: `src/components/studio/CodeEditor.tsx`)
- HDL editor → Verilog parser: uses (evidence: `src/components/studio/CodeEditor.tsx`)
- Project and build → Verilog parser: parses project files (evidence: `src/lib/hdl/project.ts`)
- Verilog parser → HDL lexer: tokenizes with (evidence: `src/lib/hdl/parser.ts`)
- Verilog parser → HDL syntax model: produces syntax model (evidence: `src/lib/hdl/parser.ts`)
- Studio workflow → Built-in simulator: simulates project (evidence: `src/routes/index.tsx`)
- Studio workflow → External simulation: runs selected simulator (evidence: `src/routes/index.tsx`)
- External simulation → Installed simulators: invokes installed tools (evidence: `README.md`)
- Waveform viewer → Waveform formatting: formats values (evidence: `src/components/studio/WaveformViewer.tsx`)
- Studio workflow → Electron shell: uses desktop bridge (evidence: `README.md`)
- Electron shell → Desktop bridge: exposes native features (evidence: `README.md`)
- Desktop bridge → Native file system: accesses files (evidence: `README.md`)
