# chicagodave/fyrevmweb-react architecture

> Architecture diagram of the GitHub repository chicagodave/fyrevmweb-react, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chicagodave/fyrevmweb-react
- Repository: https://github.com/chicagodave/fyrevmweb-react

## Overview

##### Project Type and Purpose
- This is a **frontend-centric web application** platform for running Inform 7 interactive fiction stories in the browser.
- Core responsibilities:
- Hosting and rendering a compiled story file (.ulx)
- Wrapping and coordinating a Glulx interpreter (glulx-typescript)
- Managing VM memory (FyreVMMem)
- Presenting a React/semantic-UI user interface

##### Out the Major Code Areas (Top-Level Directories)
- **src/**
- FyreVMWeb wrapper & memory manager (src/FyreVMWeb)
- React components (src/components)
- Story templates (src/templates/standard)
- Entry point (src/index.js)
- **public/**
- index.html (loads the app)
- Sample compiled story (Cloak of Darkness.ulx)
- **extensions/** – optional Inform extensions (.i7x files)
- **projects/** – raw Inform source (.ni) for local compilation
- **Submodules** (via .gitmodules):
- glulx-typescript engine

##### Key Runtime Components
a. **Browser / Host Environment**
- Loads index.html + bundle.js (webpack or similar)
b. **FyreVMWeb Manager** (src/FyreVMWeb/FyreVMWeb.ts + .js)
- Initializes and orchestrates the Glulx interpreter
c. **Glulx-TypeScript Engine** (submodule)
- Executes the .ulx story bytecode
d. **FyreVM Memory Manager** (src/FyreVMWeb/FyreVMMem.ts)
- Provides custom memory allocation & inspection APIs
e. **UI Layer**
- React components (EmbeddedCommandLine, StatusLine, HintsStandard, etc.)
- Templates (Story.jsx) define layout & styling via semantic-UI
f. **Story Data**
- .ulx files served from public/ or fetched remotely

##### Relationships & Data Flows
- **Build & Deploy**
- npm scripts → install submodules → tsc compile → bundle → public assets
- **Startup**
1. index.html loads the JavaScript bundle
2. src/index.js boots React, uses Semantic UI theme
- **Story Loading**
1. Template component fetches .ulx (HTTP GET)
2. FyreVMWeb instantiates the interpreter with the fetched data
- **Execution Loop**
- UI → user inputs a command → command passed to FyreVMWeb
- FyreVMWeb → glulx-typescript executes instructions, reads/writes memory via FyreVMMem
- Execution events emit text, hints, status updates → React components render changes
- Loop continues until story end

##### Architectural Patterns & Principles
- **Layered Architecture**
- Presentation (React components & templates)
- Application façade (FyreVMWeb manager)
- Engine & runtime (glulx-typescript + memory manager)
- Data source (compiled story file)
- **Separation of Concerns**
- UI logic vs. VM orchestration vs. low-level execution
- **Extensibility Points**
- New React components (src/components)
- Create new story templates (src/templates/…)
- Plug in custom Inform extensions (extensions/*)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Browser / Host Environment
    subgraph "Browser / Host Environment"
        direction TB
        BrowserHTML["public/index.html"]:::external
    end

    %% Presentation Layer
    subgraph "Presentation Layer (React)" 
        direction TB
        Entry["src/index.js"]:::frontend
        StoryTemplate["Story Template (Story.jsx)"]:::frontend
        subgraph "React UI Components"
            direction TB
            ECLine["EmbeddedCommandLine"]:::frontend
            HelpStd["HelpStandard"]:::frontend
            HintsStd["HintsStandard"]:::frontend
            StatusLine["StandardStatusLine"]:::frontend
            Menu["StandardMenu"]:::frontend
            Paging["PagingContent"]:::frontend
            Scrolling["ScrollingContent"]:::frontend
            Title["StoryTitle"]:::frontend
        end
    end

    %% Application Façade
    subgraph "Application Façade (FyreVMWeb Manager)"
        direction TB
        VMTSrc["FyreVMWeb.ts"]:::appfacade
        VMTJS["FyreVMWeb.js"]:::appfacade
    end

    %% Engine & Memory
    subgraph "Engine & Runtime"
        direction TB
        Engine["glulx-typescript (submodule)"]:::engine
        Mem["FyreVMMem.ts"]:::engine
    end

    %% Data Sources
    subgraph "Data Sources"
        direction TB
        StoryFile["Cloak of Darkness.ulx"]:::data
        Extensions["extensions/*.i7x"]:::ext
        LocalSrc["projects/.../story.ni"]:::ext
    end

    %% Flows
    BrowserHTML -->|"loads"| Entry
    Entry -->|"boots React App"| StoryTemplate
    StoryTemplate -->|"renders UI"| ECLine
    StoryTemplate --> ECLine
    StoryTemplate --> HelpStd
    StoryTemplate --> HintsStd
    StoryTemplate --> StatusLine
    StoryTemplate --> Menu
    StoryTemplate --> Paging
    StoryTemplate --> Scrolling
    StoryTemplate --> Title

    StoryTemplate -->|"HTTP GET .ulx"| StoryFile
    StoryFile -->|"provides bytecode"| VMTSrc
    ECLine -->|"user command"| VMTSrc
    VMTSrc -->|"initialize interpreter"| Engine
    VMTSrc -->|"memory ops"| Mem
    Engine -->|"read/write"| Mem
    Engine -->|"execution events"| ECLine
    Engine -->|"execution events"| HelpStd
    Engine -->|"execution events"| StatusLine
    Engine -->|"execution events"| HintsStd
    Engine -->|"execution events"| Menu
    Engine -->|"execution events"| Paging
    Engine -->|"execution events"| Scrolling
    Engine -->|"execution events"| Title

    %% Click Events
    click BrowserHTML "https://github.com/chicagodave/fyrevmweb-react/blob/main/public/index.html"
    click Entry "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/index.js"
    click ECLine "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/components/EmbeddedCommandLine.js"
    click HelpStd "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/components/HelpStandard.js"
    click HintsStd "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/components/HintsStandard.js"
    click StatusLine "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/components/StandardStatusLine.js"
    click Menu "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/components/StandardMenu.js"
    click Paging "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/components/PagingContent.js"
    click Scrolling "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/components/ScrollingContent.js"
    click Title "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/components/StoryTitle.js"
    click StoryTemplate "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/templates/standard/Story.jsx"
    click VMTSrc "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/FyreVMWeb/FyreVMWeb.ts"
    click VMTJS "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/FyreVMWeb/FyreVMWeb.js"
    click Mem "https://github.com/chicagodave/fyrevmweb-react/blob/main/src/FyreVMWeb/FyreVMMem.ts"
    click Engine "https://github.com/chicagodave/fyrevmweb-react/tree/main/src/FyreVMWeb/glulx-typescript"
    click StoryFile "https://github.com/chicagodave/fyrevmweb-react/blob/main/public/Cloak of Darkness.ulx"
    click Extensions "https://github.com/chicagodave/fyrevmweb-react/tree/main/extensions"
    click LocalSrc "https://github.com/chicagodave/fyrevmweb-react/blob/main/projects/Cloak of Darkness.inform/Source/story.ni"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,stroke-width:1px
    classDef appfacade fill:#D5F5E3,stroke:#1D8348,stroke-width:1px
    classDef engine fill:#FCF3CF,stroke:#B7950B,stroke-width:1px
    classDef data fill:#FADBD8,stroke:#922B21,stroke-width:1px
    classDef ext fill:#E8DAEF,stroke:#6C3483,stroke-width:1px
    classDef external fill:#F2F3F4,stroke:#626567,stroke-width:1px,stroke-dasharray: 5 5
```
