# nicknochnack/acpwalkthrough architecture

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

- Interactive diagram: https://gitdiagram.com/nicknochnack/acpwalkthrough
- Repository: https://github.com/nicknochnack/acpwalkthrough

## Overview

##### Project type and purpose
- This is a Python-based Retrieval-Augmented Generation (RAG) and multi-agent orchestration system.
- Key features:
- Ingest a PDF (“gold-hospital-and-premium-extras.pdf”) into a vector store (Chroma).
- Serve RAG queries via a “CrewAI” server.
- Support multiple client/agent patterns (ACP, smolagents, chained agents, fast ACP calls).

##### File structure
Top-level scripts:
- 1. RAG via CrewAI.py – drives retrieval + generation logic.
- 2. CrewAI via Server.py – HTTP or RPC server exposing the RAG service.
- 3. ACP client to CrewAI Server.py – an ACP client that calls the server.
- 4. smolagents ACP.py – minimal toy agent using ACP.
- 5. Chained Agents.py – composes multiple agents in sequence.
- 6. ACPCallingAgent.py – an agent that invokes other agents via ACP.
- fastacp.py – optimized or batched ACP invocation.
Supporting directories:
- data/ – raw PDF assets.
- db/ – chroma.sqlite3 and binary data blobs (vectors, headers).
Config/build:
- pyproject.toml, uv.lock – Python project metadata & lockfile.

a. Main components
1. Data Ingestion Module (“1. RAG via CrewAI.py” or a dedicated loader)
2. Vector Store (Chroma DB in db/chroma.sqlite3 + binary blobs)
3. RAG Service (CrewAI via Server.py)
4. Agent Framework
– ACP client (script #3)
– smolagents module (#4)
– ChainedAgents (#5)
– ACPCallingAgent (#6)
– fastacp utility
5. External LLM API (e.g., OpenAI)
6. Clients or CLI drivers

b. Relationships & data flow
- Data Loader → Vector Store: parse PDF → create embeddings → store.
- Client/Agent → RAG Service: send query → server triggers RAG via CrewAI.
- RAG Service → Vector Store: retrieve top-k passages.
- RAG Service → External LLM: craft prompts (context + query) → LLM response.
- RAG Service → Client/Agent: return generated answer.
- Agent Framework: can call RAG Service or call other agents via ACP (fastacp).

c. Architectural patterns & design principles
- Separation of concerns: ingestion, storage, service, agents.
- Layered architecture: Presentation (clients/agents), Service (CrewAI server), Data (Chroma DB).
- Micro-kernel/Plugin style for agents: ACP, smolagents, chained.
- Externalization of configuration: metadata in pyproject.toml, lockfile.

d. Relevant technologies
- Python 3.x
- Chroma vector DB (sqlite3 + binary chunk files)
- HTTP/RPC server framework (e.g., FastAPI or custom in Server.py)
- ACP (Asynchronous Chain-of-Agents Protocol) libraries
- LLM provider SDK (OpenAI, etc.)

##### Essential elements
- Labels: Clear names (e.g., “Vector Store (Chroma)”, “CrewAI Server”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client/Agent Layer
    subgraph "Client/Agent Layer"
        ACPClient("ACP Client"):::agent
        Smolagents("smolagents Module"):::agent
        ChainedAgents("Chained Agents"):::agent
        ACPCallingAgent("ACP-Calling Agent"):::agent
        FastACP("Fast ACP Utility"):::agent
    end

    %% Service Layer
    subgraph "Service Layer"
        CrewAIServer["CrewAI Server"]:::service
    end
    ExternalLLM(("External LLM API")):::external

    %% Data Layer
    subgraph "Data Layer"
        PDF["PDF Asset"]:::data
        DataIngestion["Data Ingestion Module"]:::service
        VectorStore[(Chroma DB)]:::db
    end

    %% Config
    Config["Project Configuration"]:::config

    %% Data flows
    PDF -->|parse & embed| DataIngestion
    DataIngestion -->|store embeddings| VectorStore

    %% Service interactions
    VectorStore -->|retrieve embeddings| CrewAIServer
    CrewAIServer -->|send prompt| ExternalLLM
    ExternalLLM -->|LLM response| CrewAIServer

    %% Agent to service queries
    ACPClient -->|query| CrewAIServer
    Smolagents -->|query| CrewAIServer
    ChainedAgents -->|query| CrewAIServer
    ACPCallingAgent -->|query| CrewAIServer
    FastACP -->|batch query| CrewAIServer

    %% Service responses
    CrewAIServer -->|return answer| ACPClient
    CrewAIServer -->|return answer| Smolagents
    CrewAIServer -->|return answer| ChainedAgents
    CrewAIServer -->|return answer| ACPCallingAgent
    CrewAIServer -->|return answer| FastACP

    %% Agent control flows
    ACPCallingAgent -.->|invoke via ACP| ACPClient
    ACPCallingAgent -.->|invoke via ACP| Smolagents
    ACPCallingAgent -.->|invoke via ACP| ChainedAgents
    FastACP -.->|batch invoke| ACPCallingAgent

    %% Configuration link
    Config -.-> CrewAIServer

    %% Click Events
    click DataIngestion "https://github.com/nicknochnack/acpwalkthrough/blob/main/1. RAG via CrewAI.py"
    click VectorStore "https://github.com/nicknochnack/acpwalkthrough/blob/main/db/chroma.sqlite3"
    click PDF "https://github.com/nicknochnack/acpwalkthrough/blob/main/data/gold-hospital-and-premium-extras.pdf"
    click CrewAIServer "https://github.com/nicknochnack/acpwalkthrough/blob/main/2. CrewAI via Server.py"
    click ACPClient "https://github.com/nicknochnack/acpwalkthrough/blob/main/3. ACP client to CrewAI Server.py"
    click Smolagents "https://github.com/nicknochnack/acpwalkthrough/blob/main/4. smolagents ACP.py"
    click ChainedAgents "https://github.com/nicknochnack/acpwalkthrough/blob/main/5. Chained Agents.py"
    click ACPCallingAgent "https://github.com/nicknochnack/acpwalkthrough/blob/main/6. ACPCallingAgent.py"
    click FastACP "https://github.com/nicknochnack/acpwalkthrough/blob/main/fastacp.py"
    click Config "https://github.com/nicknochnack/acpwalkthrough/blob/main/pyproject.toml"

    %% Styles
    classDef data fill:#AED6F1,stroke:#1F618D,color:#1B4F72
    classDef db fill:#ABEBC6,stroke:#1D8348,color:#145A32
    classDef service fill:#F9E79F,stroke:#B7950B,color:#7D6608
    classDef agent fill:#D2B4DE,stroke:#6C3483,color:#4A235A
    classDef external fill:#E5E7E9,stroke:#566573,color:#1C2833
    classDef config fill:#F2F3F4,stroke:#99A3A4,color:#424949
```
