# besser-pearl/besser-agentic-framework architecture

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

- Interactive diagram: https://gitdiagram.com/besser-pearl/besser-agentic-framework
- Repository: https://github.com/besser-pearl/besser-agentic-framework

## Overview

##### Main Components Identification
The system should be divided into these major components:

a) Core Framework Components:
- Agent Core System
- NLP Engine
- Platform Integrations
- Database & Monitoring
- Libraries

b) External Integrations:
- LLM Services (OpenAI, HuggingFace, Replicate)
- Speech-to-Text Services
- Telegram Platform
- WebSocket Interfaces

**┌─ External Services Layer ─────────────────────┐**
- [OpenAI] [HuggingFace] [Replicate] [Telegram]│
- ┬───────────────────────────┘
- ↓
**┌─ Platform Layer ──────────────────────────────┐**
- [Telegram Platform] [WebSocket Platform]      │
- [Chat Widget UI]   [Streamlit UI]            │
- ┬───────────────────────────┘
- ↓
**┌─ Core Layer ───────────────────────────────────────────┐**
- ┌─ Agent Core ─┐ ┌─ NLP Engine ─┐ ┌─ Libraries ─┐     │
- States       │ │ Intent Class.│ │ Entities    │     │
- Transitions  │ │ NER          │ │ Intents     │     │
- Sessions     │ │ LLM          │ │ States      │     │
- Properties   │ │ RAG          │ │ Events      │     │
- ┘ └─────────────┘ └────────────┘      │
- ┬───────────────────────────────┘
- ↓
**┌─ Monitoring & Storage Layer ────────────────────┐**
- [Monitoring DB] [Monitoring UI] [Flow Graphs]   │
- ┘

##### Key Relationships to Highlight

a) Core Components:
- Agent Core manages states and transitions
- NLP Engine processes user inputs
- Libraries provide reusable components

b) Integration Points:
- Platform adapters connecting to external services
- NLP Engine integration with LLM services
- Monitoring system collecting data from all layers

##### Implementation Details

- Clear labels for all components
- Version information
- Dependencies and requirements notes

##### Additional Notes

- Configuration management
- Error handling flow
- Demonstrate session management
- Event system
- RAG system integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Services Layer
    subgraph ExternalServices
        OpenAI["OpenAI API"]
        HuggingFace["HuggingFace API"]
        Replicate["Replicate API"]
        Telegram["Telegram API"]
    end

    %% Platform Layer
    subgraph Platforms
        TelegramPlatform["Telegram Platform"]:::platform
        WebSocketPlatform["WebSocket Platform"]:::platform
        ChatWidget["Chat Widget UI"]:::platform
        StreamlitUI["Streamlit UI"]:::platform
    end

    %% Core Layer
    subgraph CoreSystem
        subgraph AgentCore["Agent Core"]
            States["States"]:::core
            Transitions["Transitions"]:::core
            Sessions["Sessions"]:::core
            Properties["Properties"]:::core
        end

        subgraph NLPEngine["NLP Engine"]
            IntentClass["Intent Classification"]:::nlp
            NER["Named Entity Recognition"]:::nlp
            LLM["LLM Integration"]:::nlp
            RAG["RAG System"]:::nlp
            Speech2Text["Speech-to-Text"]:::nlp
        end

        subgraph Libraries
            Entities["Entities"]:::lib
            Intents["Intents"]:::lib
            LibStates["States"]:::lib
            Events["Events"]:::lib
        end
    end

    %% Monitoring Layer
    subgraph Monitoring
        MonitoringDB["Monitoring Database"]:::monitoring
        MonitoringUI["Monitoring UI"]:::monitoring
        FlowGraphs["Flow Graphs"]:::monitoring
    end

    %% Relationships
    OpenAI --> LLM
    HuggingFace --> LLM
    Replicate --> LLM
    Telegram --> TelegramPlatform

    TelegramPlatform --> AgentCore
    WebSocketPlatform --> AgentCore
    ChatWidget --> WebSocketPlatform
    StreamlitUI --> WebSocketPlatform

    AgentCore --> NLPEngine
    NLPEngine --> Libraries
    AgentCore --> MonitoringDB
    MonitoringDB --> MonitoringUI
    MonitoringUI --> FlowGraphs

    %% Click Events
    click AgentCore "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/core/"
    click States "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/core/state.py"
    click Transitions "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/core/transition.py"
    click Sessions "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/core/session.py"
    click Properties "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/core/property.py"
    
    click NLPEngine "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/nlp/"
    click IntentClass "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/nlp/intent_classifier/"
    click NER "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/nlp/ner/"
    click LLM "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/nlp/llm/"
    click RAG "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/nlp/rag/"
    click Speech2Text "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/nlp/speech2text/"
    
    click TelegramPlatform "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/platforms/telegram/telegram_platform.py"
    click WebSocketPlatform "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/platforms/websocket/websocket_platform.py"
    click ChatWidget "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/platforms/websocket/chat_widget/"
    click StreamlitUI "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/platforms/websocket/streamlit_ui/"
    
    click MonitoringDB "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/db/monitoring_db.py"
    click MonitoringUI "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/db/monitoring_ui/"
    click FlowGraphs "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/blob/main/besser/agent/db/monitoring_ui/flow_graph.py"
    
    click Libraries "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/library/"
    click Entities "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/library/entity/"
    click Intents "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/library/intent/"
    click LibStates "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/library/state/"
    click Events "https://github.com/BESSER-PEARL/BESSER-Agentic-Framework/tree/main/besser/agent/library/event/"

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef nlp fill:#4CAF50,stroke:#2E7D32,color:white
    classDef platform fill:#FF9800,stroke:#F57C00,color:white
    classDef monitoring fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef lib fill:#607D8B,stroke:#455A64,color:white
```
