# unisonweb/unison architecture

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

## Overview

##### Main System Components

**┌─ Unison System Architecture ─────────────────────────────────────┐**

- ┌─ Frontend Layer ──────────────────────────────────────────┐   │
- Language Server Protocol (LSP)                          │   │
- Command Line Interface (CLI)                            │   │
- Local Web UI                                           │   │
- ┘   │

- ┌─ Core Processing Layer ───────────────────────────────────┐   │
- ┌─ Parser/Typechecker ─┐  ┌─ Codebase Management ──────┐ │   │
- Syntax Parser      │  │ - SQLite Storage           │ │   │
- Type Inference     │  │ - Branch Management        │ │   │
- Pattern Matching   │  │ - Version Control          │ │   │
- ┘  └────────────────────────────┘ │   │

- ┌─ Runtime System ─────┐  ┌─ Distributed Computing ───┐ │   │
- ANF Compilation    │  │ - Node Communication      │ │   │
- Builtin Functions  │  │ - Distributed Execution   │ │   │
- Memory Management  │  │ - Fault Tolerance         │ │   │
- ┘  └────────────────────────────┘ │   │
- ┘   │

- ┌─ Storage & Integration Layer ────────────────────────────┐   │
- Codebase Storage (SQLite)                             │   │
- Share API Integration                                 │   │
- External Tool Integration                            │   │
- ┘   │
- ┘

##### Detailed Component Descriptions

Each major component should include:

**┌─ Component Name ─────┐**
- Purpose: [Brief description]
- Key Responsibilities:
- [Responsibility 1]
- [Responsibility 2]
- Dependencies:
- [Internal/External]
- ┘

##### Integration Points

Integration points with:

- External tools
- Editor support
- Build systems
- Package management

##### Deployment View

A separate section showing:

- Runtime deployment options
- Distributed system configuration
- Network communication paths
- Security boundaries

- Content-addressed code storage
- Purely functional distributed computing
- Ability to describe entire distributed systems
- Type-safe refactoring capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef frontend fill:#e6e6fa,stroke:#333
    classDef core fill:#add8e6,stroke:#333
    classDef runtime fill:#90ee90,stroke:#333
    classDef storage fill:#ffa500,stroke:#333
    classDef integration fill:#d3d3d3,stroke:#333

    %% Frontend Layer
    subgraph Frontend
        LSP["Language Server Protocol (LSP)"]
        CLI["Command Line Interface"]
        WebUI["Local Web UI"]
    end

    %% Core Processing Layer
    subgraph CoreProcessing
        subgraph ParserTypechecker
            Parser["Syntax Parser"]
            TypeInf["Type Inference"]
            Pattern["Pattern Matching"]
            Hash["Hashing System"]
        end

        subgraph CodebaseManagement
            Storage["SQLite Storage"]
            Branch["Branch Management"]
            Version["Version Control"]
            Merge["Merge Operations"]
        end

        subgraph RuntimeSystem
            ANF["ANF Compilation"]
            Builtin["Builtin Functions"]
            Memory["Memory Management"]
        end

        subgraph DistributedComputing
            NodeComm["Node Communication"]
            DistExec["Distributed Execution"]
            Fault["Fault Tolerance"]
        end
    end

    %% Storage & Integration Layer
    subgraph StorageIntegration
        CodebaseStorage["Codebase Storage"]
        ShareAPI["Share API Integration"]
        ExtTools["External Tool Integration"]
    end

    %% Relationships
    LSP --> Parser
    CLI --> Parser
    WebUI --> Parser

    Parser --> TypeInf
    TypeInf --> Pattern
    Pattern --> Hash

    Parser --> CodebaseStorage
    CodebaseStorage --> Storage
    Storage --> Branch
    Branch --> Version
    Version --> Merge

    Pattern --> ANF
    ANF --> Builtin
    Builtin --> Memory

    Memory --> NodeComm
    NodeComm --> DistExec
    DistExec --> Fault

    CodebaseStorage --> ShareAPI
    CodebaseStorage --> ExtTools

    %% Styles Application
    class LSP,CLI,WebUI frontend
    class Parser,TypeInf,Pattern,Hash core
    class Storage,Branch,Version,Merge storage
    class ANF,Builtin,Memory runtime
    class NodeComm,DistExec,Fault runtime
    class CodebaseStorage,ShareAPI,ExtTools integration

    %% Click Events
    click LSP "https://github.com/unisonweb/unison/tree/trunk/unison-cli/src/Unison/LSP/"
    click CLI "https://github.com/unisonweb/unison/tree/trunk/unison-cli/src/Unison/CommandLine/"
    click Parser "https://github.com/unisonweb/unison/tree/trunk/parser-typechecker/src/Unison/"
    click Storage "https://github.com/unisonweb/unison/tree/trunk/codebase2/codebase-sqlite/"
    click Memory "https://github.com/unisonweb/unison/tree/trunk/unison-runtime/src/Unison/Runtime/"
    click NodeComm "https://github.com/unisonweb/unison/tree/trunk/parser-typechecker/src/Unison/Codebase/"
    click CodebaseStorage "https://github.com/unisonweb/unison/tree/trunk/lib/unison-sqlite/"
    click ShareAPI "https://github.com/unisonweb/unison/tree/trunk/unison-share-api/src/Unison/Server/"
    click ExtTools "https://github.com/unisonweb/unison/tree/trunk/editor-support/"
    click Parser "https://github.com/unisonweb/unison/tree/trunk/unison-core/src/Unison/"
    click Parser "https://github.com/unisonweb/unison/tree/trunk/unison-syntax/src/Unison/Syntax/"
    click Hash "https://github.com/unisonweb/unison/tree/trunk/lib/unison-hash/src/Unison/Hash/"
    click Merge "https://github.com/unisonweb/unison/tree/trunk/unison-merge/src/Unison/Merge/"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Components"]:::frontend
        Core_L["Core Components"]:::core
        Runtime_L["Runtime Components"]:::runtime
        Storage_L["Storage Components"]:::storage
        Integration_L["Integration Components"]:::integration
    end
```
