# tm9657/flow-like architecture

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

- Interactive diagram: https://gitdiagram.com/tm9657/flow-like
- Repository: https://github.com/tm9657/flow-like

## Overview

##### Main Components
- Runtime Core – At the center is the Rust-based core runtime that executes node-based logic in approximately 100 microseconds. This core handles workflow execution, incorporates AI integrations, and processes nodes that encapsulate discrete functions.
- Backend Services – Found in the apps/backend directory (with its own Dockerfiles, Prisma schema, and Terraform configurations for cloud/AWS deployment). This layer exposes APIs, manages entity models (see the extensive “entity” folders in both apps/backend and packages/core), and controls routes for authentication, health checks, user info, and store operations.
- Frontend & Desktop UI – Multiple frontends exist:
- A desktop application (using Tauri, React, and TypeScript in apps/desktop) with a graphical editor, settings views, and onboarding.
- A web application (in apps/web-app and apps/website) that provides additional user or dashboard interfaces.
- A UI package (in packages/ui) that encapsulates reusable components (for flows, nodes, dialogs, etc.).
- Schema & Models – The packages/schema as well as references in packages/core define the JSON and other structured schemas used to describe nodes, flows, bits, and integrations.
- Developer Tools & Documentation – The apps/docs and tools directories (plus the GitHub actions CI/CD workflows) support documentation, testing, code quality checks, schema generation, and build automation.
- Integrations and Adapters – Look at the “adapter - legacy” folders in the desktop’s src-tauri directory and the various external service integrations (e.g., provider proxies, storage adapters, mail adapters) that allow the system to connect with AI models, file storage systems, and other external services.

##### Relationships and Interactions
- The Core Runtime interacts directly with the Back-end APIs, which in turn communicate with the database (using ORM interfaces and Prisma schema) and external services (via adapter patterns).
- Frontends (both desktop and web) connect to the backend through local APIs. They also interact with the runtime for executing node-based workflows.
- UI components (from packages/ui) are used by the frontends to render flow boards, node interfaces, and settings dialogs.
- The schema layer feeds into both the core runtime and the UI layer to enforce consistent data formats.
- CI/CD pipelines indicated in the .github directory and Docker configurations ensure that deployments and testing are automated, with clear separation between environment setups (development, alpha-release, production).

##### Architectural Patterns and Design Principles
- Modular (Node-Based) Architecture: Flows are split into nodes, making the system highly modular, testable, and scalable.
- Unification: A single, unified runtime supports different deployment targets (on-edge, on-prem, cloud) and integrates AI capabilities seamlessly.
- Separation of Concerns: Distinct directories for backend, desktop, web, and UI packages emphasize clear boundaries between presentation, business logic, and infrastructure.
- Extensibility and Integration: The legacy adapters and integration frameworks allow developers to extend functionality easily, whether for new backend services or external APIs.

##### Final Assembly
- Branch out to illustrate the Backend Service layer (with its routing, entity management, and deployment configurations).
- Two primary frontends (desktop and web) independently, but connected to the backend.
- Ancillary components like the UI library and schema definitions feeding into both core and frontends.
- Deployment and infrastructure-related items (Docker, Terraform, CI/CD) together to represent the operational layer.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core and Business Logic
    CoreRuntime["Core Runtime"]:::core
    Backend["Backend Services"]:::backend
    Integrations["Integrations and Adapters"]:::integration
    Infrastructure["Infrastructure & Deployment"]:::infra

    CoreRuntime -->|"executes"| Integrations
    Backend -->|"interacts"| CoreRuntime
    Backend -->|"deployed_by"| Infrastructure

    %% Frontend
    Desktop["Desktop Application"]:::desktop
    Web["Web Application"]:::web
    UI["UI Library"]:::ui

    Desktop -->|"calls"| Backend
    Web -->|"calls"| Backend
    Desktop ---|"uses"| UI
    Web ---|"uses"| UI

    %% Data & Models
    Schema["Schema & Models"]:::schema
    Entities["Entity Definitions"]:::schema
    Models["Model Definitions"]:::schema

    Schema -->|"defines"| CoreRuntime
    Schema -->|"defines"| UI
    Entities -->|"supplements"| Schema
    Models -->|"supplements"| Schema

    %% Developer Tools & Documentation
    Developer["Developer Tools & Documentation"]:::developer
    Developer -->|"automates"| Infrastructure

    %% Click Events
    click CoreRuntime "https://github.com/tm9657/flow-like/tree/main/packages/core"
    click Backend "https://github.com/tm9657/flow-like/tree/main/apps/backend"
    click Desktop "https://github.com/tm9657/flow-like/tree/main/apps/desktop"
    click Desktop "https://github.com/tm9657/flow-like/tree/main/apps/desktop/src-tauri"
    click Web "https://github.com/tm9657/flow-like/tree/main/apps/web-app"
    click Web "https://github.com/tm9657/flow-like/tree/main/apps/website"
    click UI "https://github.com/tm9657/flow-like/tree/main/packages/ui"
    click Schema "https://github.com/tm9657/flow-like/tree/main/packages/schema"
    click Entities "https://github.com/tm9657/flow-like/tree/main/packages/core/entity"
    click Models "https://github.com/tm9657/flow-like/tree/main/packages/core/models"
    click Developer "https://github.com/tm9657/flow-like/tree/main/apps/docs"
    click Developer "https://github.com/tm9657/flow-like/tree/main/tools"
    click Integrations "https://github.com/tm9657/flow-like/tree/main/apps/desktop/src-tauri/src/adapter - legacy"

    %% Styles
    classDef core fill:#f9e79f,stroke:#d4ac0d,stroke-width:2px;
    classDef backend fill:#fad7a0,stroke:#e67e22,stroke-width:2px;
    classDef integration fill:#f5b7b1,stroke:#e74c3c,stroke-width:2px;
    classDef infra fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
    classDef desktop fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef web fill:#a9dfbf,stroke:#27ae60,stroke-width:2px;
    classDef ui fill:#f7dc6f,stroke:#f1c40f,stroke-width:2px;
    classDef schema fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef developer fill:#f5cba7,stroke:#e59866,stroke-width:2px;
```
