# finos/legend architecture

> Architecture diagram of the GitHub repository finos/legend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/finos/legend
- Repository: https://github.com/finos/legend

## Overview

##### Integration Layer
Integration between components:

a. External Systems:
- GitLab (for model storage and version control)
- Authentication systems
- Data sources (Relational, MongoDB, Service APIs)

b. Connection Points:
- API interfaces between components
- Data flow paths
- Authentication flows

##### Functional Layers (use horizontal layers)

Top to Bottom:

##### Business Logic Layer
- Model Management
- Query Processing
- Data Transformation
- Code Generation

##### Execution Layer
- Pure Language Runtime
- Query Engine
- Service Execution

##### Storage Layer
- Model Repository
- Version Control
- Metadata Storage

##### Key Design Elements

- Blue: Core components
- Green: External integrations
- Orange: Data stores
- Gray: Infrastructure components

b. Connection Types:

##### Specific Features

Specialized subsystems:
- Data modeling capabilities
- Code generation (JSON Schema, Protobuf, AVRO)
- Data governance controls
- Self-service capabilities
- Validation mechanisms

##### Deployment View

A separate section showing:
- Docker container boundaries
- Service boundaries
- Network zones
- Load balancers
- API gateways

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef core fill:#2374AB,color:white
    classDef external fill:#57A773,color:white
    classDef storage fill:#FF8C42,color:white
    classDef infra fill:#808080,color:white
    classDef presentation fill:#6C8EBF,color:white
    classDef business fill:#B85450,color:white
    classDef execution fill:#D79B00,color:white

    %% Presentation Layer
    subgraph PresentationLayer["Presentation Layer"]
        Studio["Legend Studio"]
        Docs["Documentation"]
        GraphQL["GraphQL Interface"]
    end

    %% Business Logic Layer
    subgraph BusinessLayer["Business Logic Layer"]
        ModelMgmt["Model Management"]
        QueryProc["Query Processing"]
        DataTrans["Data Transformation"]
        CodeGen["Code Generation"]
    end

    %% Execution Layer
    subgraph ExecutionLayer["Execution Layer"]
        Engine["Legend Engine"]
        PureRuntime["Pure Language Runtime"]
        QueryEngine["Query Engine"]
    end

    %% Storage Layer
    subgraph StorageLayer["Storage Layer"]
        Depot["Legend Depot"]
        GitLab["GitLab"]
        Database["Database"]
    end

    %% External Systems
    subgraph ExternalSystems["External Systems"]
        Auth["Authentication"]
        DataSources["Data Sources"]
    end

    %% Connections
    Studio --> ModelMgmt
    Studio --> QueryProc
    GraphQL --> QueryEngine
    ModelMgmt --> Engine
    QueryProc --> Engine
    DataTrans --> Engine
    CodeGen --> Engine
    Engine --> PureRuntime
    Engine --> QueryEngine
    PureRuntime --> Depot
    QueryEngine --> DataSources
    Depot --> GitLab
    ModelMgmt --> GitLab
    Auth --> Studio
    Auth --> Engine

    %% Click events
    click Studio "https://github.com/finos/legend/tree/master/installers/docker-compose/studio"
    click Engine "https://github.com/finos/legend/tree/master/installers/docker-compose/engine"
    click Depot "https://github.com/finos/legend/tree/master/installers/docker-compose/depot-store"
    click GraphQL "https://github.com/finos/legend/tree/master/installers/docker-compose/graphiql"
    click Docs "https://github.com/finos/legend/tree/master/docs"
    click GitLab "https://github.com/finos/legend/tree/master/installers/omnibus/components/gitlab"
    click Database "https://github.com/finos/legend/tree/master/installers/docker-compose/postgres"

    %% Style applications
    class Studio,Engine,Depot core
    class Auth,DataSources external
    class GitLab,Database storage
    class PureRuntime,QueryEngine execution
    class ModelMgmt,QueryProc,DataTrans,CodeGen business
    class Studio,Docs,GraphQL presentation

    %% Legend
    subgraph Legend["Legend"]
        CoreComp["Core Component"]:::core
        ExtComp["External Integration"]:::external
        StorageComp["Storage Component"]:::storage
        PresentationComp["Presentation Component"]:::presentation
        BusinessComp["Business Logic Component"]:::business
        ExecutionComp["Execution Component"]:::execution
    end
```
