# ml4ai/skema architecture

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

## Overview

##### Main Components Architecture

The system should be represented as a multi-tier architecture with these main components:

a) Service Layer:
- skema-py service (Python)
- skema-rs service (Rust)
- Text Reading service (Scala)

b) Core Processing Components:
- Program Analysis
- GroMEt (Graph-based Model Representation)
- Model Assembly
- Image to MathML (img2mml)
- Text Reading and Analysis

c) Supporting Infrastructure:
- Docker containers
- REST APIs
- Data storage/processing

##### Component Relationships

**[External Clients/Users]**
- ↓
**[Service Layer]**
- skema-py API
- skema-rs API
- Text Reading API
- ↓
**[Processing Layer]**
- Program Analysis
- Code Parsers (Python, Fortran, MATLAB)
- GroMEt Engine
- Execution Engine
- Function Networks
- Model Assembly
- Image Processing (img2mml)
- Text Reading
- Mention Extraction
- Model Linking
- ↓
**[Data Layer]**
- Scientific Documents
- Code Repositories
- Model Definitions

##### Implementation Details

- Language indicators (Python 🐍, Rust 🦀, Scala ☕)
- Docker container boundaries
- REST API endpoints
- Data flow directions
- Component dependencies

##### Architectural Patterns to Emphasize

- Microservices architecture
- Pipeline processing
- Plugin system for parsers
- Event-driven communication

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Layers
    subgraph SL["Service Layer"]
        PY["SKEMA Python Service 🐍"]
        RS["SKEMA Rust Service 🦀"]
        TR["Text Reading Service ☕"]
    end

    subgraph PL["Processing Layer"]
        subgraph PA["Program Analysis"]
            PP["Code Parsers"]:::processor
            PF["Fortran Parser"]:::parser
            PM["MATLAB Parser"]:::parser
            PY2["Python Parser"]:::parser
        end

        subgraph GR["GroMEt Engine"]
            EE["Execution Engine"]:::processor
            FN["Function Networks"]:::processor
        end

        subgraph MA["Model Assembly"]
            MC["Model Composition"]:::processor
            MI["Model Integration"]:::processor
        end

        IMG["Image to MathML"]:::processor

        subgraph TX["Text Reading"]
            ME["Mention Extraction"]:::processor
            ML["Model Linking"]:::processor
        end
    end

    subgraph DL["Data Layer"]
        SD["Scientific Documents"]:::data
        CR["Code Repositories"]:::data
        MD["Model Definitions"]:::data
        DS["Data Storage"]:::data
    end

    %% External Entry Point
    EC["External Clients"]:::external

    %% Relationships
    EC --> PY & RS & TR
    PY & RS & TR --> PA
    PA --> GR
    GR --> MA
    TX --> MA
    IMG --> MA
    PA --> PP
    PP --> PF & PM & PY2
    GR --> EE
    GR --> FN
    TX --> ME
    TX --> ML
    MA --> DS
    SD & CR & MD --> DS

    %% Styles
    classDef external fill:#gray
    classDef service fill:#3498db
    classDef processor fill:#2ecc71
    classDef parser fill:#e74c3c
    classDef data fill:#f1c40f
    
    %% Click Events
    click PY "https://github.com/ml4ai/skema/tree/main/skema/skema_py/"
    click RS "https://github.com/ml4ai/skema/tree/main/skema/skema-rs/"
    click TR "https://github.com/ml4ai/skema/tree/main/skema/text_reading/scala/"
    click PA "https://github.com/ml4ai/skema/tree/main/skema/program_analysis/"
    click EE "https://github.com/ml4ai/skema/tree/main/skema/gromet/execution_engine/"
    click FN "https://github.com/ml4ai/skema/tree/main/skema/gromet/fn/"
    click MA "https://github.com/ml4ai/skema/tree/main/skema/model_assembly/"
    click IMG "https://github.com/ml4ai/skema/tree/main/skema/img2mml/"
    click TX "https://github.com/ml4ai/skema/tree/main/skema/text_reading/scala/src/main/scala/org/ml4ai/skema/text_reading/"
    click ML "https://github.com/ml4ai/skema/tree/main/skema/metal/model_linker/"
    click DS "https://github.com/ml4ai/skema/tree/main/skema/data/"

    %% Legend
    subgraph Legend
        L1["🐍 Python Component"]:::service
        L2["🦀 Rust Component"]:::service
        L3["☕ Scala Component"]:::service
        L4["Processing Component"]:::processor
        L5["Parser Component"]:::parser
        L6["Data Store"]:::data
    end
```
