# live-codes/livecodes architecture

> Architecture diagram of the GitHub repository live-codes/livecodes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/live-codes/livecodes
- Repository: https://github.com/live-codes/livecodes

## Overview

##### Main Components Architecture

a) Core Application Components:
- UI Layer
- Editor System
- Compiler System
- Runtime Environment
- Storage System
- Services Layer

b) External Integrations:
- CDN Services (jsDelivr, unpkg, esm.sh)
- Cloud Services (GitHub, Cloudflare Pages)
- Third-party Services (Codeium, BundleJS, etc.)

##### Detailed Component Breakdown

**┌─ LiveCodes Application ──────────────────────────────────────────┐**

- ┌─ UI Layer ─────┐  ┌─ Editor System ─┐  ┌─ Compiler System ─┐ │
- Main UI      │  │ - CodeMirror    │  │ - Language        │ │
- Tools Pane   │  │ - Monaco        │  │   Processors      │ │
- Console      │  │ - CodeJar       │  │ - Compilers       │ │
- Settings     │  │ - Blockly       │  │ - Workers         │ │
- ┘  └────────────────-┘  └─────────────────--┘ │

- ┌─ Runtime ──────┐  ┌─ Storage ──────┐  ┌─ Services ────────┐  │
- Sandbox      │  │ - Local Store  │  │ - Auth            │  │
- Workers      │  │ - Sync         │  │ - GitHub          │  │
- Evaluators   │  │ - Backup       │  │ - Modules         │  │
- Console      │  │ - Projects     │  │ - Broadcast       │  │
- ┘  └────────────────┘  └─────────────────--┘  │

- ┘

**┌─ External Services ───────────────────────────────────────────---┐**

- ┌─ CDN ──────────┐  ┌─ Cloud ────────┐  ┌─ Integrations ────┐  │
- jsDelivr     │  │ - Cloudflare   │  │ - Codeium        │  │
- unpkg        │  │ - GitHub Pages │  │ - BundleJS       │  │
- esm.sh      │  │ - Netlify      │  │ - Lokalise       │  │
- ┘  └────────────────┘  └─────────────────--┘  │

- ┘

##### Data Flow Indicators

- User input flow through the UI to editors
- Code compilation and processing flow
- Runtime execution path
- Storage operations
- External service communications

##### Notes

Annotations for:
- Security boundaries
- Performance optimization points
- Caching mechanisms
- Error handling paths
- Fallback systems

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph LiveCodes["LiveCodes Application"]
        subgraph UI["UI Layer"]
            MainUI["Main UI"]:::ui
            Tools["Tools Pane"]:::ui
            Console["Console"]:::ui
            Settings["Settings"]:::ui
        end

        subgraph Editors["Editor System"]
            CodeMirror["CodeMirror"]:::editor
            Monaco["Monaco"]:::editor
            CodeJar["CodeJar"]:::editor
            Blockly["Blockly"]:::editor
        end

        subgraph Compilers["Compiler System"]
            LangProc["Language Processors"]:::compiler
            CompWorker["Compiler Workers"]:::compiler
            Compilers2["Compilers"]:::compiler
        end

        subgraph Runtime["Runtime Environment"]
            Sandbox["Sandbox"]:::runtime
            Workers["Workers"]:::runtime
            Evaluators["Evaluators"]:::runtime
            ConsoleRT["Console"]:::runtime
        end

        subgraph Storage["Storage System"]
            LocalStore["Local Store"]:::storage
            Sync["Sync"]:::storage
            Backup["Backup"]:::storage
            Projects["Projects"]:::storage
        end

        subgraph Services["Services Layer"]
            Auth["Auth"]:::service
            GitHub["GitHub"]:::service
            Modules["Modules"]:::service
            Broadcast["Broadcast"]:::service
        end
    end

    subgraph External["External Services"]
        subgraph CDN["CDN Services"]
            jsDelivr["jsDelivr"]:::external
            unpkg["unpkg"]:::external
            esmsh["esm.sh"]:::external
        end

        subgraph Cloud["Cloud Services"]
            Cloudflare["Cloudflare"]:::external
            GitHubPages["GitHub Pages"]:::external
            Netlify["Netlify"]:::external
        end

        subgraph Integration["Third-party Services"]
            Codeium["Codeium"]:::external
            BundleJS["BundleJS"]:::external
            Lokalise["Lokalise"]:::external
        end
    end

    %% Relationships
    UI --> Editors
    Editors --> Compilers
    Compilers --> Runtime
    Runtime --> Storage
    Runtime --> Services
    Services --> External
    Storage --> Services

    %% Click Events
    click MainUI "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/UI/"
    click Tools "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/UI/"
    click Console "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/toolspane/console.ts"
    click Settings "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/UI/"
    
    click CodeMirror "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/editor/codemirror/"
    click Monaco "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/editor/monaco/"
    click CodeJar "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/editor/codejar/"
    click Blockly "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/editor/blockly/"
    
    click LangProc "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/languages/"
    click CompWorker "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/compiler/compile.worker.ts"
    click Compilers2 "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/compiler/"
    
    click Sandbox "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/services/sandbox.ts"
    click ConsoleRT "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/toolspane/console.ts"
    
    click LocalStore "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/storage/"
    click Sync "https://github.com/live-codes/livecodes/tree/develop/src/livecodes/sync/"
    click Projects "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/storage/project-storage.ts"
    
    click Auth "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/services/auth.ts"
    click GitHub "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/services/github.ts"
    click Modules "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/services/modules.ts"
    click Broadcast "https://github.com/live-codes/livecodes/blob/develop/src/livecodes/services/broadcast.ts"

    %% Styles
    classDef ui fill:#ff9900,stroke:#333,stroke-width:2px
    classDef editor fill:#3498db,stroke:#333,stroke-width:2px
    classDef compiler fill:#9b59b6,stroke:#333,stroke-width:2px
    classDef runtime fill:#e74c3c,stroke:#333,stroke-width:2px
    classDef storage fill:#f1c40f,stroke:#333,stroke-width:2px
    classDef service fill:#1abc9c,stroke:#333,stroke-width:2px
    classDef external fill:#2ecc71,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        UI_L["UI Components"]:::ui
        Editor_L["Editor Components"]:::editor
        Compiler_L["Compiler Components"]:::compiler
        Runtime_L["Runtime Components"]:::runtime
        Storage_L["Storage Components"]:::storage
        Service_L["Service Components"]:::service
        External_L["External Services"]:::external
    end
```
