# phidatahq/phidata architecture

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

- Interactive diagram: https://gitdiagram.com/phidatahq/phidata
- Repository: https://github.com/phidatahq/phidata

## Overview

##### High-Level Architecture Components

The system should be divided into these main components:

a) Core Components:
- Agent System
- Model Layer
- Tools Layer
- Knowledge Base
- Memory System
- Vector Database Integration
- Storage System

b) Supporting Components:
- Playground UI
- Monitoring & Debugging
- Authentication System
- CLI Interface

##### Detailed Component Breakdown

a) Agent System (Central Component):
- Multi-modal Agent Implementation
- Agent Team Orchestration
- Reasoning Engine
- Agent Storage
- Session Management

b) Model Layer:
- OpenAI Integration
- Azure OpenAI Integration
- Anthropic Integration
- Google AI Integration
- Other LLM Providers
- Model Registry

c) Tools Layer:
- Web Search Tools
- Financial Tools
- File Operation Tools
- Database Tools
- API Integration Tools
- Custom Tool Registry

d) Knowledge Base:
- Document Processing
- PDF Knowledge Base
- Website Knowledge Base
- CSV Knowledge Base
- Wikipedia Knowledge Base
- YouTube Knowledge Base

e) Memory System:
- Short-term Memory
- Long-term Memory
- Memory Storage (SQLite/PostgreSQL)
- Memory Summarization

f) Vector Database Integration:
- ChromaDB
- LanceDB
- Pinecone
- PGVector
- Qdrant
- SingleStore

##### Connection and Data Flow

a) Primary Data Flows:
- User Input → Agent System
- Agent System → Model Layer
- Agent System → Tools Layer
- Agent System → Knowledge Base
- Agent System → Memory System
- Agent System → Vector Database

b) Secondary Flows:
- Authentication Flow
- Monitoring Data Flow
- Storage Operations Flow

##### Implementation Details

Notes for:
- Key Python dependencies
- Required API keys
- Storage requirements
- Deployment considerations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        PG["Playground UI"]:::ui
        API["API Layer"]:::api
    end

    subgraph Core["Core Agent Layer"]
        AS["Agent System"]:::core
        TO["Team Orchestrator"]:::core
        RE["Reasoning Engine"]:::core
    end

    subgraph Models["Model Layer"]
        ML["Model Base"]:::model
        MP["Model Providers"]:::model
        RH["Response Handlers"]:::model
    end

    subgraph Tools["Tools Layer"]
        TR["Tool Registry"]:::tool
        TB["Tool Base"]:::tool
        TI["Tool Implementations"]:::tool
    end

    subgraph Knowledge["Knowledge & Memory"]
        KB["Knowledge Base"]:::knowledge
        MS["Memory System"]:::knowledge
        MM["Memory Manager"]:::knowledge
    end

    subgraph Storage["Storage Systems"]
        SS["Storage System"]:::storage
        VS["Vectorstore System"]:::storage
        DA["Database Adapters"]:::storage
    end

    subgraph Processing["Document Processing"]
        DP["Document Processor"]:::processing
        CS["Chunking Strategies"]:::processing
        FH["File Handlers"]:::processing
    end

    subgraph Embeddings["Embeddings System"]
        EB["Embeddings Base"]:::embeddings
        EP["Embeddings Providers"]:::embeddings
    end

    %% Connections
    PG --> API
    API --> AS
    AS --> TO
    AS --> RE
    AS <--> ML
    ML --> MP
    ML --> RH
    AS <--> TR
    TR --> TB
    TB --> TI
    AS <--> KB
    AS <--> MS
    MS --> MM
    KB --> SS
    MS --> SS
    SS --> DA
    KB --> VS
    DP --> VS
    DP --> CS
    DP --> FH
    VS --> EB
    EB --> EP

    %% Click Events
    click AS "https://github.com/phidatahq/phidata/blob/main/phi/agent/agent.py"
    click TO "https://github.com/phidatahq/phidata/blob/main/phi/workflow/workflow.py"
    click RE "https://github.com/phidatahq/phidata/blob/main/phi/reasoning/step.py"
    click ML "https://github.com/phidatahq/phidata/blob/main/phi/model/base.py"
    click MP "https://github.com/phidatahq/phidata/tree/main/phi/model"
    click TR "https://github.com/phidatahq/phidata/blob/main/phi/tools/tool_registry.py"
    click TB "https://github.com/phidatahq/phidata/blob/main/phi/tools/tool.py"
    click TI "https://github.com/phidatahq/phidata/tree/main/phi/tools"
    click KB "https://github.com/phidatahq/phidata/blob/main/phi/knowledge/base.py"
    click MS "https://github.com/phidatahq/phidata/blob/main/phi/memory/memory.py"
    click MM "https://github.com/phidatahq/phidata/blob/main/phi/memory/manager.py"
    click SS "https://github.com/phidatahq/phidata/blob/main/phi/storage/agent/base.py"
    click DA "https://github.com/phidatahq/phidata/tree/main/phi/storage/agent"
    click VS "https://github.com/phidatahq/phidata/blob/main/phi/vectordb/base.py"
    click DP "https://github.com/phidatahq/phidata/blob/main/phi/document/base.py"
    click CS "https://github.com/phidatahq/phidata/tree/main/phi/document/chunking"
    click FH "https://github.com/phidatahq/phidata/tree/main/phi/document/reader"
    click EB "https://github.com/phidatahq/phidata/blob/main/phi/embedder/base.py"
    click EP "https://github.com/phidatahq/phidata/tree/main/phi/embedder"
    click API "https://github.com/phidatahq/phidata/blob/main/phi/api/api.py"
    click PG "https://github.com/phidatahq/phidata/blob/main/phi/playground/playground.py"

    %% Styles
    classDef core fill:#2374ab
    classDef model fill:#48a9a6
    classDef tool fill:#e4572e
    classDef knowledge fill:#17bebb
    classDef storage fill:#533a71
    classDef processing fill:#db7c26
    classDef embeddings fill:#2e5339
    classDef ui fill:#4392f1
    classDef api fill:#4392f1

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Model Components"]:::model
        L3["Tool Components"]:::tool
        L4["Knowledge Components"]:::knowledge
        L5["Storage Components"]:::storage
        L6["Processing Components"]:::processing
        L7["Embeddings Components"]:::embeddings
        L8["UI/API Components"]:::ui
    end
```
