How bogdan-chis/ai-research-assistant works
Project type and purpose
• This is a full-stack web application (“AI Research Assistant”) that allows end users to query scientific literature.
• The backend provides a Retrieval-Augmented Generation (RAG) pipeline with vector search, embeddings, and local LLM integration.
• The frontend is a React (or Streamlit) UI that sends queries to the backend and renders the results with source citations and guardrails.
File structure
• Top-level directories:
• backend: Python service with submodules for API, data ingestion, embeddings, LLM integration, vector store, and tests.
• frontend: JavaScript/TypeScript React app with public assets, reusable UI components, and HTTP/service wrappers.
• chroma: local database file (chroma.sqlite3) for vector storage.
• Key backend modules:
• api: main.py, routes, schemas – defines HTTP endpoints (likely FastAPI).
• data: dataset loading, document splitting, postprocessing.
• embeddings: wrapper for computing or fetching embeddings.
• llm_integration: client for local LLM (LM Studio), prompt engineering, RAG service.
• vectorstore: interface to ChromaDB vector store.
• Configuration files: .env.example, requirements.txt.
README for additional insights
• Workflow steps:
1. User query via web UI.
2. Vector search on embedded docs.
3. Context + query → local LLM.
4. Toxicity/hallucination checks.
5. Return answer + citations.
• External services: LM Studio (local LLM), Perspective API (toxicity / hallucination guardrails).
1. Frontend (React)
2. Backend API Server (FastAPI)
3. Ingestion & Preprocessing Pipeline (dataset_loader, document_splitter, postprocessing)
4. Embeddings Service (embeddings.py)
5. Vector Store (ChromaDB with chroma.sqlite3)
6. RAG Service (rag_service.py)
7. LLM Client (LLM Studio via llm_client.py)
8. Toxicity/Hallucination Guardrails (Perspective API)
9. External Services (LM Studio, Perspective API)
10. Data Store (raw documents, optional file storage)
b. Relationships & interactions:
• Frontend ↔ Backend API: HTTP requests (question submission, answer retrieval).
• Backend API → Ingestion Pipeline: triggered on new uploads or at startup.
• Backend API → Vector Store: query–embed–retrieve.
• Backend API → Embeddings Service: compute embeddings for query or new docs.
• Backend API → RAG Service → LLM Client → LLM Studio: send prompt + context.
• Backend API → Guardrails → Perspective API: analyze LLM output.
• Vector Store ← Embeddings Service ← Data Pipeline: embedding docs once.
• Database (chroma.sqlite3) stores embedding vectors and metadata.
c. Architectural patterns and design principles:
• Modular micro-service–style Python modules (api, data, embeddings, llm_integration, vectorstore).
• Clear separation of concerns: ingestion, storage, inference, and UI.
• Pipeline orchestration: RAG service composes retrieval + LLM + guardrails.
• Stateless API layer, with persistent vector store.
d. Key technologies, frameworks, libraries:
• Frontend: React (components/services)
• Backend: Python (FastAPI or Flask), Pydantic schemas
• Vector DB: ChromaDB
• LLM: Local instance via LM Studio (llm_client)
• Guardrails: Perspective API
• Data processing: custom Python modules
Details to capture
• Batch vs. real-time flows (document ingestion is batch, querying is real-time).
• Protocols (HTTP, gRPC if any, local file I/O).
• Config points (e.g., .env for API keys, LM Studio endpoint).
• Error/guardrail branch: LLM output → Perspective API → warning labels.