# fix-project/fix architecture

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

## Overview

##### Main Components

a) Core Runtime System:
- Following sub-components from src/runtime:
- Executor (executor.cc/hh)
- Evaluator (evaluator.cc/hh)
- Scheduler (scheduler.cc/hh)
- ELF Loader (elfloader.cc/hh)

b) Storage Layer:
- Below the runtime system
- Components from src/storage:
- Repository (repository.cc/hh)
- Runtime Storage (runtimestorage.cc/hh)
- Hash Table (hash_table.cc/hh)
- FixCache System (fixcache.hh)

c) WebAssembly Runtime:
- On the right side
- Components from src/wasm-rt
- Connection to the core runtime

d) Component System:
- On the left side
- Object and Program handlers from src/component

e) HTTP Interface:
- At the top
- HTTP client/server components from src/http

##### Relationship Flows

- External requests → HTTP Interface
- HTTP Interface → Runtime System
- Runtime System → Wasm Runtime (for execution)
- Runtime System → Storage Layer (for object persistence)
- Runtime System → Component System (for object handling)

##### Special Elements

a) File System Integration:
- .fix repository structure:
- data/
- labels/
- pins/
- relations/

b) Build System:
- CMake configuration flow
- Connection to wasm-toolchain

##### Architectural Patterns to Highlight

- Component-based architecture
- Event-driven execution model (shown by eventloop.cc/hh)
- Object storage and caching system
- Modular design with clear separation of concerns

##### Implementation Details

- Resource limits handling
- Dependency graph management
- Concurrent execution capabilities
- Object handle system

##### External Dependencies

Connections to:
- BLAKE3 (third-party)
- Abseil (third-party)
- Wasm toolchain (external)

##### Testing Infrastructure

A section showing:
- Unit tests
- End-to-end tests
- Benchmark system
- Flatware tests

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef core fill:#b3d1ff,stroke:#333
    classDef storage fill:#90EE90,stroke:#333
    classDef wasm fill:#FFE5B4,stroke:#333
    classDef http fill:#DDA0DD,stroke:#333
    classDef component fill:#FFB6C1,stroke:#333
    classDef testing fill:#D3D3D3,stroke:#333
    classDef util fill:#F0E68C,stroke:#333

    %% HTTP Interface Layer
    subgraph HTTP
        HC["HTTP Client"]
        HS["HTTP Server"]
        WS["Web Server"]
    end

    %% Core Runtime Layer
    subgraph Runtime
        EX["Executor"]:::core
        EV["Evaluator"]:::core
        SC["Scheduler"]:::core
        EL["ELF Loader"]:::core
        DG["Dependency Graph"]:::core
    end

    %% Storage Layer
    subgraph Storage
        RP["Repository"]:::storage
        RS["Runtime Storage"]:::storage
        HT["Hash Table"]:::storage
        FC["FixCache"]:::storage
    end

    %% WebAssembly Runtime
    subgraph WASM
        WR["WASM Runtime"]:::wasm
        WI["WASM Implementation"]:::wasm
    end

    %% Component System
    subgraph Components
        OH["Object Handler"]:::component
        PH["Program Handler"]:::component
    end

    %% Utility Layer
    subgraph Utilities
        EL_["Event Loop"]:::util
        RL["Resource Limits"]:::util
    end

    %% Testing Infrastructure
    subgraph Testing
        UT["Unit Tests"]:::testing
        BT["Benchmark Tests"]:::testing
        FT["Flatware Tests"]:::testing
    end

    %% Relationships
    HC --> EX
    HS --> EX
    WS --> EX
    
    EX --> EV
    EV --> SC
    SC --> EL
    SC --> DG
    
    EX --> RP
    RP --> RS
    RS --> HT
    RS --> FC
    
    EX --> WR
    WR --> WI
    
    EX --> OH
    OH --> PH
    
    SC --> EL_
    EL_ --> RL

    %% Testing relationships
    UT --> Runtime
    BT --> Runtime
    FT --> Runtime

    %% Click events
    click EX "https://github.com/fix-project/fix/blob/master/src/runtime/executor.cc"
    click EV "https://github.com/fix-project/fix/blob/master/src/runtime/evaluator.cc"
    click SC "https://github.com/fix-project/fix/blob/master/src/runtime/scheduler.cc"
    click EL "https://github.com/fix-project/fix/blob/master/src/runtime/elfloader.cc"
    click DG "https://github.com/fix-project/fix/blob/master/src/runtime/dependency_graph.hh"
    
    click RP "https://github.com/fix-project/fix/blob/master/src/storage/repository.cc"
    click RS "https://github.com/fix-project/fix/blob/master/src/storage/runtimestorage.cc"
    click HT "https://github.com/fix-project/fix/blob/master/src/storage/hash_table.cc"
    click FC "https://github.com/fix-project/fix/blob/master/src/storage/fixcache.hh"
    
    click WR "https://github.com/fix-project/fix/blob/master/src/wasm-rt/wasm-rt.h"
    click WI "https://github.com/fix-project/fix/blob/master/src/wasm-rt/wasm-rt-impl.cc"
    
    click OH "https://github.com/fix-project/fix/blob/master/src/component/object.cc"
    click PH "https://github.com/fix-project/fix/blob/master/src/component/program.hh"
    
    click HC "https://github.com/fix-project/fix/blob/master/src/http/http_client.hh"
    click HS "https://github.com/fix-project/fix/blob/master/src/http/http_server.hh"
    click WS "https://github.com/fix-project/fix/blob/master/src/http/web_server.cc"
    
    click EL_ "https://github.com/fix-project/fix/blob/master/src/util/eventloop.cc"
    click RL "https://github.com/fix-project/fix/blob/master/src/util/resource_limits.cc"
    
    click UT "https://github.com/fix-project/fix/tree/master/src/tests"
    click BT "https://github.com/fix-project/fix/tree/master/testing/benchmark"
    click FT "https://github.com/fix-project/fix/tree/master/applications/flatware"
```
