# krish-adi/barfi architecture

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

- Interactive diagram: https://gitdiagram.com/krish-adi/barfi
- Repository: https://github.com/krish-adi/barfi

## Overview

##### Main Components

a) Frontend Layer:
- Vue.js application with BaklavaJS integration
- Streamlit widget component
- Client-side rendering and interaction logic

b) Backend Layer:
- Core Barfi engine
- Block management system
- Computation engine
- Schema management

c) Integration Layer:
- Python API interface
- Streamlit integration
- Future Jupyter Notebook integration (planned)

##### Key Architectural Elements

a) Core Components:
- Block Builder: Handles block definition and properties
- Compute Engine: Manages execution of the flow
- Schema Manager: Handles saving and loading of flow schemas
- Option Builder: Manages block configuration options

b) Frontend Architecture:
- Vue.js components for visual programming interface
- Streamlit connection handling
- CSS and asset management

**[User Interface Layer]**
- ↓
**[Integration Layer]**
- ↓
**[Core Engine Layer]**
- ↓
**[Execution Layer]**

##### Component relationships
- Double lines: API boundaries

##### Specific Elements

a) Frontend Section:
**[Vue.js Frontend] ← → [BaklavaJS]**
- ↓
**[Streamlit Widget]**

b) Core Engine Section:
**[Block Builder] ← → [Option Builder]**
- ↓
**[Compute Engine] ← → [Schema Manager]**

c) Integration Layer:
**[Python API] ← → [Streamlit Integration]**

##### Important Details to Highlight

- The flow-based programming nature of the system
- Block interface connections
- Data flow between components
- Schema persistence
- Computation execution path

##### Technical Specifications

Key technologies:
- Vue.js/TypeScript (Frontend)
- Python (Backend)
- Streamlit (Integration)
- BaklavaJS (Visual Programming Interface)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef ui fill:#3498db,color:white
    classDef core fill:#2ecc71,color:white
    classDef schema fill:#f1c40f,color:black
    classDef compute fill:#e67e22,color:white
    classDef integration fill:#9b59b6,color:white
    classDef static fill:#95a5a6,color:white

    %% UI Layer
    subgraph UI
        FlowEditor["Flow Editor"]:::ui
        BlockEditor["Block Editor"]:::ui
        ContextMenu["Context Menu"]:::ui
        UIComponents["UI Components"]:::ui
        StaticAssets["Static Assets"]:::static
    end

    %% Core Framework Layer
    subgraph Core
        subgraph BlockSystem["Block System"]
            BlockBase["Block Base"]:::core
            BlockInterface["Block Interface"]:::core
            BlockOptions["Block Options"]:::core
            BlockPrep["Block Preparation"]:::core
        end

        subgraph SchemaManagement["Schema Management"]
            SchemaTypes["Schema Types"]:::schema
            SchemaManager["Schema Manager"]:::schema
            FlowSchema["Flow Schema Handlers"]:::schema
        end

        subgraph ComputeEngine["Compute Engine"]
            ComputeBase["Computation Base"]:::compute
            DataFlow["Data Flow Management"]:::compute
            ExecutionPipeline["Execution Pipeline"]:::compute
        end
    end

    %% Integration Layer
    subgraph Integration
        StreamlitWidget["Streamlit Widget"]:::integration
        JupyterWidget["Jupyter Widget (Planned)"]:::integration
        ExternalIntegration["External Integration"]:::integration
    end

    %% Version Migration
    VersionMigration["Version Migration (v0 to v1)"]:::core

    %% Relationships
    FlowEditor --> BlockEditor
    FlowEditor --> ContextMenu
    FlowEditor --> UIComponents
    UIComponents --> StaticAssets

    BlockSystem --> SchemaManagement
    SchemaManagement --> ComputeEngine
    ComputeEngine --> Integration

    VersionMigration --> SchemaManagement

    %% Click events
    click FlowEditor "https://github.com/krish-adi/barfi/blob/main/ui-flow/src/components/flow/flow-editor.tsx"
    click ContextMenu "https://github.com/krish-adi/barfi/blob/main/ui-flow/src/components/flow/context-menu.tsx"
    click BlockBase "https://github.com/krish-adi/barfi/blob/main/src/barfi/flow/block/base.py"
    click BlockInterface "https://github.com/krish-adi/barfi/blob/main/src/barfi/flow/block/interface.py"
    click BlockOptions "https://github.com/krish-adi/barfi/blob/main/src/barfi/flow/block/option.py"
    click BlockPrep "https://github.com/krish-adi/barfi/blob/main/src/barfi/flow/block/prepare.py"
    click SchemaManager "https://github.com/krish-adi/barfi/blob/main/src/barfi/flow/schema/manage.py"
    click SchemaTypes "https://github.com/krish-adi/barfi/blob/main/src/barfi/flow/schema/types.py"
    click ComputeBase "https://github.com/krish-adi/barfi/blob/main/src/barfi/flow/compute/base.py"
    click StreamlitWidget "https://github.com/krish-adi/barfi/blob/main/src/barfi/flow/streamlit/base.py"
    click UIComponents "https://github.com/krish-adi/barfi/tree/main/ui-flow/src/components/ui"
    click VersionMigration "https://github.com/krish-adi/barfi/blob/main/src/barfi/utils/v0_migration.py"
    click StaticAssets "https://github.com/krish-adi/barfi/tree/main/src/barfi/flow/streamlit/static/assets"
```
