# ultravioletrs/cube architecture

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

- Interactive diagram: https://gitdiagram.com/ultravioletrs/cube
- Repository: https://github.com/ultravioletrs/cube

## Overview

##### Main Components

a) Core Components:
- Trusted Execution Environment (TEE)
- AI Model Execution Layer
- Hardware Abstraction Layer (HAL)
- Proxy Service
- User Interface
- Authentication & Authorization (SpiceDB)
- Message Broker (NATS)

b) Security Components:
- SSL/TLS Layer
- Attestation Service
- Secure Enclave

##### Component Relationships

- Client/UI → Proxy → TEE
- TEE ↔ AI Model
- TEE ↔ Hardware Layer
- Proxy ↔ Authentication
- System ↔ Attestation Service

##### Specific Implementation Details

Top Layer (External Interface):
- UI Component (represented by the /ui directory)
- API Gateway/Proxy (represented by /proxy directory)
- SSL/TLS termination (shown from /docker/ssl)

Middle Layer (Core Processing):
- TEE Environment
- AI Model Runtime
- Message Broker (NATS)
- Authorization Service (SpiceDB)

Bottom Layer (Hardware):
- Hardware Abstraction Layer (represented by /hal directory)
- Buildroot/Linux Configuration
- QEMU/Virtual Environment

##### Design Elements

Use these visual elements:

##### Additional Details

Technical aspects:
- Docker container boundaries (based on docker-compose files)
- Network isolation zones
- SSL certificate paths
- Configuration management points

- Client Zone (UI, API endpoints)
- Security Zone (TEE, Attestation)
- Processing Zone (AI Model, Runtime)
- Infrastructure Zone (HAL, System Services)

##### Implementation Notes

Annotations for:
- Middleware components (logging, metrics, tracing)
- API endpoints and their security levels
- Configuration sources
- Build and deployment paths

Remember to include:
- Version information
- Date of last update
- Security classification levels
- Component ownership boundaries
- Scale indicators for distributed components

This will provide a clear understanding of how Cube AI protects user data and AI models while maintaining operational efficiency and scalability.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client_Zone
        UI["User Interface"]:::frontend
        API["API Gateway/Proxy"]:::api
        SSL["SSL/TLS Layer"]:::security
    end

    subgraph Security_Zone
        TEE["Trusted Execution Environment"]:::security
        ATTEST["Attestation Service"]:::security
        ENCLAVE["Secure Enclave"]:::security
    end

    subgraph Processing_Zone
        AI["AI Model Runtime"]:::processing
        NATS["Message Broker (NATS)"]:::messaging
        SPICE["SpiceDB (Auth)"]:::security
    end

    subgraph Infrastructure_Zone
        HAL["Hardware Abstraction Layer"]:::infrastructure
        BUILD["Buildroot/Linux"]:::infrastructure
        QEMU["QEMU/Virtual Environment"]:::infrastructure
    end

    %% Connections
    UI --> |HTTPS| SSL
    SSL --> API
    API --> |Authenticated Request| TEE
    TEE --> |Secure Processing| AI
    TEE <--> |Attestation| ATTEST
    TEE --> |Hardware Access| ENCLAVE
    ENCLAVE --> HAL
    API <--> |Events| NATS
    API <--> |Authorization| SPICE
    HAL --> BUILD
    BUILD --> QEMU

    %% Click Events
    click UI "https://github.com/ultravioletrs/cube/tree/main/ui/*"
    click API "https://github.com/ultravioletrs/cube/tree/main/proxy/*"
    click SSL "https://github.com/ultravioletrs/cube/tree/main/docker/ssl/*"
    click ATTEST "https://github.com/ultravioletrs/cube/blob/main/hal/buildroot/linux/systemd/attest.sh"
    click ENCLAVE "https://github.com/ultravioletrs/cube/tree/main/hal/buildroot/linux/package/snpguest/*"
    click NATS "https://github.com/ultravioletrs/cube/tree/main/docker/nats/*"
    click SPICE "https://github.com/ultravioletrs/cube/tree/main/docker/spicedb/*"
    click HAL "https://github.com/ultravioletrs/cube/tree/main/hal/*"

    %% Styling
    classDef frontend fill:#4299E1,stroke:#2B6CB0,stroke-width:2px
    classDef api fill:#48BB78,stroke:#2F855A,stroke-width:2px
    classDef security fill:#F56565,stroke:#C53030,stroke-width:2px
    classDef processing fill:#48BB78,stroke:#2F855A,stroke-width:2px
    classDef messaging fill:#ED8936,stroke:#C05621,stroke-width:2px
    classDef infrastructure fill:#ECC94B,stroke:#B7791F,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Frontend Components"]:::frontend
        L2["API Components"]:::api
        L3["Security Components"]:::security
        L4["Processing Components"]:::processing
        L5["Messaging Components"]:::messaging
        L6["Infrastructure Components"]:::infrastructure
    end
```
