# tinkoff/ogam3 architecture

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

- Interactive diagram: https://gitdiagram.com/tinkoff/ogam3
- Repository: https://github.com/tinkoff/ogam3

## Overview

##### Main Components Identification

a. Core Interpreter Components:
- Reader (String & Binary formats)
- Compiler
- Language Virtual Machine (VM)
- Evaluator

b. Supporting Systems:
- REPL Interface
- RPC System
- Core Language Implementation
- Utility Services

**┌─────────────────┐    ┌─────────────────┐**
- String REPL   │    │    Binary RPC   │
- ┘    └─────────────────┘

**┌──────────┐  ┌──────────┐  ┌──────────┐  ┌──────────┐**
- Reader  │→ │Compiler  │→ │   VM     │→ │Evaluator │
- ┘  └──────────┘  └──────────┘  └──────────┘

**┌─────────────┐  ┌─────────────┐  ┌─────────────┐**
- Core.cs    │  │CoreMacro.cs │  │ Utils       │
- ┘  └─────────────┘  └─────────────┘

##### Specific Implementation Details

Key elements based on the file structure:

a. LSP Components:
- BinFormater
- Cons
- Continuation
- Lambda
- MacroSystem
- Symbol

b. Utils Components:
- Reflect
- SGuid
- Synchronizer
- ThreadBazuka

##### Implementation Notes

- The pipeline nature of the interpretation process
- The separation between string-based REPL and binary RPC
- The extensibility mechanism for .NET integration
- The clear separation between the compiler and VM

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef interface fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef support fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef utils fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Interface Layer
    subgraph Interface
        REPL["String REPL"]:::interface
        RPC["Binary RPC"]:::interface
    end

    %% Processing Pipeline
    subgraph Pipeline
        Reader["Reader"]:::core
        Compiler["Compiler"]:::core
        VM["Virtual Machine"]:::core
        Evaluator["Evaluator"]:::core
    end

    %% Core Implementation
    subgraph CoreImpl
        Core["Core Language"]:::core
        MacroSystem["Macro System"]:::core
        CoreMacro["Core Macros"]:::core
    end

    %% Data Structures
    subgraph DataStructures
        Cons["Cons"]:::support
        Lambda["Lambda"]:::support
        Continuation["Continuation"]:::support
        Symbol["Symbol"]:::support
        EnvFrame["Environment Frame"]:::support
        BinFormatter["Binary Formatter"]:::support
        Params["Parameters"]:::support
        SpecialMsg["Special Messages"]:::support
    end

    %% Utility Services
    subgraph Utils
        Reflect["Reflect"]:::utils
        Sync["Synchronizer"]:::utils
        ThreadBaz["Thread Bazuka"]:::utils
        LogWriter["Log Writer"]:::utils
    end

    %% Relationships
    REPL --> Reader
    RPC --> Reader
    Reader --> Compiler
    Compiler --> VM
    VM --> Evaluator
    
    Evaluator --> Core
    Core --> MacroSystem
    MacroSystem --> CoreMacro
    
    VM -.-> DataStructures
    Evaluator -.-> DataStructures
    Core -.-> Utils

    %% Click Events
    click Reader "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Reader.cs"
    click Compiler "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Compiler.cs"
    click VM "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/VM.cs"
    click Evaluator "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Evaluator.cs"
    click Core "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Defaults/Core.cs"
    click MacroSystem "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/MacroSystem.cs"
    click CoreMacro "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Defaults/CoreMacro.cs"
    click BinFormatter "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/BinFormater.cs"
    click Cons "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Cons.cs"
    click Lambda "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Lambda.cs"
    click Continuation "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Continuation.cs"
    click EnvFrame "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/EnviromentFrame.cs"
    click Symbol "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Symbol.cs"
    click Reflect "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Utils/Reflect.cs"
    click Sync "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Utils/Synchronizer.cs"
    click ThreadBaz "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Utils/ThreadBazuka.cs"
    click LogWriter "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Utils/LogTextWriter.cs"
    click Params "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/Params.cs"
    click SpecialMsg "https://github.com/Tinkoff/Ogam3/blob/master/Ogam3/Lsp/SpecialMessage.cs"

    %% Legend
    subgraph Legend
        L1["Interface Components"]:::interface
        L2["Core Components"]:::core
        L3["Support Components"]:::support
        L4["Utility Components"]:::utils
    end
```
