# ai-flowx/flowx architecture

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

- Interactive diagram: https://gitdiagram.com/ai-flowx/flowx
- Repository: https://github.com/ai-flowx/flowx

## Overview

##### Main Components

a) Core Components (Primary Layer):
- Agent System (/agent)
- Flow Management (/flow)
- GPT Integration (/gpt)
- Memory Management (/memory)
- Task Management (/task)
- Team Management (/team)

b) Infrastructure Components (Support Layer):
- Cache System (/cache)
- Storage System (/store)
- Tool System (/tool)
- Configuration Management (/config)

##### External Interface Layer
- HTTP Server (port 8080 as default)
- WeChat Channel Integration (from flow/wechat.go)

##### Core Processing Layer
- Agent Orchestration
- Flow Management
- Task Processing
- Team Coordination

##### Service Layer
- GPT Integration (with providers like doubao-chat)
- Memory Management (both short-term and long-term)
- Tool Integration

##### Infrastructure Layer
- Cache System (with multiple providers)
- Vector Store (supporting Chroma, PostgreSQL, SQLite)
- Configuration Management

##### Key Relationships to Highlight

- Bidirectional communication between agents and the flow manager
- Memory access patterns (short-term vs. long-term)
- Demonstrate tool integration points
- Cache and storage interaction flows
- WeChat channel integration path

##### Specific Design Elements

Use the following visual elements:
- Blue rectangles for core components
- Green rectangles for external interfaces
- Yellow rectangles for service components
- Gray rectangles for infrastructure components

##### Component Details

For each major component, include:
- Component name
- Key responsibilities
- External dependencies
- Communication protocols

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef service fill:#FFE4B5,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#DCDCDC,stroke:#333,stroke-width:2px

    %% External Interface Layer
    subgraph ExternalLayer["External Interface Layer"]
        HTTP["HTTP Server\nPort 8080"]:::external
        WeChat["WeChat Channel"]:::external
    end

    %% Core Processing Layer
    subgraph CoreLayer["Core Processing Layer"]
        Agent["Agent System"]:::core
        Flow["Flow Management"]:::core
        Task["Task Processing"]:::core
        Team["Team Coordination"]:::core
    end

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        GPT["GPT Integration\n(doubao-chat)"]:::service
        Memory["Memory Management"]:::service
        Tools["Tool Integration"]:::service
        
        subgraph MemoryTypes["Memory Types"]
            ShortTerm["Short-term Memory"]:::service
            LongTerm["Long-term Memory"]:::service
        end
    end

    %% Infrastructure Layer
    subgraph InfraLayer["Infrastructure Layer"]
        Cache["Cache System"]:::infrastructure
        Store["Vector Store"]:::infrastructure
        Config["Configuration\nManagement"]:::infrastructure
        
        subgraph StoreProviders["Store Providers"]
            Chroma["Chroma"]:::infrastructure
            Postgres["PostgreSQL"]:::infrastructure
            SQLite["SQLite"]:::infrastructure
        end
    end

    %% Relationships
    HTTP --> Flow
    WeChat --> Flow
    Flow --> Agent
    Agent --> Task
    Task --> Team
    Agent --> Tools
    Agent --> Memory
    Memory --> ShortTerm
    Memory --> LongTerm
    Agent --> GPT
    GPT --> Cache
    Memory --> Store
    Store --> Chroma
    Store --> Postgres
    Store --> SQLite
    Config -.-> CoreLayer
    Config -.-> ServiceLayer
    Config -.-> InfraLayer

    %% Click Events
    click Agent "https://github.com/ai-flowx/flowx/blob/main/agent/agent.go"
    click Flow "https://github.com/ai-flowx/flowx/blob/main/flow/flow.go"
    click GPT "https://github.com/ai-flowx/flowx/blob/main/gpt/gpt.go"
    click Memory "https://github.com/ai-flowx/flowx/blob/main/memory/memory.go"
    click ShortTerm "https://github.com/ai-flowx/flowx/blob/main/memory/shortterm.go"
    click LongTerm "https://github.com/ai-flowx/flowx/blob/main/memory/longterm.go"
    click Task "https://github.com/ai-flowx/flowx/blob/main/task/task.go"
    click Team "https://github.com/ai-flowx/flowx/blob/main/team/team.go"
    click Cache "https://github.com/ai-flowx/flowx/blob/main/cache/cache.go"
    click Store "https://github.com/ai-flowx/flowx/blob/main/store/store.go"
    click Chroma "https://github.com/ai-flowx/flowx/blob/main/store/chroma.go"
    click Postgres "https://github.com/ai-flowx/flowx/blob/main/store/postgres.go"
    click SQLite "https://github.com/ai-flowx/flowx/blob/main/store/sqlite.go"
    click Tools "https://github.com/ai-flowx/flowx/blob/main/tool/tool.go"
    click Config "https://github.com/ai-flowx/flowx/blob/main/config/config.go"
    click WeChat "https://github.com/ai-flowx/flowx/blob/main/flow/wechat.go"

    %% Legend
    subgraph Legend["Legend"]
        L1["External Interface"]:::external
        L2["Core Component"]:::core
        L3["Service Component"]:::service
        L4["Infrastructure"]:::infrastructure
    end
```
