How teclaguna/ragchatbot works
Main Components
• Client/User Interface – Represents front-end clients that consume the API (for example, a web application or Postman/Insomnia used during testing).
• API Server – Central component running within app.py using FastAPI, which exposes REST endpoints for functionalities like uploading PDFs (/embed), querying (/query), scraping (/scrape_and_embed), and establishing WebSocket connections.
• Document Processing Module – Handles PDF parsing and the extraction of text and other structured content.
• External Model Service – Represents the integration with Hugging Face’s models (e.g., Mistral-7B) used to generate language embeddings.
• Langchain Integration – Orchestrates the retrieval and generation logic for the RAG (Retrieval-Augmented Generation) bot.
• Vector Store (ChromaDB) – Used for storing and retrieving vector embeddings of documents.
• Database (MongoDB) – Persists documents, conversations, and related metadata.
• Docker Container – The environment in which the entire application is packaged and deployed; note that the provided Dockerfile contains detailed instructions to create a reproducible image.
• WebSocket Component – Enables real-time bidirectional communication for the chatbot experience.
Relationships and Interactions
• The Document Processing Module for handling PDFs.
• The External Model Service (via Hugging Face) which is triggered for LLM inference.
• Langchain that orchestrates the retrieval process.
• The Vector Store (ChromaDB) which is queried for embeddings.
• The Database (MongoDB) for saving/retrieving document and conversation data.
Architectural Patterns and Design Principles
• That the application uses a modular design where each major functionality (data ingestion, processing, vector search, and persistence) is distinctly separated.
• The overall architecture can be represented as a monolithic backend layer (the FastAPI application) that integrates with many external services.
• Docker encapsulation is critical, as it ensures that the application—including all its dependencies like system libraries and Python packages—is consistent between development and deployment environments.
• Best practices such as separation of concerns (e.g., dedicated endpoints for embedding vs. querying), clear data flow, and integration with external APIs.
Relevant Technologies and Tools
• That the API Server is developed in Python (using FastAPI).
• Integration with third-party APIs such as Hugging Face and Langchain.
• Database components with MongoDB and differentiate between the vector storage (ChromaDB) and persistent storage (MongoDB).
• Containerization using Docker.
• Optionally, include placeholders or labels for PDF processing (possibly using Unstructured) and other tools mentioned in the README.