# aenix-io/cozystack architecture

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

## Overview

##### Main Components Identification

The system can be broken down into these major components:

a. Core Components:
- Control Plane (packages/core/platform)
- API Server (cmd/cozystack-api)
- Installer (packages/core/installer)

b. Service Components:
- Database Services (MySQL, PostgreSQL, Redis, etc.)
- Kubernetes Management
- Virtual Machine Management
- Storage Management
- Networking Services
- Monitoring & Metrics

**┌─ Control Plane Layer ─────────────────────────┐**
- API Server                                  │
- Authentication & Authorization              │
- Resource Management                         │
- ┘
- ↕
**┌─ Service Management Layer ────────────────────┐**
- ┌─ Infrastructure ─┐ ┌─ Platform Services ─┐  │
- Kubernetes     │ │ - Databases         │  │
- Virtual Machines│ │ - Message Queues   │  │
- Storage        │ │ - Caching          │  │
- ┘ └──────────────────────┘ │
- ┘
- ↕
**┌─ Infrastructure Layer ────────────────────────┐**
- Bare Metal Servers                         │
- Networking                                 │
- Storage Systems                            │
- ┘

##### Component Relationships

Following interactions:
- API Server → Service Controllers
- Service Controllers → Infrastructure Resources
- Monitoring System → All Components
- Authentication Flow → API Endpoints

##### Elements

a. Control Plane:
- API Server (cozystack-api)
- Authentication System (Keycloak)
- Resource Controllers
- Configuration Management

b. Service Management:
- Database Operators (MySQL, PostgreSQL, etc.)
- Kubernetes Management
- Virtual Machine Management
- Storage Management (Seaweedfs)
- Network Services (Ingress, Load Balancers)

c. Monitoring & Operations:
- Metrics Collection (Victoria Metrics)
- Logging System (Fluent Bit)
- Alert Management
- Dashboard System

##### Additional Details

Annotations for:
- API endpoints
- Security boundaries
- Data flow directions
- Scaling components
- High availability pairs

##### Implementation Notes

- Use standard architectural symbols
- Clear boundaries between components
- Scalable components
- Security zones
- Backup/recovery paths
- Monitoring points

This system design should reflect Cozystack's ability to:
- Transform bare metal servers into a cloud platform
- Provide REST API for service management
- Support multiple service types (Kubernetes, DBaaS, VMs)
- Handle security and monitoring
- Support both public and private cloud deployments

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#2374ab
    classDef service fill:#57a773
    classDef infra fill:#484848,color:#fff
    classDef security fill:#ff6b6b
    classDef monitoring fill:#ffa62b
    classDef api fill:#4a90e2
    
    %% Control Plane Layer
    subgraph ControlPlane
        API["API Server"]
        Auth["Authentication & Authorization"]
        ResourceMgmt["Resource Management"]
        ControlCore["Control Plane Core"]
    end
    
    %% Service Management Layer
    subgraph ServiceManagement
        subgraph Infrastructure
            K8s["Kubernetes Management"]
            VM["Virtual Machine Management"]
            Storage["Storage Management"]
        end
        
        subgraph PlatformServices
            MySQL["MySQL Service"]
            PostgreSQL["PostgreSQL Service"]
            Redis["Redis Service"]
            ObjectStorage["Object Storage"]
            BlockStorage["Block Storage"]
        end
    end
    
    %% Infrastructure Layer
    subgraph InfraLayer
        BareMetal["Bare Metal Servers"]
        Network["Network Services"]
        StorageSys["Storage Systems"]
    end
    
    %% Monitoring Components
    Monitor["Monitoring System"]
    MetricsStorage["Metrics Storage"]
    Dashboard["Dashboard"]
    
    %% Relationships
    API --> Auth
    Auth --> ResourceMgmt
    ResourceMgmt --> ControlCore
    ControlCore --> Infrastructure
    ControlCore --> PlatformServices
    
    Infrastructure --> InfraLayer
    PlatformServices --> InfraLayer
    
    Monitor --> ControlPlane
    Monitor --> ServiceManagement
    Monitor --> InfraLayer
    Monitor --> MetricsStorage
    MetricsStorage --> Dashboard
    
    Network --> Ingress["Ingress Controller"]
    Network --> NetworkOverlay["Network Overlay"]
    
    %% Component Classifications
    class API,ControlCore core
    class Auth,Ingress,NetworkOverlay security
    class K8s,VM,Storage,MySQL,PostgreSQL,Redis,ObjectStorage,BlockStorage service
    class BareMetal,Network,StorageSys infra
    class Monitor,MetricsStorage,Dashboard monitoring
    
    %% Click Events
    click API "https://github.com/aenix-io/cozystack/tree/main/cmd/cozystack-api"
    click ControlCore "https://github.com/aenix-io/cozystack/tree/main/packages/core/platform"
    click K8s "https://github.com/aenix-io/cozystack/tree/main/packages/apps/kubernetes"
    click VM "https://github.com/aenix-io/cozystack/tree/main/packages/apps/virtual-machine"
    click MySQL "https://github.com/aenix-io/cozystack/tree/main/packages/apps/mysql"
    click PostgreSQL "https://github.com/aenix-io/cozystack/tree/main/packages/apps/postgres"
    click Redis "https://github.com/aenix-io/cozystack/tree/main/packages/apps/redis"
    click ObjectStorage "https://github.com/aenix-io/cozystack/tree/main/packages/apps/bucket"
    click BlockStorage "https://github.com/aenix-io/cozystack/tree/main/packages/system/seaweedfs"
    click Ingress "https://github.com/aenix-io/cozystack/tree/main/packages/system/ingress-nginx"
    click NetworkOverlay "https://github.com/aenix-io/cozystack/tree/main/packages/system/cilium"
    click Monitor "https://github.com/aenix-io/cozystack/tree/main/packages/system/monitoring-agents"
    click MetricsStorage "https://github.com/aenix-io/cozystack/tree/main/packages/system/victoria-metrics-operator"
    click Auth "https://github.com/aenix-io/cozystack/tree/main/packages/system/keycloak"
    click Dashboard "https://github.com/aenix-io/cozystack/tree/main/packages/system/dashboard"
```
