# robertinglin/vertstack architecture

> Architecture diagram of the GitHub repository robertinglin/vertstack, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/robertinglin/vertstack
- Repository: https://github.com/robertinglin/vertstack

## Overview

##### Main Components

a) Core Framework Components:
- VertStack Server (Central Hub)
- WebSocket Manager
- Template Engine
- Static File Server
- Proxy Handler
- URL Rewriter
- Session Manager

b) Module Architecture:
- Module Container
- Client-Side Runtime
- Server-Side Runtime
- Message Bus System

- Client Browser                                         |

- Module 1     |  |   Module 2     |  |   Module 3     |   |   Module N     |        |
- (iframe-based) |  | (iframe-based) |  | (iframe-based) |   | (iframe-based) |        |

- ⇅

- WebSocket Layer                                        |

- ⇅

- VertStack Core Server                                     |

- Session Manager|  | Template Engine   |  | Static Server  |  | Message Bus       |   |

- URL Rewriter   |  | Proxy Handler     |  | Module Loader  |                         |

- ⇅

- Module Server Instances                                   |

- Module 1     |  |   Module 2     |  |   Module 3     |   |   Module N     |        |
- Server Runtime |  | Server Runtime |  | Server Runtime |   | Server Runtime |        |

##### Additional Details

- Annotations for key features like automatic iframe resizing
- Session management flow
- Proxy routing mechanisms
- Demonstrate template resolution paths

##### Implementation Notes

- Maintain consistent spacing and alignment
- Version information
- Notes for scaling considerations
- Document proxy configurations

##### Key Relationships to Highlight

- WebSocket connections between client modules and server
- Template inheritance and override patterns
- Static file serving paths
- Session management flow
- Cross-module communication patterns
- Proxy routing relationships

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Layer"
        IFrameManager["IFrame Manager"]:::client
        WebWorker["Web Worker"]:::client
        
        subgraph "Module IFrames"
            ChatFrame["Chat Module Frame"]:::client
            MainFrame["Main Module Frame"]:::client
            CounterFrame["Counter Module Frame"]:::client
            LoggerFrame["Logger Module Frame"]:::client
            NotifierFrame["Notifier Module Frame"]:::client
        end
        
        IFrameManager --> ChatFrame
        IFrameManager --> MainFrame
        IFrameManager --> CounterFrame
        IFrameManager --> LoggerFrame
        IFrameManager --> NotifierFrame
        
        WebWorker <--> ChatFrame
        WebWorker <--> MainFrame
        WebWorker <--> CounterFrame
        WebWorker <--> LoggerFrame
        WebWorker <--> NotifierFrame
    end

    subgraph "Communication Layer"
        direction TB
        MessageBus["Message Bus"]:::communication
        
        subgraph "Message Types"
            Vertical["Vertical (_prefix)"]:::msgtype
            Cross["Cross-channel (#prefix)"]:::msgtype
            Local["Local ($prefix)"]:::msgtype
            Global["Global (*prefix)"]:::msgtype
        end
    end

    subgraph "Server Layer"
        NodeSandbox["Node Sandbox Environment"]:::server
        WSServer["WebSocket Server"]:::server
        
        subgraph "Module Servers"
            ChatServer["Chat Server"]:::server
            MainServer["Main Server"]:::server
            CounterServer["Counter Server"]:::server
            LoggerServer["Logger Server"]:::server
            NotifierServer["Notifier Server"]:::server
        end
        
        NodeSandbox --> ChatServer
        NodeSandbox --> MainServer
        NodeSandbox --> CounterServer
        NodeSandbox --> LoggerServer
        NodeSandbox --> NotifierServer
        
        WSServer <--> NodeSandbox
    end

    WebWorker <--> MessageBus
    MessageBus <--> WSServer

    %% Click events for component mapping
    click ChatFrame "https://github.com/robertinglin/vertstack/blob/main/examples/chat/index.html"
    click ChatServer "https://github.com/robertinglin/vertstack/blob/main/examples/chat/server.mjs"
    click MainFrame "https://github.com/robertinglin/vertstack/blob/main/examples/messages/main/index.html"
    click MainServer "https://github.com/robertinglin/vertstack/blob/main/examples/messages/main/server.mjs"
    click CounterFrame "https://github.com/robertinglin/vertstack/blob/main/examples/messages/counter/index.html"
    click CounterServer "https://github.com/robertinglin/vertstack/blob/main/examples/messages/counter/server.mjs"
    click LoggerFrame "https://github.com/robertinglin/vertstack/blob/main/examples/messages/logger/index.html"
    click LoggerServer "https://github.com/robertinglin/vertstack/blob/main/examples/messages/logger/server.mjs"
    click NotifierFrame "https://github.com/robertinglin/vertstack/blob/main/examples/messages/notifier/index.html"
    click NotifierServer "https://github.com/robertinglin/vertstack/blob/main/examples/messages/notifier/server.mjs"
    click NodeSandbox "https://github.com/robertinglin/vertstack/blob/main/vertstack.js"
    click WSServer "https://github.com/robertinglin/vertstack/blob/main/vertstack.js"
    click WebWorker "https://github.com/robertinglin/vertstack/blob/main/vertstack.js"
    click IFrameManager "https://github.com/robertinglin/vertstack/blob/main/vertstack.js"

    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef communication fill:#f1c40f,stroke:#f39c12,color:black
    classDef msgtype fill:#e74c3c,stroke:#c0392b,color:white

    %% Legend
    subgraph Legend
        Client["Client Component"]:::client
        Server["Server Component"]:::server
        Comm["Communication"]:::communication
        MsgType["Message Type"]:::msgtype
    end
```
