# krateoplatformops/core-provider architecture

> Architecture diagram of the GitHub repository krateoplatformops/core-provider, 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/krateoplatformops/core-provider
- Repository: https://github.com/krateoplatformops/core-provider

## Overview

##### Main Components

a) Core Components:
- Core Provider Controller Manager
- Composition Definition Controller
- Dynamic Controller Generator
- Helm Chart Manager
- RBAC Generator
- Authentication Manager

b) External Components:
- Kubernetes API Server
- Helm Repositories
- OCI Registries
- Krateo BFF (Backend-for-Frontend)

##### Component Relationships and Interactions

a) Input Layer:
- CompositionDefinition CRDs
- Authentication Secrets
- Helm Charts (from various sources)

b) Processing Layer:
- Controller Logic
- Chart Processing
- RBAC Generation
- CRD Generation

c) Output Layer:
- Generated Dynamic Controllers
- Deployed Helm Releases
- Generated RBAC Policies

##### Specific Implementation Details

- Rectangles: Core components
- Hexagons: External services
- Rounded rectangles: Controllers

- Blue: Core provider components
- Green: External services
- Yellow: Generated resources
- Gray: Infrastructure components

##### Key Flows

a) Chart Processing Flow:
**CompositionDefinition → Core Provider → Helm Chart Download → Schema Validation → CRD Generation**

b) Controller Generation Flow:
**Core Provider → Dynamic Controller Generation → RBAC Policy Creation → Controller Deployment**

c) Authentication Flow:
**Secrets → Authentication Manager → OCI/Helm Repository Access**

##### Important Subsystems

a) Chart Management System:
- Chart downloaders (OCI, Helm repo, TGZ)
- Schema validators
- Version managers

b) Controller Management:
- Dynamic controller generation
- RBAC policy management
- Lifecycle management

c) Authentication System:
- Secret management
- Registry configuration
- Access control

##### Additional Elements

Annotations showing:
- Environment variable configurations
- Webhook interactions
- Leader election mechanism
- Reconciliation loops

##### Monitoring and Control

Following aspects:
- Health check flows
- Metrics collection points
- Debug logging paths
- Resource cleanup mechanisms

This architecture should reflect the project's key features:
- Multi-version support
- Authentication handling
- RBAC generation
- Dynamic controller management
- Automatic cleanup mechanisms
- Schema validation
- Helm chart management

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        CD[CompositionDefinition CRDs]
        AS[Authentication Secrets]
        HC[Helm Charts]
    end

    subgraph "Core Provider"
        CPCM[Core Provider Controller Manager]
        CDC[Composition Definition Controller]
        DCG[Dynamic Controller Generator]
        HCM[Helm Chart Manager]
        RBACG[RBAC Generator]
        AM[Authentication Manager]
    end

    subgraph "Chart Processing"
        OCI[OCI Charts]
        HR[Helm Repository]
        TGZ[TGZ Charts]
        SV[Schema Validator]
    end

    subgraph "Generated Resources"
        CRDS[Generated CRDs]
        RBAC[RBAC Policies]
        DC[Dynamic Controllers]
    end

    subgraph "External Services"
        K8S[Kubernetes API]
        OCIR[OCI Registry]
        HELMR[Helm Registry]
        BFF[Krateo BFF]
    end

    %% Core Flow
    CD --> CDC
    CDC --> DCG
    DCG --> HCM
    HCM --> RBACG
    AS --> AM

    %% Chart Processing
    HCM --> OCI
    HCM --> HR
    HCM --> TGZ
    OCI --> SV
    HR --> SV
    TGZ --> SV

    %% Authentication Flow
    AM --> OCIR
    AM --> HELMR

    %% Generated Resources
    DCG -.-> DC
    RBACG -.-> RBAC
    SV -.-> CRDS

    %% External Interactions
    DC --> K8S
    RBAC --> K8S
    CRDS --> K8S
    BFF --> CPCM

    %% Styling
    classDef core fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef external fill:#98FB98,stroke:#333,stroke-width:2px
    classDef generated fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef input fill:#E6E6FA,stroke:#333,stroke-width:2px

    class CPCM,CDC,DCG,HCM,RBACG,AM core
    class K8S,OCIR,HELMR,BFF external
    class CRDS,RBAC,DC generated
    class CD,AS,HC input

    %% Click Events
    click CPCM "https://github.com/krateoplatformops/core-provider/blob/main/server/main.go"
    click CDC "https://github.com/krateoplatformops/core-provider/blob/main/internal/controllers/compositiondefinitions/compositiondefinitions.go"
    click DCG "https://github.com/krateoplatformops/core-provider/blob/main/internal/controllers/compositiondefinitions/generator/chart.go"
    click HCM "https://github.com/krateoplatformops/core-provider/blob/main/internal/helm/getter/getter.go"
    click RBACG "https://github.com/krateoplatformops/core-provider/blob/main/internal/tools/rbacgen/rbacgen.go"
    click AM "https://github.com/krateoplatformops/core-provider/blob/main/internal/tools/resolvers/secrets.go"
    click CD "https://github.com/krateoplatformops/core-provider/blob/main/crds/core.krateo.io_compositiondefinitions.yaml"
    click OCI "https://github.com/krateoplatformops/core-provider/blob/main/internal/helm/getter/oci.go"
    click HR "https://github.com/krateoplatformops/core-provider/blob/main/internal/helm/getter/helm.go"
    click TGZ "https://github.com/krateoplatformops/core-provider/blob/main/internal/helm/getter/tgz.go"
    click RBAC "https://github.com/krateoplatformops/core-provider/tree/main/internal/tools/rbactools"
    click CRDS "https://github.com/krateoplatformops/core-provider/blob/main/internal/tools/crd/crd.go"
```
