# fazzone/structural-demo architecture

> Architecture diagram of the GitHub repository fazzone/structural-demo, 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/fazzone/structural-demo
- Repository: https://github.com/fazzone/structural-demo

## Overview

##### Project Type Analysis
This is a web-based structural editor with both browser and Electron support, built primarily in Clojure/ClojureScript. The project appears to follow a component-based architecture with several distinct subsystems.

##### Main Components

A. Core Application Layer:
- Core Engine (`src/sted/core.cljc`)
- Schema System (`src/sted/schema.cljc`)
- Command System (`src/sted/cmd/*`)

B. UI Component Layer:
- Root Component (`src/sted/comp/root.cljc`)
- Various UI Components (`src/sted/comp/*`)
- Document Components (`src/sted/comp/doc.cljc`)

C. System Services:
- Keyboard System (`src/sted/sys/keyboard.cljs`)
- Mouse System (`src/sted/sys/mouse.cljs`)
- Search System (`src/sted/sys/search/*`)
- Evaluation System (`src/sted/sys/eval/*`)

D. Platform-specific Components:
- Electron Main Process (`src/sted/electron_main.cljs`)
- Browser Entry Point (`src/sted/page.cljs`)

E. Data Flow System:
- Reactive Database (`src/sted/db_reactive.cljs`)
- Data Format Handlers (`src/sted/df/*`)

**┌─────────────────────────────────────────────┐**
- Client Layer                 │
- ┌─────────────┐        ┌──────────────┐    │
- Browser   │        │   Electron   │    │
- ┘        └──────────────┘    │
- ┤
- Component Layer                 │
- ┌─────────────┐        ┌──────────────┐    │
- UI       │        │   Editor     │    │
- Components  │◄─────► │  Components  │    │
- ┘        └──────────────┘    │
- ┤
- System Services                 │
- ┌─────────┐  ┌────────┐  ┌────────────┐   │
- Keyboard │  │ Mouse  │  │  Search    │   │
- System  │  │ System │  │  System    │   │
- ┘  └────────┘  └────────────┘   │
- ┤
- Core Services                   │
- ┌─────────┐  ┌────────┐  ┌────────────┐   │
- Schema   │  │Command │  │  Reactive  │   │
- System   │  │System  │  │    DB      │   │
- ┘  └────────┘  └────────────┘   │
- ┘

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef client fill:#a8d1f0
    classDef component fill:#90EE90
    classDef system fill:#FFB347
    classDef core fill:#DDA0DD
    classDef db fill:#B19CD9,stroke:#333
    
    %% Client Layer
    subgraph ClientLayer
        Browser["Browser Entry"]:::client
        Electron["Electron Main"]:::client
    end

    %% Component Layer
    subgraph ComponentLayer
        Root["Root Component"]:::component
        Doc["Document Component"]:::component
        Code["Code Component"]:::component
        SearchComp["Search Component"]:::component
        Debug["Debug Component"]:::component
    end

    %% System Services Layer
    subgraph SystemLayer
        KbdSystem["Keyboard System"]:::system
        MouseSystem["Mouse System"]:::system
        SearchSystem["Search System"]:::system
        EvalSystem["Evaluation System"]:::system
        KbdMap["Keyboard Mapping"]:::system
        KbdEvents["Keyboard Events"]:::system
        SearchDB["Search Database"]:::system
        SearchDOM["Search DOM"]:::system
    end

    %% Core Layer
    subgraph CoreLayer
        CoreEngine["Core Engine"]:::core
        SchemaSystem["Schema System"]:::core
        CmdSystem["Command System"]:::core
        EditCmd["Edit Commands"]:::core
        NavCmd["Navigation Commands"]:::core
        MutCmd["Mutation Commands"]:::core
    end

    %% Data Flow Layer
    subgraph DataLayer
        ReactiveDB[(Reactive Database)]:::db
        DFHandlers["Data Format Handlers"]:::core
        AsyncHandler["Async Handler"]:::core
        GitHubHandler["GitHub Handler"]:::core
    end

    %% Additional Systems
    subgraph AdditionalSystems
        EmbedSystem["Embedding System"]:::system
        NREPLSystem["nREPL System"]:::system
    end

    %% Relationships
    Browser --> Root
    Electron --> Root
    Root --> Doc
    Root --> Code
    Root --> SearchComp
    Root --> Debug
    
    KbdSystem --> KbdMap
    KbdSystem --> KbdEvents
    SearchSystem --> SearchDB
    SearchSystem --> SearchDOM
    
    CmdSystem --> EditCmd
    CmdSystem --> NavCmd
    CmdSystem --> MutCmd
    
    DFHandlers --> AsyncHandler
    DFHandlers --> GitHubHandler

    %% Core Interactions
    CoreEngine --> SchemaSystem
    CoreEngine --> CmdSystem
    CoreEngine --> ReactiveDB
    
    %% System Interactions
    KbdSystem --> CoreEngine
    MouseSystem --> CoreEngine
    SearchSystem --> CoreEngine
    EvalSystem --> CoreEngine

    %% Click Events
    click Browser "https://github.com/fazzone/structural-demo/blob/master/src/sted/page.cljs"
    click Electron "https://github.com/fazzone/structural-demo/blob/master/src/sted/electron_main.cljs"
    click Root "https://github.com/fazzone/structural-demo/blob/master/src/sted/comp/root.cljc"
    click Doc "https://github.com/fazzone/structural-demo/blob/master/src/sted/comp/doc.cljc"
    click Code "https://github.com/fazzone/structural-demo/blob/master/src/sted/comp/code.cljc"
    click SearchComp "https://github.com/fazzone/structural-demo/blob/master/src/sted/comp/search.cljc"
    click Debug "https://github.com/fazzone/structural-demo/blob/master/src/sted/comp/debug.cljc"
    click KbdSystem "https://github.com/fazzone/structural-demo/blob/master/src/sted/sys/keyboard.cljs"
    click MouseSystem "https://github.com/fazzone/structural-demo/blob/master/src/sted/sys/mouse.cljs"
    click KbdMap "https://github.com/fazzone/structural-demo/blob/master/src/sted/sys/kbd/map.cljc"
    click KbdEvents "https://github.com/fazzone/structural-demo/blob/master/src/sted/sys/kbd/evt.cljs"
    click SearchDB "https://github.com/fazzone/structural-demo/blob/master/src/sted/sys/search/db.cljc"
    click SearchDOM "https://github.com/fazzone/structural-demo/blob/master/src/sted/sys/search/dom.cljs"
    click CoreEngine "https://github.com/fazzone/structural-demo/blob/master/src/sted/core.cljc"
    click SchemaSystem "https://github.com/fazzone/structural-demo/blob/master/src/sted/schema.cljc"
    click CmdSystem "https://github.com/fazzone/structural-demo/tree/master/src/sted/cmd/"
    click EditCmd "https://github.com/fazzone/structural-demo/blob/master/src/sted/cmd/edit.cljc"
    click NavCmd "https://github.com/fazzone/structural-demo/blob/master/src/sted/cmd/nav.cljc"
    click MutCmd "https://github.com/fazzone/structural-demo/blob/master/src/sted/cmd/mut.cljc"
    click ReactiveDB "https://github.com/fazzone/structural-demo/blob/master/src/sted/db_reactive.cljs"
    click DFHandlers "https://github.com/fazzone/structural-demo/tree/master/src/sted/df/"
    click AsyncHandler "https://github.com/fazzone/structural-demo/blob/master/src/sted/df/async.cljc"
    click GitHubHandler "https://github.com/fazzone/structural-demo/blob/master/src/sted/df/github.cljs"
    click EmbedSystem "https://github.com/fazzone/structural-demo/tree/master/src/sted/embed/"
    click NREPLSystem "https://github.com/fazzone/structural-demo/tree/master/src/sted/sys/nrepl/"
    click SearchSystem "https://github.com/fazzone/structural-demo/tree/master/src/sted/sys/search/"
    click EvalSystem "https://github.com/fazzone/structural-demo/tree/master/src/sted/sys/eval/sci/"
```
