# percona/everest architecture

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

- Interactive diagram: https://gitdiagram.com/percona/everest
- Repository: https://github.com/percona/everest

## Overview

##### High-Level Architecture Components

a. Core Components:
- Frontend Layer (UI) - React-based web interface
- Backend Layer (API Server)
- Database Management Layer
- Kubernetes Integration Layer
- Authentication & Authorization Layer (RBAC)

b. External Components:
- Kubernetes Cluster
- Database Operators (MongoDB, PostgreSQL, XtraDB)
- Backup Storage Systems
- Monitoring Systems

##### Component Relationships

a. Frontend to Backend:
- REST API communication between UI and API server
- WebSocket connections for real-time updates
- Authentication flow

b. Backend to Kubernetes:
- Kubernetes API interactions
- Operator management connections
- Resource provisioning flow

##### Detailed Component Breakdown

a. Frontend (from /ui/apps/everest):
- React Components
- State Management
- API Client Layer
- Authentication Module

b. Backend (from /cmd and /internal):
- API Server
- Database Engine Management
- Backup Management
- Monitoring System
- RBAC Controller

c. CLI Component (from /cmd/cli):
- Command Processor
- Kubernetes Client
- Configuration Manager

##### Data Flow Representation

- Kubernetes control operations (bold lines)

##### Security Layer

Highlight:
- RBAC implementation
- Authentication flow
- JWT token management
- TLS/SSL encryption

##### Specific Implementation Details

a. Database Operations:
- Flows for database creation
- Backup/restore operations
- Monitoring integration
- Resource scaling

b. Kubernetes Integration:
- Custom Resource Definitions (CRDs)
- Operator management
- Namespace handling
- Resource provisioning

##### Additional Elements

Include:
- Version information
- External service connections
- Scaling indicators
- Health check flows

Key Considerations:

##### Cloud-native aspects
- Kubernetes integration points
- Scalability features
- Container orchestration

##### Database management
- Different database engine support
- Backup and restore flows
- Monitoring and metrics

##### Security architecture
- Authentication flows
- Authorization checks
- RBAC implementation

##### Operational flows
- Database provisioning
- Backup management
- Monitoring setup
- Resource scaling

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Legend"
        UI[User Interface]:::frontend
        API[API Component]:::backend
        DB[(Database)]:::database
        SEC{Security}:::security
        MON[Monitoring]:::monitoring
        K8S{{Kubernetes}}:::kubernetes
    end

    subgraph "Frontend Layer"
        UI_APP["React Web Interface"]:::frontend
        STATE["State Management"]:::frontend
        API_CLIENT["API Client Layer"]:::frontend
        AUTH_MOD["Authentication Module"]:::frontend
    end

    subgraph "Backend Layer"
        API_SERVER["API Server"]:::backend
        REQ_HANDLER["Request Handlers"]:::backend
        MIDDLEWARE["Middleware"]:::backend
        BIZ_LOGIC["Business Logic"]:::backend
    end

    subgraph "Database Management"
        DB_CLUSTER["Database Cluster Manager"]:::database
        DB_OPS["Database Operations"]:::database
        DB_PROVISION["Provisioning Service"]:::database
    end

    subgraph "Kubernetes Integration"
        K8S_CLIENT["Kubernetes Client"]:::kubernetes
        CRD["Custom Resource Definitions"]:::kubernetes
        OP_MANAGE["Operator Management"]:::kubernetes
    end

    subgraph "Security"
        RBAC["RBAC Controller"]:::security
        AUTH["Authentication Service"]:::security
        JWT["JWT Manager"]:::security
    end

    subgraph "Monitoring & Backup"
        MON_SYS["Monitoring System"]:::monitoring
        BACKUP["Backup Management"]:::monitoring
        RESTORE["Restore Service"]:::monitoring
    end

    subgraph "CLI"
        CLI_MAIN["CLI Main"]:::cli
        CMD_PROC["Command Processor"]:::cli
        CONFIG_MGR["Configuration Manager"]:::cli
    end

    UI_APP --> API_CLIENT
    API_CLIENT --> AUTH_MOD
    AUTH_MOD --> API_SERVER
    API_SERVER --> REQ_HANDLER
    REQ_HANDLER --> MIDDLEWARE
    MIDDLEWARE --> BIZ_LOGIC
    BIZ_LOGIC --> DB_CLUSTER
    DB_CLUSTER --> K8S_CLIENT
    K8S_CLIENT --> CRD
    CRD --> OP_MANAGE
    API_SERVER --> RBAC
    RBAC --> AUTH
    AUTH --> JWT
    DB_CLUSTER --> MON_SYS
    DB_CLUSTER --> BACKUP
    BACKUP --> RESTORE
    CLI_MAIN --> CMD_PROC
    CMD_PROC --> CONFIG_MGR
    CONFIG_MGR --> K8S_CLIENT

    %% Click events for component mapping
    click UI_APP "https://github.com/percona/everest/tree/main/ui/apps/everest/"
    click API_SERVER "https://github.com/percona/everest/tree/main/internal/server/"
    click DB_CLUSTER "https://github.com/percona/everest/blob/main/internal/server/database_cluster.go"
    click K8S_CLIENT "https://github.com/percona/everest/tree/main/pkg/kubernetes/"
    click RBAC "https://github.com/percona/everest/tree/main/pkg/rbac/"
    click CLI_MAIN "https://github.com/percona/everest/tree/main/cmd/cli/"
    click BACKUP "https://github.com/percona/everest/blob/main/internal/server/database_cluster_backup.go"
    click MON_SYS "https://github.com/percona/everest/blob/main/internal/server/monitoring_instance.go"

    classDef frontend fill:#2196F3,stroke:#fff,stroke-width:2px,color:#fff
    classDef backend fill:#4CAF50,stroke:#fff,stroke-width:2px,color:#fff
    classDef database fill:#FF9800,stroke:#fff,stroke-width:2px,color:#fff
    classDef kubernetes fill:#00BCD4,stroke:#fff,stroke-width:2px,color:#fff
    classDef security fill:#f44336,stroke:#fff,stroke-width:2px,color:#fff
    classDef monitoring fill:#9C27B0,stroke:#fff,stroke-width:2px,color:#fff
    classDef cli fill:#795548,stroke:#fff,stroke-width:2px,color:#fff
```
