How ayushsaini9156/astrarag-chatbot works
1. Repository purpose
- This is a Python-based chatbot system centered on a RAG + agent architecture. The repo name and module layout indicate a question-answering assistant built over local documents in docs_dir/.
2. Top-level shape
- The code is split into four main runtime areas under src/:
- frontend_src for the user-facing app
- backend_src for the API and orchestration layer
- agents_src for the LLM/agent logic
- rag_doc_ingestion for preparing source documents
- This separation suggests clear boundaries between presentation, request handling, AI reasoning, and offline document processing.
3. User interaction layer
- src/frontend_src/app.py is the entry point for the client-facing application.
- frontend_settings.py implies frontend-specific environment/config values.
- The frontend likely sends chat requests to the backend rather than calling the model directly, keeping the UI thin.
4. Backend API and service boundary
- src/backend_src/main.py is the backend entry point.
- src/backend_src/api/chat.py exposes the chat endpoint surface.
- src/backend_src/services/chat.py holds chat orchestration/business logic, which likely mediates between incoming requests and the agent subsystem.
- This creates a clean separation between transport concerns and AI execution.
5. Agent orchestration core
- src/agents_src/crew.py indicates a crew/task style orchestration pattern, likely coordinating one or more agent roles.
- agents/question_answer_agent.py defines the QA-focused agent behavior.
- tasks/question_answer_task.py defines the work item the agent performs.
- This layer is where the system likely decides how to reason over user queries before returning an answer.
6. LLM abstraction
- src/agents_src/llm/get_llm.py and llm_configuration.py encapsulate model selection and setup.
- This suggests the repository is designed to switch LLM backends or parameters without touching the rest of the agent logic.
- The LLM layer is a distinct dependency boundary between application logic and the model provider.
7. RAG and tool integration
- src/agents_src/tools/rag_qa_tool.py is the main clue that the agent is augmented with retrieval.
- The agent likely uses this tool to pull relevant context from indexed documents before answering.
- The architecture therefore combines generative reasoning with document-grounded lookup, rather than relying on the model alone.
8. Document ingestion pipeline
- src/rag_doc_ingestion/ingest_docs.py is the offline/preprocessing entry point for loading documents into the RAG corpus.
- The presence of docs_dir/12. Ecosystem.pdf and docs_dir/6. Evolution.pdf shows the system is already wired to answer from a fixed document set.
- doc_ingestion_settings.py likely controls ingestion paths and indexing parameters.
- The ingestion pipeline is a separate boundary from runtime chat handling.
9. Configuration layering
- Each major subsystem has its own settings module:
- backend_settings.py
- frontend_settings.py
- agent_settings.py
- doc_ingestion_settings.py
- env_template.txt suggests the system is environment-driven and expects external configuration for secrets, endpoints, and model settings.
10. Probable data flow
- Offline flow: PDFs in docs_dir/ -> ingestion script -> retrieval index/store -> available to rag_qa_tool.
- Online flow: user question in frontend -> backend chat API -> service layer -> crew/agent/task -> LLM + retrieval tool -> answer returned to frontend.
- The main architectural value is that documents are prepared once, then reused at query time for grounded responses.
11. Technology/runtime signals
- The project is clearly Python-based, with requirements.txt and package-style src/ modules.
- The code organization suggests a modular service rather than a monolith with one entry point.
- The use of “crew,” agents, and tools points to an agent framework or a custom orchestration abstraction, but the repo structure alone does not show the exact vendor dependency.
12. Useful diagram boundaries
- A good architecture diagram should show four boxes: Frontend, Backend API/Service, Agent + LLM/RAG Core, and Document Ingestion/Corpus.
- The key arrows are:
- user requests into frontend
- frontend requests to backend chat API
- backend to agent orchestration
- agent to LLM and retrieval tool
- ingestion feeding the retrieval store used by the tool
- The document corpus should be drawn as an external input to runtime chat, not as part of the request path.
Main entry points: question_answer_agent.py QA agent · api/chat.py Chat API · services/chat.py Chat service · crew.py Crew
Components 16
Frontend
User-facing chat application
- Chat UI · Frontend application entry point
src/frontend_src/app.py - Frontend config · Frontend environment and runtime settings
src/frontend_src/config/frontend_settings.py
Backend API
HTTP and chat orchestration boundary
- Backend app · Backend service entry point
src/backend_src/main.py - Chat API · Chat endpoint surface
src/backend_src/api/chat.py - Chat service · Orchestrates chat request handling
src/backend_src/services/chat.py - Backend config · Backend environment and runtime settings
src/backend_src/config/backend_settings.py
Agent Core
Crew, agent, task, LLM, and retrieval logic
- Crew · Coordinates agent execution
src/agents_src/crew.py - QA agent · Question-answering agent behavior
src/agents_src/agents/question_answer_agent.py - QA task · Work item for the QA agent
src/agents_src/tasks/question_answer_task.py - RAG tool · Retrieval-augmented QA tool
src/agents_src/tools/rag_qa_tool.py - LLM loader · Builds or selects the active model backend
src/agents_src/llm/get_llm.py - LLM config · Model and provider configuration
src/agents_src/llm/llm_configuration.py - Agent config · Agent subsystem settings
src/agents_src/config/agent_settings.py
Ingestion
Offline document preparation for retrieval
- Ingest docs · Offline document ingestion entry point
src/rag_doc_ingestion/ingest_docs.py - Ingest config · Document ingestion settings
src/rag_doc_ingestion/config/doc_ingestion_settings.py - Document corpus · Source PDFs used for retrieval
docs_dir
Connections 17
- Chat UI → Chat API: chat requests · Frontend sends user messages to backend API
- Chat UI → Frontend config: loads · Frontend reads its runtime configuration
- Backend app → Chat API: serves · Backend mounts the chat API
- Chat API → Chat service: delegates · API hands off request handling to service logic
- Chat service → Crew: invokes · Chat service triggers agent orchestration
- Chat service → Backend config: loads · Backend service uses backend configuration
- Crew → QA task: assigns · Crew coordinates the QA task
- QA task → QA agent: runs on · Task is executed by the QA agent
- QA agent → RAG tool: uses · Agent consults retrieval tool for grounded answers
- QA agent → LLM loader: gets model · Agent resolves the active LLM backend
- LLM loader → LLM config: configured by · Model loader is driven by LLM configuration
- QA agent → Agent config: loads · Agent behavior is configured separately
- RAG tool → Document corpus: retrieves from · Retrieval tool queries the indexed document corpus
- Ingest docs → Document corpus: ingests · Offline pipeline reads source PDFs
- Ingest docs → Ingest config: configured by · Ingestion pipeline uses document settings
- Ingest config → RAG tool: feeds index · Ingestion settings shape the retrieval store used at query time
- Chat API → Crew: routes to · API requests flow into the agent runtime