# instill-ai/instill-core architecture

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

- Interactive diagram: https://gitdiagram.com/instill-ai/instill-core
- Repository: https://github.com/instill-ai/instill-core

## Overview

##### Main Components Identification
The system consists of several key microservices that should be represented as distinct components:

a. Core Services:
- API Gateway
- Console (Frontend)
- Management Backend
- Model Backend
- Pipeline Backend
- Artifact Backend

b. Infrastructure Services:
- Database (PostgreSQL)
- Redis
- Registry
- Temporal
- OpenFGA (Authorization)
- Ray Service (ML/AI Processing)

c. Observability Stack:
- Elasticsearch
- Grafana
- InfluxDB
- Jaeger
- Prometheus
- OpenTelemetry Collector

##### Component Relationships and Architecture

Frontend Layer:
**┌─────────────┐**
- Console   │
- ┘

API Gateway Layer:
**┌─────────────────┐**
- API Gateway   │
- ┘

Service Layer:
**┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐**
- Management  │ │   Model     │ │  Pipeline   │ │  Artifact   │
- Backend    │ │  Backend    │ │  Backend    │ │  Backend    │
- ┘ └─────────────┘ └─────────────┘ └─────────────┘

Infrastructure Layer:
**┌─────────┐ ┌────────┐ ┌──────────┐ ┌─────────┐ ┌────────┐**
- Postgres │ │ Redis  │ │ Registry │ │Temporal │ │OpenFGA │
- ┘ └────────┘ └──────────┘ └─────────┘ └────────┘

Observability Layer:
**┌───────────┐ ┌─────────┐ ┌──────────┐ ┌────────┐**
- Grafana   │ │ Jaeger  │ │InfluxDB  │ │Prometheus│
- ┘ └─────────┘ └──────────┘ └────────┘

##### Connection Types

Different types of connections:
- Monitoring/metrics flow: Dash-dot lines

##### Additional Elements

Include:
- Load balancers where applicable
- Security boundaries
- External service integrations
- Volume mounts and persistent storage
- Kubernetes deployment boundaries (based on Helm charts)

##### Deployment Context

How the system is deployed using Kubernetes:
- Namespace boundaries
- Service mesh if applicable
- Replicated components
- Stateful vs stateless services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef cache fill:#e67e22,stroke:#d35400,color:white
    classDef observability fill:#9b59b6,stroke:#8e44ad,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef infra fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    Console["Console Frontend"]:::frontend
    click Console "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/console/"

    %% API Gateway Layer
    APIGateway["API Gateway"]:::backend
    click APIGateway "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/api-gateway/"

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        ManagementBackend["Management Backend"]:::backend
        ModelBackend["Model Backend"]:::backend
        PipelineBackend["Pipeline Backend"]:::backend
        ArtifactBackend["Artifact Backend"]:::backend
    end
    click ManagementBackend "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/mgmt-backend/"
    click ModelBackend "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/model-backend/"
    click PipelineBackend "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/pipeline-backend/"
    click ArtifactBackend "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/artifact-backend/"

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        PostgreSQL[(PostgreSQL)]:::database
        Redis[(Redis)]:::cache
        Registry["Registry"]:::infra
        Temporal["Temporal"]:::infra
        OpenFGA["OpenFGA"]:::security
        RayService["Ray Service"]:::infra
    end
    click PostgreSQL "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/database/"
    click Redis "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/redis/"
    click Registry "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/registry/"
    click Temporal "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/temporal/"
    click OpenFGA "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/openfga/"
    click RayService "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/ray-service/"

    %% Observability Layer
    subgraph ObservabilityLayer["Observability Layer"]
        Elasticsearch[(Elasticsearch)]:::database
        Grafana["Grafana"]:::observability
        InfluxDB[(InfluxDB)]:::database
        Jaeger["Jaeger"]:::observability
        Prometheus["Prometheus"]:::observability
        OTelCollector["OpenTelemetry Collector"]:::observability
    end
    click Grafana "https://github.com/instill-ai/instill-core/tree/main/charts/core/templates/grafana/"
    click InfluxDB "https://github.com/instill-ai/instill-core/tree/main/configs/influxdb/"
    click OTelCollector "https://github.com/instill-ai/instill-core/blob/main/configs/otel-collector/config.yaml"
    click Prometheus "https://github.com/instill-ai/instill-core/blob/main/configs/prometheus/config.yaml"

    %% Connections
    Console --> APIGateway
    APIGateway --> ManagementBackend
    APIGateway --> ModelBackend
    APIGateway --> PipelineBackend
    APIGateway --> ArtifactBackend

    ManagementBackend --> PostgreSQL
    ManagementBackend --> Redis
    ManagementBackend --> OpenFGA
    
    ModelBackend --> PostgreSQL
    ModelBackend --> Redis
    ModelBackend --> Registry
    ModelBackend --> RayService
    
    PipelineBackend --> PostgreSQL
    PipelineBackend --> Redis
    PipelineBackend --> Temporal
    
    ArtifactBackend --> PostgreSQL
    ArtifactBackend --> Registry

    %% Observability Connections
    OTelCollector -.-> Elasticsearch
    OTelCollector -.-> Prometheus
    OTelCollector -.-> Jaeger
    Grafana -.-> Prometheus
    Grafana -.-> InfluxDB
    Grafana -.-> Elasticsearch

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        Backend["Backend Service"]:::backend
        DB[(Database)]:::database
        Cache[(Cache)]:::cache
        Obs["Observability Tool"]:::observability
        Sec["Security Component"]:::security
        Inf["Infrastructure Service"]:::infra
    end
```
