# epuerta9/kitchenai architecture

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

- Interactive diagram: https://gitdiagram.com/epuerta9/kitchenai
- Repository: https://github.com/epuerta9/kitchenai

## Overview

##### Main components
- Application / Control Plane: Represented by the “kitchenai” directory and its various submodules (apps, core, dashboard, etc.). This component provides the unified API for application developers.
- Messaging Layer: Emphasize the use of NATS (referenced by configuration files, e.g. NATS_URL and related configuration scripts) that enables messaging, service discovery, and asynchronous communication among components.
- External Dependencies: Include external systems such as the relational database (Postgres, as indicated by DATABASE_URL), S3-compatible storage (using Minio for local development), Redis for caching if enabled, and monitoring/observability tools (Grafana is configured).
- Plugin Ecosystem: Illustrate additional extensibility points such as those in “plugins-community” and “whisk” which provide additional logic, integrations, or experimental features.

##### Relationships and Data Flow
- External components (database, cache, S3 cloud storage, and monitoring dashboards) are connected to the Control Plane. For instance, database interactions for persistence and minio/S3 for media storage must be represented; similarly, monitoring tools (Grafana) ingest logs/metrics from various components.

##### Architectural Patterns and Design Principles
- Loose coupling and modularity: Components such as individual bento modules are independently deployable and replaceable without affecting the overall system.
- Support for plug & play components: Indicate the plugin ecosystem where additional modules (like the Deepeval plugin) can be integrated seamlessly.
- Notation of service dependency and communication protocols (HTTP for backend API and NATS messaging for inter-service communication) is important.

##### Relevant Technologies and Frameworks
- Backend: Likely Django (hinted by common Django file names and structure), possibly with additional async handlers.
- Messaging: NATS as the high-performance messaging layer.
- Data Storage: PostgreSQL (database), Redis (if used), and S3/Minio for media storage.
- Frontend/Presentation: While the emphasis is on the API and admin/dashboard layers indicated by templates and static assets, note the existence of interactive playgrounds.
- Containerization and Deployment: Docker compose files, deployment scripts, and configuration files (e.g., for Grafana and NATS).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Entities
    Client["Client Applications"]:::external

    %% Application Layer
    subgraph "Application Layer"
        CP["Control Plane (KitchenAI API & Dashboard)"]:::control
    end

    %% Messaging & Communication Layer
    subgraph "Messaging & Communication"
        NATS["NATS Messaging Layer"]:::messaging
        NATSSetup["NATS Setup Script"]:::messaging
    end

    %% Execution Modules Layer
    subgraph "Execution Modules"
        Bento["Bento Boxes Layer (Individual AI workflows/modules)"]:::bento
    end

    %% Plugin Ecosystem Layer
    subgraph "Plugin Ecosystem"
        PluginComm["Plugin Ecosystem (Plugins Community)"]:::plugin
        Deepeval["Deepeval Plugin"]:::plugin
    end

    %% External Dependencies Layer
    subgraph "External Dependencies"
        Postgres["Postgres Database"]:::external
        Minio["Minio S3 Storage"]:::external
        Redis["Redis Cache"]:::external
        Grafana["Grafana Monitoring"]:::external
        EnvTemplate["Environment Template"]:::external
        DockerCompose["Docker Compose"]:::external
    end

    %% Connections
    Client -->|"HTTP"| CP
    CP -->|"sends_msg"| NATS
    NATS -->|"for_processing"| Bento
    Bento -->|"processed_msg"| NATS
    NATS -->|"returns_msg"| CP
    CP -->|"integrates"| PluginComm
    CP -->|"integrates"| Deepeval
    CP -->|"db_storage"| Postgres
    CP -->|"media_storage"| Minio
    CP -->|"cache"| Redis
    CP -->|"metrics"| Grafana
    CP -->|"config"| EnvTemplate
    CP -->|"config"| DockerCompose
    CP -->|"trigger"| NATSSetup
    NATSSetup -->|"configures"| NATS

    %% Click Events
    click CP "https://github.com/epuerta9/kitchenai/tree/main/kitchenai/"
    click Bento "https://github.com/epuerta9/kitchenai/tree/main/bento-community/"
    click NATS "https://github.com/epuerta9/kitchenai/tree/main/config/nats/"
    click NATSSetup "https://github.com/epuerta9/kitchenai/blob/main/scripts/setup_nats_operator.sh"
    click PluginComm "https://github.com/epuerta9/kitchenai/tree/main/plugins-community/"
    click Deepeval "https://github.com/epuerta9/kitchenai/tree/main/kitchenai/deepeval_plugin"
    click Grafana "https://github.com/epuerta9/kitchenai/tree/main/config/grafana/"
    click EnvTemplate "https://github.com/epuerta9/kitchenai/blob/main/.env.template"
    click DockerCompose "https://github.com/epuerta9/kitchenai/blob/main/docker-compose.yml"

    %% Styles
    classDef control fill:#AED6F1,stroke:#2E86C1,stroke-width:2px;
    classDef messaging fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef bento fill:#82E0AA,stroke:#28B463,stroke-width:2px;
    classDef plugin fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
```
