# xinyuez/chat-your-doc architecture

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

- Interactive diagram: https://gitdiagram.com/xinyuez/chat-your-doc
- Repository: https://github.com/xinyuez/chat-your-doc

## Overview

##### Main Components
- Experimental App Tiers – Separate the applications into three main layers: Simple, Intermediate, and Advanced. Each tier includes streamlit-based demos and standalone scripts.
- LLM Agent/Workflow Modules – Represent various agentic flows, such as LangChain agents, LlamaIndex workflows, CrewAI agent systems, and LangGraph processes. These modules form the core logic of how the system “thinks” and interacts with provided data.
- Data Processing & Retrieval – Include components for vectorization and storage (using FAISS, Chroma etc.), RAG engines, and document ingestion pipelines.
- External Integrations – External services such as OpenAI’s API, Ollama, computer vision modules (e.g., GroundingDINO, YOLOv8), and audio/music synthesis components.
- Notebooks & Experimentation Environment – Represent the notebooks directory as a dynamic space for rapid experiments, testing, and prototyping.
- Assets & Tools – Include repositories of configuration (environment.yml, requirements.txt), images, and deployment scripts (like Dockerfile in the wine-price-app).

##### Relationships and Data Flow
- Experimental & Notebook Environment: Represent the notebooks folder as a sandbox that interacts similarly with the agents and storage layer, reinforcing iteration and experimentation.

##### Architectural Patterns
- Modular and Layered Architecture: Emphasize separation between UI, application logic (agentic processing), data management, and external service integrations.
- Microservices-Like Structure for Apps: Note that while the project is monorepo-based, its sub-app divisions (simple, intermediate, advanced) can be conceptually treated as separate micro-applications that share core underlying technology stacks.

##### Inclusion of Detailed Elements
- Annotations: For components with complex interactions (such as the multi-agent workflow or the adaptive RAG patterns), include brief notes or annotations that explain their role (e.g., “Handles multi-query augmentation” or “Integrates retrieval and summarization”).

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        UI1("Streamlit Frontend (Simple Apps)"):::ui
        UI2("Streamlit Frontend (Intermediate Apps)"):::ui
        UI3("Streamlit Frontend (Advanced Apps)"):::ui
    end

    %% Agentic Workflow Layer
    subgraph "Agentic Workflow Layer"
        APH("Agent Processing Hub"):::agenthub
        A1("CrewAI Agent"):::agent
        A2("LangGraph Agent"):::agent
        A3("OpenAI BI Agent"):::agent
        A4("LlamaIndex Adaptive RAG"):::agent
    end

    %% Data Processing & Retrieval
    subgraph "Data Processing & Retrieval"
        DP1("FAISS Vectorization"):::data
        DP2("LlamaIndex Vector Summary Retriever"):::data
        DP3("Simple Retriever"):::data
        DP4("Intermediate Hyde Retriever"):::data
        DP5("Multi-Query Retrieval Notebook"):::data
    end

    %% External Integrations
    subgraph "External Integrations"
        EI1("GroundingDINO Model"):::external
        EI2("Ollama Gemma"):::external
        EI3("YOLO8 & OpenAI Vision"):::external
    end

    %% Experimentation Environment
    subgraph "Experimentation Environment"
        NE("Notebooks"):::notebook
    end

    %% Assets & Deployment Tools
    subgraph "Assets & Deployment Tools"
        AT("Assets & Tools"):::assets
    end

    %% Connections from UI to Agent Processing Hub
    UI1 -->|"triggers"| APH
    UI2 -->|"triggers"| APH
    UI3 -->|"triggers"| APH

    %% Agent Processing Hub to LLM Agent Modules
    APH --> A1
    APH --> A2
    APH --> A3
    APH --> A4

    %% Agent modules to Data Processing & Retrieval nodes
    A1 -->|"uses"| DP1
    A1 -->|"calls"| DP3
    A2 -->|"uses"| DP2
    A2 -->|"calls"| DP4
    A3 -->|"uses"| DP1
    A3 -->|"calls"| DP2
    A4 -->|"triggers"| DP5

    %% Agent modules to External Integrations
    A1 -->|"integrates"| EI2
    A2 -->|"integrates"| EI1
    A3 -->|"integrates"| EI2
    A4 -->|"integrates"| EI3

    %% Notebooks interact with Agent and Data layers
    NE -->|"experiments with"| APH
    NE -->|"tests"| DP5

    %% Assets connection (deployment assets supporting UI)
    AT -->|"deploys"| UI3

    %% Click Events for Experimental App Tiers
    click UI1 "https://github.com/xinyuez/chat-your-doc/tree/master/simple/"
    click UI2 "https://github.com/xinyuez/chat-your-doc/tree/master/intermediate/"
    click UI3 "https://github.com/xinyuez/chat-your-doc/tree/master/advanced/"

    %% Click Events for LLM Agent/Workflow Modules
    click A1 "https://github.com/xinyuez/chat-your-doc/blob/master/advanced/crewai_BI_agent.py"
    click A2 "https://github.com/xinyuez/chat-your-doc/blob/master/advanced/langgraph_agent_mailtool.py"
    click A3 "https://github.com/xinyuez/chat-your-doc/blob/master/advanced/openai_BI_agent.py"
    click A4 "https://github.com/xinyuez/chat-your-doc/blob/master/advanced/llamaindex_adaptive_rag.py"

    %% Click Events for Data Processing & Retrieval
    click DP1 "https://github.com/xinyuez/chat-your-doc/blob/master/advanced/faiss_app.py"
    click DP2 "https://github.com/xinyuez/chat-your-doc/blob/master/advanced/llamaindex_vector_summary_retriever.py"
    click DP3 "https://github.com/xinyuez/chat-your-doc/blob/master/simple/retriever.py"
    click DP4 "https://github.com/xinyuez/chat-your-doc/blob/master/intermediate/hyde_retrieval.py"
    click DP5 "https://github.com/xinyuez/chat-your-doc/blob/master/notebooks/multi_queries_retrieval.ipynb"

    %% Click Events for External Integrations
    click EI1 "https://github.com/xinyuez/chat-your-doc/blob/master/advanced/api/grounding_dino_model.py"
    click EI2 "https://github.com/xinyuez/chat-your-doc/blob/master/simple/ollama_gemma.py"
    click EI3 "https://github.com/xinyuez/chat-your-doc/blob/master/notebooks/yolo8_world_and_openai_vision.py"

    %% Click Events for Notebooks & Experimentation Environment
    click NE "https://github.com/xinyuez/chat-your-doc/tree/master/notebooks/"

    %% Click Events for Assets & Deployment Tools
    click AT "https://github.com/xinyuez/chat-your-doc/tree/master/assets/"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef agenthub fill:#D5F5E3,stroke:#196F3D,stroke-width:2px;
    classDef agent fill:#ABEBC6,stroke:#145A32,stroke-width:2px;
    classDef data fill:#F9E79F,stroke:#7D6608,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#943126,stroke-width:2px;
    classDef notebook fill:#D7BDE2,stroke:#5B2C6F,stroke-width:2px;
    classDef assets fill:#FAD7A0,stroke:#AF601A,stroke-width:2px;
```
