How spkkarri/chatbot works
Project type and purpose
• This is a full-stack chatbot application (“Chatbot-geminiV3”) that integrates:
• A React frontend (under src/)
• A Node.js/Express backend (under server/)
• A Python-based Retrieval-Augmented Generation (RAG) microservice (under server/rag_service/)
• A vector store (Faiss indices) and a MongoDB database
• Integration with an external LLM (Gemini, via geminiService.js)
File structure
• Top level: two chatbot versions (V2, V3), a knowledge‐graph (KG) tool, and a Notebook demo—but the main deliverable is V3.
• Chatbot-geminiV3/src/: React UI components, styling, API wrapper
• Chatbot-geminiV3/server/:
• routes/: Express route handlers (auth, chat, upload, syllabus, etc.)
• models/: Mongoose schemas for User and ChatHistory
• middleware/: JWT authentication
• services/: External-LLM wrapper
• rag_service/: Python Flask app for document parsing and vector search
• config/: DB connection setup
• faiss_indices/: persisted Faiss vector indexes
• Configuration & build: package.json, requirements.txt, install.sh
Architecture overview
a. Main components (containers):
• Frontend (React SPA)
• Backend API (Node.js/Express)
• RAG Microservice (Python/Flask)
• Vector Store (Faiss indices on disk)
• Database (MongoDB)
• External LLM Provider (Gemini API)
b. Relationships & data flows:
1. User ↔ React SPA
2. SPA → Backend REST endpoints (via api.js)
3. Backend:
– Authenticated requests pass through authMiddleware → routes
– Chat route:
• Calls RAG microservice (over HTTP or subprocess) for context vectors
• Calls Gemini LLM via geminiService.js
• Persists chat to MongoDB
– File upload route: stores docs, calls RAG’s file_parser & faiss_handler → updates Faiss indices
4. RAG service → Reads/writes Faiss indices on disk → returns nearest documents
5. Backend ↔ MongoDB for users & chat history
c. Architectural patterns & principles:
• Separation of concerns: UI vs API vs vector search logic
• Microservice for RAG (allows scaling/technology heterogeneity)
• Modular Express routes & middleware
• Persistent vector indices for fast retrieval
d. Key technologies:
• React, React Router, CSS Modules
• Node.js, Express, Mongoose (MongoDB)
• Python, Flask, FAISS, file parsing
• JWT for auth, Axios (or fetch) in frontend, shell scripts for install
Detail guidance
• Essential containers:
• React SPA ←→ Node/Express ←→ Python/Flask RAG
• Node/Express ←→ MongoDB
• Python/Flask ←→ Faiss Index files
• Node/Express ←→ External LLM API
• Within each container, show core modules:
• In Backend: “Auth Middleware”, “ChatRoute”, “UploadRoute”, “geminiService”
• In RAG: “file_parser”, “faiss_handler”, “config”
• Persistence: illustrate where files and indices live on disk
• Don’t over-complicate: focus on major moving parts and their interactions