# ersilia-os/ersilia architecture

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

- Interactive diagram: https://gitdiagram.com/ersilia-os/ersilia
- Repository: https://github.com/ersilia-os/ersilia

## Overview

##### Main Components

a) Core System Components:
- CLI Interface Layer
- Model Hub Core
- Service Layer
- Storage Systems
- Authentication System
- I/O Processing System

b) External Integrations:
- Docker Registry
- S3 Storage
- BentoML Integration
- FastAPI Services
- Conda/Pip Package Management

##### User Interface Layer
- CLI Commands (fetch, serve, run, etc.)
- Python API
- Web Interface

##### Application Layer
- Model Management (fetch, delete, serve)
- Authentication Services
- Configuration Management
- Session Management

##### Core Services Layer
- Model Serving Engine
- BentoML Service
- FastAPI Service
- Docker Container Management

##### Data Processing Layer
- I/O Handlers
- Data Type Converters
- Format Validators

##### Storage Layer
- Local Model Storage
- S3 Cloud Storage
- Docker Registry
- Metadata Storage

##### Key Elements to Highlight

- Model Hub Bundle System
- Fetch/Serve/Run Pipeline
- Docker Container Management
- Multiple Service Types (BentoML/FastAPI)
- I/O Type System
- Authentication Flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        CLI["CLI Interface"]:::cli
        PyAPI["Python API"]:::api
        WebUI["Web Interface"]:::ui
    end

    subgraph APP["Application Layer"]
        ModelMgmt["Model Management"]:::core
        AuthService["Authentication Service"]:::auth
        ConfigMgmt["Configuration Management"]:::core
        SessionMgmt["Session Management"]:::core
    end

    subgraph CORE["Core Services Layer"]
        ModelServe["Model Serving Engine"]:::core
        BentoService["BentoML Service"]:::ext
        FastService["FastAPI Service"]:::ext
        DockerMgmt["Docker Container Management"]:::infra
    end

    subgraph PROC["Data Processing Layer"]
        IOHandler["I/O Handlers"]:::io
        DataConv["Data Type Converters"]:::io
        FormatVal["Format Validators"]:::io
    end

    subgraph STORE["Storage Layer"]
        LocalStore["Local Model Storage"]:::storage
        S3Store["S3 Cloud Storage"]:::storage
        DockerReg["Docker Registry"]:::storage
        MetaStore["Metadata Storage"]:::storage
    end

    %% Relationships
    CLI --> ModelMgmt
    PyAPI --> ModelMgmt
    WebUI --> ModelMgmt

    ModelMgmt --> AuthService
    ModelMgmt --> SessionMgmt
    ModelMgmt --> ConfigMgmt

    ModelMgmt --> ModelServe
    ModelServe --> BentoService
    ModelServe --> FastService
    ModelServe --> DockerMgmt

    ModelServe --> IOHandler
    IOHandler --> DataConv
    DataConv --> FormatVal

    ModelMgmt -.-> LocalStore
    ModelMgmt -.-> S3Store
    DockerMgmt -.-> DockerReg
    ModelMgmt -.-> MetaStore

    %% Click Events
    click CLI "https://github.com/ersilia-os/ersilia/tree/master/ersilia/cli/"
    click AuthService "https://github.com/ersilia-os/ersilia/blob/master/ersilia/auth/auth.py"
    click ModelMgmt "https://github.com/ersilia-os/ersilia/blob/master/ersilia/core/model.py"
    click SessionMgmt "https://github.com/ersilia-os/ersilia/blob/master/ersilia/core/session.py"
    click IOHandler "https://github.com/ersilia-os/ersilia/tree/master/ersilia/io/"
    click DataConv "https://github.com/ersilia-os/ersilia/tree/master/ersilia/io/types/"
    click S3Store "https://github.com/ersilia-os/ersilia/blob/master/ersilia/lake/s3_logger.py"
    click LocalStore "https://github.com/ersilia-os/ersilia/tree/master/ersilia/store/"
    click FastService "https://github.com/ersilia-os/ersilia/tree/master/ersilia/app/fastapi/"
    click BentoService "https://github.com/ersilia-os/ersilia/tree/master/ersilia/tools/bentoml/"
    click DockerMgmt "https://github.com/ersilia-os/ersilia/tree/master/dockerfiles/"
    click MetaStore "https://github.com/ersilia-os/ersilia/tree/master/ersilia/db/"

    %% Styles
    classDef cli fill:#1f77b4
    classDef api fill:#9467bd
    classDef ui fill:#17becf
    classDef core fill:#2ca02c
    classDef auth fill:#d62728
    classDef ext fill:#ff7f0e
    classDef infra fill:#7f7f7f
    classDef io fill:#e377c2
    classDef storage fill:#bcbd22

    %% Legend
    subgraph Legend
        L1["CLI Components"]:::cli
        L2["API Components"]:::api
        L3["UI Components"]:::ui
        L4["Core Services"]:::core
        L5["Auth Services"]:::auth
        L6["External Services"]:::ext
        L7["Infrastructure"]:::infra
        L8["I/O Processing"]:::io
        L9["Storage Systems"]:::storage
    end
```
