# syedasad-kiwi/agentic-rag-poc architecture

> Architecture diagram of the GitHub repository syedasad-kiwi/agentic-rag-poc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/syedasad-kiwi/agentic-rag-poc
- Repository: https://github.com/syedasad-kiwi/agentic-rag-poc

## Overview

##### Project Type and Purpose
- This is a proof-of-concept, full-stack Retrieval-Augmented Generation (RAG) system.
- It ingests raw PDF/DOCX documents, chunks and embeds them, stores embeddings in PostgreSQL+pgvector, orchestrates multi-agent workflows with CrewAI and Ollama, exposes an OpenAI-compatible FastAPI, and provides a web interface via OpenWebUI.

##### File Structure Analysis
- Top level
- Dockerfile, docker-compose.yml: container orchestration
- api.py, main.py: API server and CLI entry points
- init-db.sql: database schema setup
- data/raw/: source documents
- requirements.txt / requirements-docker.txt: dependencies
- src/
- config/settings.py: environment and configuration
- data_ingestion/ingest.py: document parsing, chunking, embedding
- evaluation/: test datasets and evaluation scripts
- rag_system/
– agents.py: CrewAI agent definitions
– crew.py: multi-agent orchestration
– tools*.py: custom retrieval/generation utilities
- Tests: test_tool.py

##### README Insights
- Technologies: Docker, Docker Compose, Ollama, LlamaIndex (DoclingReader), FastAPI, PostgreSQL+pgvector, OpenWebUI

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Container Orchestration
    subgraph "Container Orchestration"
        direction TB
        DockerCompose["docker-compose.yml"]:::infra
        Dockerfile["Dockerfile"]:::infra
    end

    %% External Network
    DockerCompose -->|"spins up"| DockerNetwork((Docker Network)):::external
    DockerNetwork --> OllamaServer(["Ollama Server"]):::external

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        RawDocs["Raw Documents\n(PDF/DOCX)"]:::data
        VectorStore[(PostgreSQL + pgvector)]:::data
    end

    click RawDocs "https://github.com/syedasad-kiwi/agentic-rag-poc/tree/main/data/raw/"
    click VectorStore "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/init-db.sql"

    %% Processing Layer
    subgraph "Processing Layer"
        direction TB
        Config["Settings\n(src/config/settings.py)"]:::config
        Ingestion["Ingestion Service\n(src/data_ingestion/ingest.py)"]:::service
        EmbeddingLLM["Embedding & LLM Service\n(src/rag_system/tools.py)\n(src/rag_system/tools_new.py)"]:::service
    end

    click Config "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/src/config/settings.py"
    click Ingestion "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/src/data_ingestion/ingest.py"
    click EmbeddingLLM "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/src/rag_system/tools.py"

    RawDocs -->|"ingest & chunk"| Ingestion
    Ingestion -->|"stores embeddings"| VectorStore
    Ingestion -->|"loads env"| Config
    EmbeddingLLM -->|"uses Ollama"| OllamaServer
    EmbeddingLLM -->|"writes embeddings"| VectorStore

    %% Orchestration Layer
    subgraph "Orchestration Layer"
        direction TB
        Agents["CrewAI Agents\n(src/rag_system/agents.py)"]:::service
        CrewOrch["Agent Orchestrator\n(src/rag_system/crew.py)"]:::service
    end

    click Agents "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/src/rag_system/agents.py"
    click CrewOrch "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/src/rag_system/crew.py"

    VectorStore -->|"retrieves vectors"| Agents
    Agents -->|"coord via Crew"| CrewOrch
    CrewOrch --> EmbeddingLLM

    %% API Layer
    subgraph "API Layer"
        direction TB
        FastAPI["FastAPI Server\n(api.py)"]:::service
        CLI["CLI Entry\n(main.py)"]:::service
    end

    click FastAPI "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/api.py"
    click CLI "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/main.py"

    UserQuery(("User Query")):::external
    UserQuery -->|"HTTP request"| FastAPI
    FastAPI -->|"calls orchestrator"| CrewOrch
    CrewOrch -->|"returns answer"| FastAPI

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        OpenWebUI["OpenWebUI (Web Interface)"]:::external
    end

    OpenWebUI -->|"API calls"| FastAPI
    DockerNetwork --> OpenWebUI

    %% Evaluation Module
    subgraph "Evaluation Module"
        direction TB
        EvalData["Eval Dataset\n(src/evaluation/eval_dataset.jsonl)"]:::data
        EvalScript["run_ragas_eval.py\n(src/evaluation/run_ragas_eval.py)"]:::service
    end

    click EvalData "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/src/evaluation/eval_dataset.jsonl"
    click EvalScript "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/src/evaluation/run_ragas_eval.py"

    EvalScript -->|"uses embeddings"| VectorStore
    EvalScript -->|"invokes agents"| CrewOrch

    %% Dependencies
    Requirements["requirements.txt\nrequirements-docker.txt"]:::infra
    click Requirements "https://github.com/syedasad-kiwi/agentic-rag-poc/blob/main/requirements.txt"

    DockerCompose --> Requirements

    %% Styling
    classDef data fill:#f9f,stroke:#333,stroke-width:1px;
    classDef service fill:#bbf,stroke:#333,stroke-width:1px;
    classDef external fill:#ffe082,stroke:#333,stroke-width:1px;
    classDef infra fill:#c8e6c9,stroke:#333,stroke-width:1px;
    classDef config fill:#d1c4e9,stroke:#333,stroke-width:1px;
```
