How shalha-mucha18/ragmed works
Project Type and Purpose
• This is a full-stack RAG-enabled chat application for the medical domain.
• Frontend: Streamlit chat UI for uploading PDFs and asking questions.
• Backend: FastAPI service that handles PDF ingestion, vector embedding, Pinecone DB integration, and LLM invocation.
• Purpose: Allow users to upload private medical documents, index them semantically, and get accurate LLM-generated answers grounded in their own data.
File Structure
• Top-level:
• client/ → Streamlit frontend
• server/ → FastAPI backend
• main.py → Entrypoint orchestrating client and server (if any glue logic)
• client/
• app.py → Streamlit application startup
• components/ → chatUI, history, upload widgets
• utils/api.py → HTTP calls to backend
• config.py → client-side configuration (API URLs, keys)
• server/
• main.py → FastAPI app initialization
• routes/ → API endpoints (upload_pdfs, ask_question)
• modules/ → Core business logic
– pdf_manage.py → PDF parsing & chunking
– vectorstore.py → Pinecone integration
– llm.py → LLM (Groq LLaMA3-70B) calls
– query_manage.py → Retrieval + generation orchestration
• middlewares/ → Exception handling
• uploaded_files/ → Raw PDF storage
• logger.py → Custom logging
• test.py → Basic tests
• Config/build files:
• pyproject.toml, requirements.txt, .gitignore
README for Additional Insights
• RAG pipeline with:
1. PDF upload → semantic chunking
2. Embeddings via Google GenAI / BGE
3. Indexing & retrieval in Pinecone
4. Contextual answer generation by LLaMA3-70B
• Tech Stack highlights exactly these components.
a. Main Components
• Client (Streamlit UI)
• API Gateway / FastAPI Server
• PDF Storage (uploaded_files)
• PDF Processor (pdf_manage module)
• Embedding Service (Google GenAI / BGE)
• Vector Database (Pinecone – vectorstore module)
• Retrieval & Orchestration (query_manage module)
• LLM Engine (Groq LLaMA3-70B via llm module)
• Logging & Middleware
b. Relationships & Interactions
1. User interacts with Streamlit UI → HTTP request to FastAPI endpoint
2. Upload flow:
• upload_pdfs route → pdf_manage splits & preprocesses PDF → send chunks to Embedding Service → vectorstore indexes chunks in Pinecone → store raw PDF
3. Query flow:
• ask_question route → query_manage retrieves top-k chunks from Pinecone → llm module receives context + question → LLM generates answer → returned to client
4. Middlewares wrap each request for error handling & logging
c. Architectural Patterns / Design Principles
• Separation of concerns: clear divisions between UI, API layer, business logic modules, data persistence.
• API-First: all interactions via defined FastAPI routes.
• Modular RAG pipeline: ingest → embed → store → retrieve → generate.
• Pluggable external services: Pinecone, Google GenAI, Groq LLaMA.
d. Technologies / Frameworks
• Streamlit (client)
• FastAPI (server)
• LangChain (orchestrator library)
• Pinecone (Vector DB)
• Google Generative AI / BGE (Embeddings)
• Groq LLaMA3-70B (LLM)
• Python 3.11
Detail Without Over-Splitting
• Essential components (UI, API, business logic, data storage, external services).
• Avoid drawing every single file; instead, group by responsibility.