# kantariyaraj/ai_agent_examples architecture

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

- Interactive diagram: https://gitdiagram.com/kantariyaraj/ai_agent_examples
- Repository: https://github.com/kantariyaraj/ai_agent_examples

## Overview

##### Main Components
- For each agent project, pinpoint the key building blocks. For instance:
- PDF RAG Agent: Components like the PDF upload service, embeddings service, a text splitter, and question-answer engine.
- CONFLUENCE RAG Agent: A similar architecture with data ingestion/training of Confluence content, a question-answer service, and the Groq LLM integration.
- Simple Chatbot: A conversational interface (likely a web front-end), a conversation history/context manager, and an integration point with Groq’s Mixtral model.
- MySQL Chat Agent: The chat interface paired with a backend that converts natural language queries into SQL commands, a MySQL database, and configuration files (like agents.yaml & tasks.yaml).
- Travel Planning Agent: A user interface (UI folder), a series of agent modules (for flight info, weather checking, itinerary planning, etc.), a state management module, and integrations with external Flight and Weather APIs.

##### Out the Components for Each Project
- Components by their responsibilities:
- Input/Interface Layer: For instance, web UIs, chat interfaces, PDF upload modules.
- Business Logic/Agent Layer: Contains the core agent logic (reading config files, managing conversation flows, making decisions).
- Integration/Services Layer: Modules and tools for interacting with external systems (MySQL database, Confluence APIs, embedded documents, Flight and Weather APIs).
- Data/Storage Layer: Embedded SQL scripts, configuration files such as YAML, state management modules for travel planning, etc.
- To note utility libraries (like text_splitter modules, mysql_tool, etc.) which plug into the agent logic.

##### Relationships and Data Flows
- User input from the UI to the respective agent’s main.py or app.py.
- Communication from the agent to external APIs or databases.
- Data flow from configuration and tools modules feeding parameters and supporting operations.
- Overlay dependencies such as configuration files (agents.yaml, tasks.yaml) feeding into runtime behavior, and the use of frameworks like CrewAI for the MySQL chat or LangGraph for travel planning.

##### Architectural Patterns and Design Principles
- Many agents follow a modular pattern wherein each agent’s core logic is encapsulated under a “src” or “services” directory.
- Several components follow a configuration-driven design (YAML files, organized folder structures), allowing easy substitution or tuning of agents’ behaviors.
- Separation between presentation (UI interfaces) and processing layers (agents and services).
- Interactions between stateless input processing and stateful modules (when maintaining conversation context or travel planning state).

##### Relevant Technologies, Frameworks, and Libraries
- Groq’s LLM models appear to be a common thread.
- Specific tools such as CrewAI in the MySQL project or LangGraph in the travel planning agent.
- For database operations, highlight the MySQL components with associated SQL scripts.
- For document processing, capture components related to embeddings extraction and text splitting (found in both PDF and Confluence agents).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global User Node
    User["User Input"]:::user

    %% PDF RAG Agent
    subgraph "PDF RAG Agent"
        direction TB
        pdfUpload["PDF Upload Service"]:::service
        pdfSplitter["Text Splitter Utility"]:::utility
        pdfEmbeddings["Embeddings Service"]:::service
        pdfQA["Question-Answer Engine"]:::service

        User -->|"uploads"| pdfUpload
        pdfUpload -->|"splits"| pdfSplitter
        pdfSplitter -->|"generates"| pdfEmbeddings
        pdfEmbeddings -->|"answers"| pdfQA
    end

    %% CONFLUENCE RAG Agent
    subgraph "CONFLUENCE RAG Agent"
        direction TB
        confData["Confluence Data Ingestion/Training"]:::service
        confSplitter["Text Splitter Utility"]:::utility
        confEmbeddings["Embeddings Generation"]:::service
        confQA["Question-Answer Service"]:::service

        User -->|"initiates ingestion"| confData
        confData -->|"splits content"| confSplitter
        confSplitter -->|"generates embeddings"| confEmbeddings
        confEmbeddings -->|"answers query"| confQA
    end

    %% Simple Chatbot
    subgraph "Simple Chatbot"
        direction TB
        chatUI["Conversational Interface"]:::ui
        chatBackend["Backend/Conversation Manager"]:::service

        User -->|"sends message"| chatUI
        chatUI -->|"processes"| chatBackend
    end

    %% MySQL Chat Agent
    subgraph "MySQL Chat Agent"
        direction TB
        mysqlInterface["Chat Interface (app.py)"]:::service
        mysqlMain["Main Application (main.py)"]:::service
        mysqlConfig["Configuration Files"]:::config
        mysqlTool["SQL Query Translator / MySQL Tool"]:::utility
        mysqlDB["Database (Chinook MySql)"]:::db

        User -->|"queries"| mysqlInterface
        mysqlInterface -->|"initiates"| mysqlMain
        mysqlMain -->|"loads"| mysqlConfig
        mysqlMain -->|"translates query"| mysqlTool
        mysqlTool -->|"executes SQL"| mysqlDB
    end

    %% Travel Planning Agent
    subgraph "Travel Planning Agent"
        direction TB
        travelUI["User Interface (UI Layer)"]:::ui
        travelAgents["Agent Modules (Flight, Itinerary, etc.)"]:::service
        travelState["State Management"]:::config
        travelTools["Integration Tools (Flight & Weather APIs)"]:::utility
        travelMain["Main Application Orchestration"]:::service

        User -->|"plans trip"| travelUI
        travelUI -->|"triggers agents"| travelAgents
        travelAgents -->|"updates state"| travelState
        travelAgents -->|"calls APIs"| travelTools
        travelTools -->|"feeds data"| travelMain
    end

%% Click Events for PDF RAG Agent
click pdfUpload "https://github.com/kantariyaraj/ai_agent_examples/blob/main/pdf_rag_example/services/pdf.py"
click pdfSplitter "https://github.com/kantariyaraj/ai_agent_examples/blob/main/pdf_rag_example/utils/text_splitter.py"
click pdfEmbeddings "https://github.com/kantariyaraj/ai_agent_examples/blob/main/pdf_rag_example/services/embeddings.py"
click pdfQA "https://github.com/kantariyaraj/ai_agent_examples/blob/main/pdf_rag_example/services/question_answer.py"

%% Click Events for CONFLUENCE RAG Agent
click confData "https://github.com/kantariyaraj/ai_agent_examples/blob/main/confluence_rag_example/services/confluence.py"
click confSplitter "https://github.com/kantariyaraj/ai_agent_examples/blob/main/confluence_rag_example/utils/text_splitter.py"
click confEmbeddings "https://github.com/kantariyaraj/ai_agent_examples/blob/main/confluence_rag_example/services/embeddings.py"
click confQA "https://github.com/kantariyaraj/ai_agent_examples/blob/main/confluence_rag_example/services/question_answer.py"

%% Click Events for Simple Chatbot
click chatUI "https://github.com/kantariyaraj/ai_agent_examples/blob/main/simple_chatbot/app.py"
click chatBackend "https://github.com/kantariyaraj/ai_agent_examples/blob/main/simple_chatbot/backend.py"

%% Click Events for MySQL Chat Agent
click mysqlInterface "https://github.com/kantariyaraj/ai_agent_examples/blob/main/chat_with_mysql/src/chat_with_mysql/app.py"
click mysqlMain "https://github.com/kantariyaraj/ai_agent_examples/blob/main/chat_with_mysql/src/chat_with_mysql/main.py"
click mysqlConfig "https://github.com/kantariyaraj/ai_agent_examples/blob/main/chat_with_mysql/src/chat_with_mysql/config/agents.yaml"
click mysqlConfig "https://github.com/kantariyaraj/ai_agent_examples/blob/main/chat_with_mysql/src/chat_with_mysql/config/tasks.yaml"
click mysqlTool "https://github.com/kantariyaraj/ai_agent_examples/blob/main/chat_with_mysql/src/chat_with_mysql/tools/mysql_tool.py"
click mysqlDB "https://github.com/kantariyaraj/ai_agent_examples/blob/main/chat_with_mysql/database/Chinook_MySql.sql"

%% Click Events for Travel Planning Agent
click travelUI "https://github.com/kantariyaraj/ai_agent_examples/blob/main/travel_planner_langgraph/UI/app.py"
click travelAgents "https://github.com/kantariyaraj/ai_agent_examples/tree/main/travel_planner_langgraph/agents/"
click travelState "https://github.com/kantariyaraj/ai_agent_examples/tree/main/travel_planner_langgraph/state/"
click travelTools "https://github.com/kantariyaraj/ai_agent_examples/blob/main/travel_planner_langgraph/tools/flight_search_tool.py"
click travelTools "https://github.com/kantariyaraj/ai_agent_examples/blob/main/travel_planner_langgraph/tools/weatherapi_tool.py"
click travelMain "https://github.com/kantariyaraj/ai_agent_examples/blob/main/travel_planner_langgraph/main.py"

%% Styles
classDef user fill:#f9f,stroke:#333,stroke-width:2px;
classDef ui fill:#bbf,stroke:#333,stroke-width:2px;
classDef service fill:#bfb,stroke:#333,stroke-width:2px;
classDef utility fill:#ff9,stroke:#333,stroke-width:2px;
classDef config fill:#fc9,stroke:#333,stroke-width:2px;
classDef db fill:#f99,stroke:#333,stroke-width:2px;
```
