How suganth1704/rag_app_backend works
1. What this repo is
- RAG_APP is a retrieval-augmented generation backend: it ingests documents, turns them into embeddings, stores them in a vector database, retrieves relevant chunks for a query, and sends that context to an LLM for answer generation.
2. Top-level runtime entrypoint
- main.py is the application bootstrap. It is the likely place where the FastAPI app is created and the API routes are mounted.
- This is the handoff point from process startup into the request-serving layer.
3. API boundary
- api/route.py contains the HTTP endpoints and request handling.
- api/schema.py defines the API contract, likely using Pydantic models for typed input/output payloads.
- This layer should be treated as thin orchestration: validate requests, call ingestion/retrieval/chat services, return responses.
4. Ingestion subsystem
- ingestion/ingest.py is responsible for document processing.
- Based on the README, the ingestion flow is: load document → chunk text → create embeddings → persist vectors.
- The chunking settings are part of the architecture: chunk_size=700, chunk_overlap=150.
5. Embedding and indexing flow
- The README states embeddings are created with all-MiniLM-L6-v2.
- Those embeddings become the durable search index stored in ChromaDB, not the raw documents themselves.
- This means the key persisted artifact is the vectorized chunk representation plus any associated metadata.
6. Vector store boundary
- vector_store/chroma_client.py encapsulates ChromaDB access.
- This module is the persistence/search boundary for retrieval operations, isolating the rest of the app from Chroma-specific calls.
- Retrieval uses similarity search and MMR-style selection according to the README, so the vector store is not just storage; it also drives candidate ranking.
7. LLM / chat subsystem
- llm/groq_client.py is the integration point to Groq-hosted models.
- llm/chat.py likely composes the prompt, retrieved context, and user query into the final chat response.
- The model called out in the README is llama-3.3-70b-versatile, which is the generation endpoint for the response stage.
8. End-to-end data flow
- Ingestion path: documents enter through the backend, are chunked and embedded, then stored in ChromaDB.
- Query path: a user query arrives via the API, is embedded, used to retrieve relevant chunks from ChromaDB, and those chunks are passed into the LLM as context.
- The final answer is returned through the API layer to the client.
9. Cross-cutting concerns
- config/logging.py centralizes logging setup, which is important for tracing ingestion, retrieval, and generation failures across the pipeline.
- config/__init__.py suggests additional runtime configuration may be loaded here, likely environment-driven via .env as noted in the README.
10. External dependencies that matter architecturally
- FastAPI provides the HTTP interface.
- ChromaDB is the vector persistence/retrieval engine.
- Groq is the external model provider for generation.
- The README also mentions LangChain/LangGraph as orchestration frameworks; even though they are not visible as dedicated modules in the tree, they likely influence how retrieval and prompt workflows are structured.
11. Likely system boundaries for a diagram
- Client/UI → FastAPI API → ingestion or chat orchestration → vector store / LLM service.
- Persistence is split: vector data in ChromaDB, operational concerns in logs/config, and no relational database layer is present in the tree.
12. What is not present
- There is no dedicated database model layer, task queue, or separate worker service in the repository tree.
- If Redis is used, it is only mentioned in the README and not represented by a visible module here, so it should be treated as optional auxiliary infrastructure rather than a core subsystem.
Main entry points: route.py Routes · chroma_client.py Chroma Client · __init__.py Config · main.py Main
Components 14
Runtime
Application bootstrap and request entrypoint
- Main · Starts the backend and mounts the application routes
main.py
API
HTTP request/response boundary
Ingestion
Document processing and indexing pipeline
- Ingest · Loads, chunks, embeds, and indexes documents
ingestion/ingest.py - Chunking · Splits documents with configured chunk size and overlap
- Embeddings · all-MiniLM-L6-v2 vectorizer used to encode chunks
Retrieval
Vector search and persistence boundary
- Chroma Client · Encapsulates vector persistence and similarity/MMR retrieval
vector_store/chroma_client.py
LLM
Prompt assembly and model integration
- Chat · Builds prompt, injects retrieved context, and produces answers
llm/chat.py - Groq Client · Integration wrapper for hosted model calls
llm/groq_client.py
Support
Configuration and logging
Other components
- Client · User or upstream service that sends queries and documents
- ChromaDB · Vector database holding embedded chunks and metadata
- Groq Model · llama-3.3-70b-versatile generation endpoint
Connections 20
- Client → Main: starts · Client request enters the application process
- Main → Routes: mounts · Bootstrap hands off to HTTP routes
- Routes → Schemas: validates · Endpoints use typed request and response models
- Routes → Ingest: ingests · API can trigger document ingestion
- Routes → Chat: answers · API can trigger retrieval-augmented chat
- Ingest → Chunking: splits · Documents are chunked before embedding
- Chunking → Embeddings: encodes · Chunks are converted into embeddings
- Embeddings → Chroma Client: writes vectors · Embeddings and metadata are stored for retrieval
- Chroma Client → ChromaDB: persists · Chroma client delegates storage and search to ChromaDB
- Routes → Chroma Client: retrieves · Query handling fetches relevant chunks from the vector store
- Chroma Client → Chat: returns context · Retrieved chunks are passed into response generation
- Chat → Groq Client: calls · Chat orchestration delegates model execution
- Groq Client → Groq Model: generates · Hosted Groq model produces the final answer
- Logging → Main: traces · Shared logging is used during app startup
- Logging → Ingest: traces · Ingestion failures and progress are logged
- Logging → Chat: traces · Retrieval and generation events are logged
- Config → Main: configures · Runtime settings are loaded into the app
- Config → Ingest: configures · Chunking and pipeline settings are sourced from config
- Config → Chroma Client: configures · Vector store connection details are sourced from config
- Config → Groq Client: configures · Model/provider credentials and parameters are sourced from config