# anushkapunekar/custom-rag-agent-builder architecture

> Architecture diagram of the GitHub repository anushkapunekar/custom-rag-agent-builder, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anushkapunekar/custom-rag-agent-builder
- Repository: https://github.com/anushkapunekar/custom-rag-agent-builder

## Overview

This is a local-first document RAG application with Google Drive ingestion, a main user knowledge base, and isolated configurable agents. The principal workflow is sign-in, attach documents, ingest and index them, then ask questions answered from retrieved context; users can also build agents, chat with their separate knowledge bases, and provide feedback for retrieval-level learning. The graph follows documented capabilities and sampled routes; wiring for unsampled ingestion, agent, and UI implementations is shown only at the documented subsystem level.

Main entry points: [`backend/app/main.py`](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/main.py) (FastAPI app), [`frontend/src/App.jsx`](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/App.jsx) (App routing), [`backend/app/agents.py`](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/agents.py) (Agent routes), [`frontend/src/api/api.js`](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/api/api.js) (REST client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.jsx]"]
  node_chat["Main chat<br/>[Chat.jsx]"]
  node_driveui["Drive UI<br/>[DriveFiles.jsx]"]
  node_agentui["Agent workspace<br/>[AgentWorkspace.jsx]"]
  node_agentbuilder["Agent builder<br/>[AgentBuilder.jsx]"]
  node_api_client["REST client<br/>[api.js]"]
end

subgraph group_api["Backend API"]
  node_main["FastAPI app<br/>[main.py]"]
  node_auth["Authentication<br/>[auth.py]"]
  node_drive["Drive routes<br/>[drive.py]"]
end

subgraph group_knowledge["Knowledge processing"]
  node_qa["QA routes<br/>[retriever.py]"]
  node_index_routes["Index management<br/>[index_routes.py]"]
  node_indexer["Document indexing<br/>[indexer.py]"]
  node_rag["Chunking and embeddings<br/>[rag_utils.py]"]
  node_maintenance["Maintenance<br/>[maintenance.py]"]
  node_local_models{{"Embedding and generation models"}}
end

subgraph group_agents["Agent workflows"]
  node_agents_api["Agent routes<br/>[agents.py]"]
  node_history["Chat history routes<br/>[chat_history.py]"]
end

subgraph group_state["Persistence"]
  node_disk[("Local files and indexes")]
  node_users_db[("User database<br/>[users.db]")]
  node_chroma[("Chroma index")]
end

node_user(("User"))
node_google_drive["Google Drive"]

node_user -->|"uses"| node_app
node_app -->|"renders"| node_chat
node_app -->|"renders"| node_driveui
node_app -->|"renders"| node_agentui
node_app -->|"renders"| node_agentbuilder
node_chat -->|"requests answers"| node_api_client
node_driveui -->|"requests files"| node_api_client
node_agentbuilder -->|"creates agents"| node_api_client
node_agentui -->|"requests agent data"| node_api_client
node_api_client -->|"REST calls"| node_main
node_main -->|"registers routes"| node_auth
node_main -->|"registers routes"| node_drive
node_main -->|"registers routes"| node_qa
node_main -->|"registers routes"| node_index_routes
node_main -->|"registers routes"| node_maintenance
node_main -->|"registers routes"| node_agents_api
node_main -->|"registers routes"| node_history
node_drive -.->|"imports documents"| node_google_drive
node_drive -->|"indexes documents"| node_indexer
node_indexer -->|"chunks and embeds"| node_rag
node_rag -->|"encodes text"| node_local_models
node_indexer -->|"writes files and vectors"| node_disk
node_index_routes -->|"reindexes user"| node_indexer
node_index_routes -->|"reads index status"| node_chroma
node_qa -->|"loads index and history"| node_disk
node_qa -->|"retrieves and generates"| node_local_models
node_qa -->|"saves chat and feedback data"| node_disk
node_agents_api -->|"builds agent indexes"| node_rag
node_agents_api -->|"stores agent documents"| node_disk
node_agents_api -->|"stores agent metadata"| node_users_db
node_agents_api -->|"answers agent queries"| node_local_models
node_history -->|"reads and writes history"| node_disk

click node_app "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/App.jsx"
click node_chat "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/components/Chat.jsx"
click node_driveui "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/components/DriveFiles.jsx"
click node_agentui "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/components/AgentWorkspace.jsx"
click node_agentbuilder "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/components/AgentBuilder.jsx"
click node_api_client "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/api/api.js"
click node_main "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/main.py"
click node_auth "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/auth.py"
click node_drive "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/drive.py"
click node_qa "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/retriever.py"
click node_index_routes "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/index_routes.py"
click node_indexer "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/indexer.py"
click node_rag "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/rag_utils.py"
click node_maintenance "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/maintenance.py"
click node_agents_api "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/agents.py"
click node_history "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/chat_history.py"
click node_disk "https://github.com/anushkapunekar/custom-rag-agent-builder/tree/main/backend/data"
click node_users_db "https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/users.db"
click node_chroma "https://github.com/anushkapunekar/custom-rag-agent-builder/tree/main/backend/data/chroma"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_chat,node_driveui,node_agentui,node_agentbuilder,node_api_client,node_user toneBlue
class node_main,node_auth,node_drive toneAmber
class node_qa,node_index_routes,node_indexer,node_rag,node_maintenance,node_local_models toneMint
class node_agents_api,node_history toneRose
class node_disk,node_users_db,node_chroma,node_google_drive toneIndigo
```

## Components

### Web client

- [App routing](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Main chat](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/components/Chat.jsx): `frontend/src/components/Chat.jsx`
- [Drive UI](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/components/DriveFiles.jsx): `frontend/src/components/DriveFiles.jsx`
- [Agent workspace](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/components/AgentWorkspace.jsx): `frontend/src/components/AgentWorkspace.jsx`
- [Agent builder](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/components/AgentBuilder.jsx): `frontend/src/components/AgentBuilder.jsx`
- [REST client](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/frontend/src/api/api.js): `frontend/src/api/api.js`

### Backend API

- [FastAPI app](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/auth.py): `backend/app/auth.py`
- [Drive routes](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/drive.py): `backend/app/drive.py`

### Knowledge processing

- [QA routes](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/retriever.py): `backend/app/retriever.py`
- [Index management](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/index_routes.py): `backend/app/index_routes.py`
- [Document indexing](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/indexer.py): `backend/app/indexer.py`
- [Chunking and embeddings](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/rag_utils.py): `backend/app/rag_utils.py`
- [Maintenance](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/maintenance.py): `backend/app/maintenance.py`
- **Embedding and generation models**

### Agent workflows

- [Agent routes](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/agents.py): `backend/app/agents.py`
- [Chat history routes](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/chat_history.py): `backend/app/chat_history.py`

### Persistence

- [Local files and indexes](https://github.com/anushkapunekar/custom-rag-agent-builder/tree/main/backend/data): `backend/data`
- [User database](https://github.com/anushkapunekar/custom-rag-agent-builder/blob/main/backend/app/users.db): `backend/app/users.db`
- [Chroma index](https://github.com/anushkapunekar/custom-rag-agent-builder/tree/main/backend/data/chroma): `backend/data/chroma`

### Other components

- **User**
- **Google Drive**

## Connections

- User → App routing: uses
- App routing → Main chat: renders
- App routing → Drive UI: renders
- App routing → Agent workspace: renders
- App routing → Agent builder: renders
- Main chat → REST client: requests answers
- Drive UI → REST client: requests files
- Agent builder → REST client: creates agents
- Agent workspace → REST client: requests agent data
- REST client → FastAPI app: REST calls
- FastAPI app → Authentication: registers routes
- FastAPI app → Drive routes: registers routes
- FastAPI app → QA routes: registers routes
- FastAPI app → Index management: registers routes
- FastAPI app → Maintenance: registers routes
- FastAPI app → Agent routes: registers routes
- FastAPI app → Chat history routes: registers routes
- Drive routes → Google Drive: imports documents
- Drive routes → Document indexing: indexes documents
- Document indexing → Chunking and embeddings: chunks and embeds
- Chunking and embeddings → Embedding and generation models: encodes text
- Document indexing → Local files and indexes: writes files and vectors
- Index management → Document indexing: reindexes user
- Index management → Chroma index: reads index status
- QA routes → Local files and indexes: loads index and history
- QA routes → Embedding and generation models: retrieves and generates
- QA routes → Local files and indexes: saves chat and feedback data
- Agent routes → Chunking and embeddings: builds agent indexes
- Agent routes → Local files and indexes: stores agent documents
- Agent routes → User database: stores agent metadata
- Agent routes → Embedding and generation models: answers agent queries
- Chat history routes → Local files and indexes: reads and writes history
