# cookethorg/cooketh-flow architecture

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

- Interactive diagram: https://gitdiagram.com/cookethorg/cooketh-flow
- Repository: https://github.com/cookethorg/cooketh-flow

## Overview

##### Project Type & Purpose
- Cooketh Flow is a Flutter-based application used to design, collaborate, and organize ideas visually. It supports customizable nodes, workflow management, and has cloud sync integration through Supabase.
- The multi-platform nature is evident from dedicated directories for Android, iOS, Linux, macOS, Windows, and even web support. This indicates that the system design should capture both the Flutter UI core and platform-specific adaptations.

##### Key Components to Highlight
- User Interface (UI) Layer:
- Built primarily with Flutter.
- Contains screens (found under lib/screens) for various views (dashboard, login, sign-up, workspace, etc.).
- Reusable widgets (under lib/core/widgets) such as nodes, connectors, toolboxes, and custom components.
- State Management & Routing:
- Providers (under lib/providers) handle authentication, dashboard state, workspace, and flow management.
- The routes files (lib/core/routes) configure in-app navigation, suggesting a modular routing structure.
- Core Business Logic & Services:
- Services (lib/core/services) provide platform file operations, Supabase integrations, etc.
- Utility functions and update management (in lib/core/utils) that support application logic.
- Data Models:
- Models (under lib/models) such as user, connection, flow_manager, and flow_node represent the core data entities.
- External & Cloud Services:
- Integration with Supabase for cloud sync, as described in the README and implemented in Supabase service code.
- The project also appears to support file-based configurations and possibly offline storage because of file_services.
- Platform-Specific Modules:
- Separate directories for each platform (android, ios, linux, macos, windows, web) contain build configurations, native integration files, and assets.
- Assets & Theming:
- Assets (including custom fonts in the assets/fonts directory) and theme definitions (under lib/core/theme) ensure a consistent UI across platforms.

##### Relationships & Interactions
- User Interaction:
- Users interact with the visual interface provided by Flutter. Touch events, drag-and-drop actions (for nodes), and clicks invoke changes in the UI.
- State Management:
- The Provider-based architecture mediates between UI widgets and underlying business logic. For example, user actions trigger state updates that, in turn, use services to sync with Supabase.
- Data Flow & External Integration:
- When a user updates a workflow, the change is captured by relevant UI components, processed by providers, and then dispatched to the Supabase service, ensuring real-time cloud sync.
- Navigation:
- Routing is managed by the app_route_config and app_route_const files, ensuring a clear pathway for navigation across different screens.
- Platform Layers:
- Platform-specific code (Android, iOS, etc.) interacts with the common Flutter code, enabling native performance and behavior.

##### Architectural Patterns & Design Principles
- Modular Architecture:
- Clear separation of concerns dividing UI components, state management/providers, core services, and data models.
- Provider Pattern for State Management:
- Helps in decoupling UI from state and business logic.
- Cross-Platform Abstraction:
- Flutter provides a unified UI layer while platform-specific directories ensure native integration.
- Layered Architecture:
- The design can be visualized in layers (Presentation, Business Logic, Data/Services, and Platform Specific Integrations).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level User Interaction
    U["User Interaction"]:::user

    %% Presentation Layer: Flutter UI
    subgraph "Presentation Layer: Flutter UI"
        S["Screens"]:::ui
        W["Reusable Widgets"]:::ui
    end

    %% Business Logic Layer: State & Routing
    subgraph "Business Logic: State Management & Routing"
        P["Providers"]:::state
        subgraph "Routing"
            R1["AppRoute Config"]:::state
            R2["AppRoute Const"]:::state
        end
    end

    %% Services Layer: Core Services & Utilities
    subgraph "Services Layer: Core Services & Utilities"
        subgraph "Services"
            FS["File Services"]:::service
            PFS["Platform File Service"]:::service
            SS["Supabase Service"]:::service
        end
        UTL["Utilities"]:::service
    end

    %% Data Layer: Data Models
    subgraph "Data Layer: Data Models"
        DM["Data Models"]:::data
    end

    %% External Integration
    subgraph "External Integration"
        SC["Supabase Cloud"]:::cloud
    end

    %% Assets & Theming
    subgraph "Assets & Theming"
        A["Assets (Fonts)"]:::assets
        T["Theme Definitions"]:::assets
    end

    %% Platform-Specific Modules
    subgraph "Platform-Specific Modules"
        And["Android"]:::platform
        iOS["iOS"]:::platform
        Lin["Linux"]:::platform
        Mac["macOS"]:::platform
        Win["Windows"]:::platform
        Web["Web"]:::platform
    end

    %% Connections: User to Presentation
    U -->|"uses"| S
    U -->|"uses"| W

    %% Presentation to Business Logic
    S -->|"triggers"| P
    W -->|"triggers"| P

    %% Business Logic: Providers to Routing
    P -->|"configures"| R1
    P -->|"configures"| R2

    %% Routing affects Presentation (Navigation)
    R1 -->|"navigatesTo"| S
    R2 -->|"navigatesTo"| S

    %% Business Logic to Services & Utilities
    P -->|"initiates"| FS
    P -->|"initiates"| PFS
    P -->|"initiates"| SS
    P -->|"utilizes"| UTL

    %% Services to Data and External Integration
    P -->|"updates"| DM
    SS -->|"syncsWith"| SC

    %% Presentation Layer uses Assets & Theming
    S -->|"styledBy"| T
    S -->|"loads"| A
    W -->|"styledBy"| T
    W -->|"loads"| A

    %% Flutter UI compiled for Platform Modules
    S -->|"compiledFor"| And
    S -->|"compiledFor"| iOS
    S -->|"compiledFor"| Lin
    S -->|"compiledFor"| Mac
    S -->|"compiledFor"| Win
    S -->|"compiledFor"| Web

    %% Click Events
    click S "https://github.com/cookethorg/cooketh-flow/tree/master/lib/screens"
    click W "https://github.com/cookethorg/cooketh-flow/tree/master/lib/core/widgets"
    click P "https://github.com/cookethorg/cooketh-flow/tree/master/lib/providers"
    click R1 "https://github.com/cookethorg/cooketh-flow/blob/master/lib/core/routes/app_route_config.dart"
    click R2 "https://github.com/cookethorg/cooketh-flow/blob/master/lib/core/routes/app_route_const.dart"
    click FS "https://github.com/cookethorg/cooketh-flow/blob/master/lib/core/services/file_services.dart"
    click PFS "https://github.com/cookethorg/cooketh-flow/blob/master/lib/core/services/platform_file_service.dart"
    click SS "https://github.com/cookethorg/cooketh-flow/blob/master/lib/core/services/supabase_service.dart"
    click UTL "https://github.com/cookethorg/cooketh-flow/tree/master/lib/core/utils"
    click DM "https://github.com/cookethorg/cooketh-flow/tree/master/lib/models"
    click A "https://github.com/cookethorg/cooketh-flow/tree/master/assets/fonts"
    click T "https://github.com/cookethorg/cooketh-flow/blob/master/lib/core/theme/app_theme.dart"
    click And "https://github.com/cookethorg/cooketh-flow/tree/master/android"
    click iOS "https://github.com/cookethorg/cooketh-flow/tree/master/ios"
    click Lin "https://github.com/cookethorg/cooketh-flow/tree/master/linux"
    click Mac "https://github.com/cookethorg/cooketh-flow/tree/master/macos"
    click Win "https://github.com/cookethorg/cooketh-flow/tree/master/windows"
    click Web "https://github.com/cookethorg/cooketh-flow/tree/master/web"

    %% Styles
    classDef user fill:#f8c291,stroke:#e67e22,stroke-width:2px;
    classDef ui fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef state fill:#abebc6,stroke:#1e8449,stroke-width:2px;
    classDef service fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef data fill:#d2b4de,stroke:#7d3c98,stroke-width:2px;
    classDef cloud fill:#f7dc6f,stroke:#f1c40f,stroke-width:2px;
    classDef assets fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef platform fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
```
