# santhoshm007/fde_rag architecture

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

- Interactive diagram: https://gitdiagram.com/santhoshm007/fde_rag
- Repository: https://github.com/santhoshm007/fde_rag

## Overview

WeedRAG is a chat application for weed identification and management, grounded in an ingested PDF knowledge base. Users create or select a chat, submit a question, and receive an answer displayed in the conversation; chat history is stored in browser local storage. The server retrieves relevant Chroma content, augments it with a domain-specific prompt, and invokes a language model. A separate ingestion workflow loads PDFs, chunks them, embeds them, and persists them to Chroma. The available source shows the main UI composition and server calls; some component behavior and the augment implementation are not sampled.

Main entry points: [`server/app/app.py`](https://github.com/santhoshm007/fde_rag/blob/main/server/app/app.py) (RAG workflow), [`client/src/hooks/useChat.js`](https://github.com/santhoshm007/fde_rag/blob/main/client/src/hooks/useChat.js) (Chat state), [`server/app/ingest.py`](https://github.com/santhoshm007/fde_rag/blob/main/server/app/ingest.py) (PDF ingestion), [`client/src/App.jsx`](https://github.com/santhoshm007/fde_rag/blob/main/client/src/App.jsx) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_app_ui["App shell<br/>[App.jsx]"]
  node_chat_state["Chat state<br/>[useChat.js]"]
  node_sidebar["Chat sidebar<br/>[Sidebar.jsx]"]
  node_chat_area["Chat area<br/>[ChatArea.jsx]"]
  node_chat_header["Chat header<br/>[ChatHeader.jsx]"]
  node_message_list["Message list<br/>[MessageList.jsx]"]
  node_message_bubble["Message bubble<br/>[MessageBubble.jsx]"]
  node_thinking["Thinking indicator<br/>[ThinkingDots.jsx]"]
  node_empty_state["Empty state<br/>[EmptyState.jsx]"]
  node_input_bar["Message input<br/>[InputBar.jsx]"]
end

subgraph group_server["Chat service"]
  node_api["Chat API<br/>[app.py]"]
  node_rag_flow["RAG workflow<br/>[app.py]"]
  node_retrieval["Similarity retrieval<br/>[retrieval.py]"]
  node_augmentation["Prompt augmentation<br/>[augment.py]"]
  node_prompt["Domain prompt<br/>[prompt.py]"]
  node_configuration["Model configuration<br/>[config.py]"]
end

subgraph group_knowledge["Knowledge base"]
  node_ingestion["PDF ingestion<br/>[ingest.py]"]
  node_source_pdf["Weed guide PDF"]
  node_vector_store[("Chroma vector store")]
end

subgraph group_integrations["External services"]
  node_browser_storage[("Browser storage")]
  node_openai["OpenAI models"]
end

node_user(("User"))

node_user -->|"uses"| node_app_ui
node_app_ui -->|"reads state"| node_chat_state
node_app_ui -->|"renders"| node_sidebar
node_app_ui -->|"renders"| node_chat_area
node_chat_state -->|"persists chats"| node_browser_storage
node_chat_state -->|"sends question"| node_api
node_sidebar -->|"triggers chat actions"| node_chat_state
node_chat_area -->|"renders"| node_chat_header
node_chat_area -->|"renders"| node_message_list
node_chat_area -->|"renders"| node_input_bar
node_input_bar -->|"submits message"| node_chat_state
node_message_list -->|"renders"| node_message_bubble
node_message_list -->|"shows while loading"| node_thinking
node_message_list -->|"shows when empty"| node_empty_state
node_api -->|"invokes"| node_rag_flow
node_rag_flow -->|"retrieves context"| node_retrieval
node_rag_flow -->|"builds prompt"| node_augmentation
node_rag_flow -->|"invokes chat model"| node_openai
node_retrieval -->|"searches"| node_vector_store
node_augmentation -.->|"uses prompt template"| node_prompt
node_configuration -->|"imports template"| node_prompt
node_ingestion -->|"loads documents"| node_source_pdf
node_ingestion -->|"reads settings"| node_configuration
node_ingestion -->|"creates embeddings"| node_openai
node_ingestion -->|"persists vectors"| node_vector_store
node_rag_flow -->|"opens store"| node_vector_store

click node_app_ui "https://github.com/santhoshm007/fde_rag/blob/main/client/src/App.jsx"
click node_chat_state "https://github.com/santhoshm007/fde_rag/blob/main/client/src/hooks/useChat.js"
click node_sidebar "https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/Sidebar.jsx"
click node_chat_area "https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/ChatArea.jsx"
click node_chat_header "https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/ChatHeader.jsx"
click node_message_list "https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/MessageList.jsx"
click node_message_bubble "https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/MessageBubble.jsx"
click node_thinking "https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/ThinkingDots.jsx"
click node_empty_state "https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/EmptyState.jsx"
click node_input_bar "https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/InputBar.jsx"
click node_api "https://github.com/santhoshm007/fde_rag/blob/main/server/app/app.py"
click node_rag_flow "https://github.com/santhoshm007/fde_rag/blob/main/server/app/app.py"
click node_retrieval "https://github.com/santhoshm007/fde_rag/blob/main/server/app/retrieval.py"
click node_augmentation "https://github.com/santhoshm007/fde_rag/blob/main/server/app/augment.py"
click node_prompt "https://github.com/santhoshm007/fde_rag/blob/main/server/app/prompt.py"
click node_configuration "https://github.com/santhoshm007/fde_rag/blob/main/server/app/config.py"
click node_ingestion "https://github.com/santhoshm007/fde_rag/blob/main/server/app/ingest.py"
click node_source_pdf "https://github.com/santhoshm007/fde_rag/blob/main/server/data/NoxWeedMangementGuide2019LasAnimas.pdf"
click node_vector_store "https://github.com/santhoshm007/fde_rag/tree/main/server/db/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_ui,node_chat_state,node_sidebar,node_chat_area,node_chat_header,node_message_list,node_message_bubble,node_thinking,node_empty_state,node_input_bar,node_user toneBlue
class node_api,node_rag_flow,node_retrieval,node_augmentation,node_prompt,node_configuration toneAmber
class node_ingestion,node_source_pdf,node_vector_store toneMint
class node_browser_storage,node_openai toneRose
```

## Components

### Chat client

- [App shell](https://github.com/santhoshm007/fde_rag/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Chat state](https://github.com/santhoshm007/fde_rag/blob/main/client/src/hooks/useChat.js): `client/src/hooks/useChat.js`
- [Chat sidebar](https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/Sidebar.jsx): `client/src/components/Sidebar.jsx`
- [Chat area](https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/ChatArea.jsx): `client/src/components/ChatArea.jsx`
- [Chat header](https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/ChatHeader.jsx): `client/src/components/ChatHeader.jsx`
- [Message list](https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/MessageList.jsx): `client/src/components/MessageList.jsx`
- [Message bubble](https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/MessageBubble.jsx): `client/src/components/MessageBubble.jsx`
- [Thinking indicator](https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/ThinkingDots.jsx): `client/src/components/ThinkingDots.jsx`
- [Empty state](https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/EmptyState.jsx): `client/src/components/EmptyState.jsx`
- [Message input](https://github.com/santhoshm007/fde_rag/blob/main/client/src/components/InputBar.jsx): `client/src/components/InputBar.jsx`

### Chat service

- [Chat API](https://github.com/santhoshm007/fde_rag/blob/main/server/app/app.py): `server/app/app.py`
- [RAG workflow](https://github.com/santhoshm007/fde_rag/blob/main/server/app/app.py): `server/app/app.py`
- [Similarity retrieval](https://github.com/santhoshm007/fde_rag/blob/main/server/app/retrieval.py): `server/app/retrieval.py`
- [Prompt augmentation](https://github.com/santhoshm007/fde_rag/blob/main/server/app/augment.py): `server/app/augment.py`
- [Domain prompt](https://github.com/santhoshm007/fde_rag/blob/main/server/app/prompt.py): `server/app/prompt.py`
- [Model configuration](https://github.com/santhoshm007/fde_rag/blob/main/server/app/config.py): `server/app/config.py`

### Knowledge base

- [PDF ingestion](https://github.com/santhoshm007/fde_rag/blob/main/server/app/ingest.py): `server/app/ingest.py`
- [Weed guide PDF](https://github.com/santhoshm007/fde_rag/blob/main/server/data/NoxWeedMangementGuide2019LasAnimas.pdf): `server/data/NoxWeedMangementGuide2019LasAnimas.pdf`
- [Chroma vector store](https://github.com/santhoshm007/fde_rag/tree/main/server/db/chroma): `server/db/chroma`

### External services

- **Browser storage**
- **OpenAI models**

### Other components

- **User**

## Connections

- User → App shell: uses
- App shell → Chat state: reads state (evidence: `client/src/App.jsx`)
- App shell → Chat sidebar: renders (evidence: `client/src/App.jsx`)
- App shell → Chat area: renders (evidence: `client/src/App.jsx`)
- Chat state → Browser storage: persists chats (evidence: `client/src/hooks/useChat.js`)
- Chat state → Chat API: sends question (evidence: `client/src/hooks/useChat.js`)
- Chat sidebar → Chat state: triggers chat actions (evidence: `client/src/App.jsx`)
- Chat area → Chat header: renders (evidence: `client/src/components/ChatArea.jsx`)
- Chat area → Message list: renders (evidence: `client/src/components/ChatArea.jsx`)
- Chat area → Message input: renders (evidence: `client/src/components/ChatArea.jsx`)
- Message input → Chat state: submits message
- Message list → Message bubble: renders (evidence: `client/src/components/MessageList.jsx`)
- Message list → Thinking indicator: shows while loading (evidence: `client/src/components/MessageList.jsx`)
- Message list → Empty state: shows when empty (evidence: `client/src/components/MessageList.jsx`)
- Chat API → RAG workflow: invokes (evidence: `server/app/app.py`)
- RAG workflow → Similarity retrieval: retrieves context (evidence: `server/app/app.py`)
- RAG workflow → Prompt augmentation: builds prompt (evidence: `server/app/app.py`)
- RAG workflow → OpenAI models: invokes chat model (evidence: `server/app/app.py`)
- Similarity retrieval → Chroma vector store: searches (evidence: `server/app/retrieval.py`)
- Prompt augmentation → Domain prompt: uses prompt template (evidence: `server/app/augment.py`)
- Model configuration → Domain prompt: imports template (evidence: `server/app/config.py`)
- PDF ingestion → Weed guide PDF: loads documents (evidence: `server/app/ingest.py`)
- PDF ingestion → Model configuration: reads settings (evidence: `server/app/ingest.py`)
- PDF ingestion → OpenAI models: creates embeddings (evidence: `server/app/ingest.py`)
- PDF ingestion → Chroma vector store: persists vectors (evidence: `server/app/ingest.py`)
- RAG workflow → Chroma vector store: opens store (evidence: `server/app/app.py`)
