# open-feature/flagd architecture

> Architecture diagram of the GitHub repository open-feature/flagd, 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/open-feature/flagd
- Repository: https://github.com/open-feature/flagd

## Overview

##### Main Components

a) Core Components:
- Feature Flag Evaluation Engine (core/pkg/evaluator)
- Flag Store (core/pkg/store)
- Sync System (core/pkg/sync)
- Service Layer (core/pkg/service)

b) External Interfaces:
- HTTP/gRPC API Endpoints
- Multiple Data Source Connectors
- OpenTelemetry Integration
- Provider SDKs

**┌─ Client Layer ─────────────────────────────┐**
- OpenFeature Provider SDKs (Various Languages) │
- ┬───────────────────────┘

**┌─ Communication Layer ──────────────────────┐**
- HTTP/gRPC APIs                            │
- ┬───────────────────────┘

**┌─ Core Service Layer ──────────────────────┐**
- ┌─────────────┐  ┌──────────┐  ┌───────┐ │
- Flag Evaluator│  │Flag Store│  │Metrics│ │
- ┘  └──────────┘  └───────┘ │
- ┬───────────────────────┘

**┌─ Sync Layer ──────────────────────────────┐**
- File │ HTTP │ gRPC │ Kubernetes │ Blob    │
- ┬───────────────────────┘

**┌─ Data Sources ────────────────────────────┐**
- Files │ APIs │ Remote Services │ K8s      │
- ┘

##### Key Elements to Highlight

- Blue: Core evaluation components
- Green: External interfaces
- Yellow: Data sync components
- Gray: Infrastructure components

b) Connection Types:

##### Integration Points

- OpenTelemetry integration for monitoring
- Provider SDK connections
- External data source connections
- Kubernetes integration points

##### Additional Details

- Targeting rules engine
- Percentage-based rollouts
- Real-time updates
- Multiple data source support
- OpenFeature compliance

##### Notes

- Version information
- Notes about scalability and deployment options

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef client fill:#a8d1ff,stroke:#000
    classDef core fill:#3498db,stroke:#000,color:#fff
    classDef sync fill:#f1c40f,stroke:#000
    classDef data fill:#95a5a6,stroke:#000
    classDef api fill:#2ecc71,stroke:#000
    classDef telemetry fill:#e74c3c,stroke:#000
    classDef service fill:#9b59b6,stroke:#000

    %% Client Layer
    subgraph ClientLayer
        SDK["OpenFeature Provider SDKs"]:::client
    end

    %% Communication Layer
    subgraph CommunicationLayer
        API["HTTP/gRPC API Endpoints"]:::api
        Middleware["Service Middleware"]:::service
    end

    %% Core Service Layer
    subgraph CoreServiceLayer
        Evaluator["Feature Flag Evaluation Engine"]:::core
        FlagStore["Flag Store"]:::core
        ServiceLayer["Service Layer"]:::service
        Telemetry["OpenTelemetry Integration"]:::telemetry
    end

    %% Sync Layer
    subgraph SyncLayer
        SyncService["Flag Sync Service"]:::sync
        FileSync["File Sync"]:::sync
        HTTPSync["HTTP Sync"]:::sync
        GRPCSync["gRPC Sync"]:::sync
        K8sSync["Kubernetes Sync"]:::sync
        BlobSync["Blob Storage Sync"]:::sync
    end

    %% Data Sources Layer
    subgraph DataSourcesLayer
        Files[(Files)]:::data
        APIs[(APIs)]:::data
        K8s[(Kubernetes)]:::data
        Blob[(Blob Storage)]:::data
    end

    %% Connections
    SDK --> API
    API --> Middleware
    Middleware --> ServiceLayer
    ServiceLayer --> Evaluator
    ServiceLayer --> FlagStore
    Telemetry -.-> ServiceLayer
    SyncService --> FlagStore
    FileSync & HTTPSync & GRPCSync & K8sSync & BlobSync --> SyncService
    FileSync --> Files
    HTTPSync --> APIs
    K8sSync --> K8s
    BlobSync --> Blob

    %% Click Events
    click Evaluator "https://github.com/open-feature/flagd/tree/main/core/pkg/evaluator/"
    click FlagStore "https://github.com/open-feature/flagd/tree/main/core/pkg/store/"
    click ServiceLayer "https://github.com/open-feature/flagd/tree/main/core/pkg/service/"
    click API "https://github.com/open-feature/flagd/tree/main/flagd/pkg/service/flag-evaluation/"
    click FileSync "https://github.com/open-feature/flagd/tree/main/core/pkg/sync/file/"
    click HTTPSync "https://github.com/open-feature/flagd/tree/main/core/pkg/sync/http/"
    click GRPCSync "https://github.com/open-feature/flagd/tree/main/core/pkg/sync/grpc/"
    click K8sSync "https://github.com/open-feature/flagd/tree/main/core/pkg/sync/kubernetes/"
    click BlobSync "https://github.com/open-feature/flagd/tree/main/core/pkg/sync/blob/"
    click Telemetry "https://github.com/open-feature/flagd/tree/main/core/pkg/telemetry/"
    click Middleware "https://github.com/open-feature/flagd/tree/main/flagd/pkg/service/middleware/"
    click SyncService "https://github.com/open-feature/flagd/tree/main/flagd/pkg/service/flag-sync/"

    %% Legend
    subgraph Legend
        Client["Client Components"]:::client
        CoreComp["Core Components"]:::core
        SyncComp["Sync Components"]:::sync
        DataComp["Data Sources"]:::data
        APIComp["API Components"]:::api
        TelemetryComp["Telemetry"]:::telemetry
        ServiceComp["Service Components"]:::service
    end
```
