How mathis-lambert/personal_website works
Project Type and Purpose
• This is a full‑stack personal website with an interactive LLM‑powered chat feature and RAG (Retrieval‑Augmented Generation) knowledge layer.
• Frontend: React + ViteJS + Redux + Chakra UI
• Backend: FastAPI (Python) exposing REST endpoints
• Database: MongoDB for storing content collections and RAG knowledge
• External Service: LLM API (e.g., OpenAI via api_client)
Main Architectural Components
a. Frontend Application
• Browser-based React SPA
• UI layer (Chakra UI components)
• State management (Redux + Context)
• API client module (calls backend REST endpoints)
b. Backend Application
• FastAPI server hosting multiple routes (chat, UI endpoints)
• Service layer (api/services) implementing core logic (e.g., get_classes)
• RAG module (prompts + retrieval against MongoDB)
• Database connector (mongo_db_connector.py)
• Utility modules (logging, file utils, startup checks)
c. Data Storage
• MongoDB instance (Docker container)
• Collections loaded from JSON files under backend/datasets
d. External LLM Service
• Hosted LLM endpoint (via api_client pointing at api.mathislambert.fr)
e. Deployment & Integration
• Docker Compose orchestrating three containers: Frontend, Backend, MongoDB
• Build scripts (Dockerfile in each folder) and docker‐compose.yml
Relationships and Data Flows
1. User interacts with Browser → React UI
2. React dispatches actions → Redux store → UI updates
3. Chat input triggers REST call → FastAPI /chat endpoint
4. FastAPI endpoint → Service layer invokes:
– MongoDB connector to fetch relevant docs (RAG retrieval)
– External LLM API (prompts+rtrv docs)
5. LLM generates response → Backend assembles and returns JSON → Frontend
6. Frontend displays chat response in UI
Architectural Patterns & Design Principles
• Layered architecture (Presentation → API → Services → Data)
• Separation of concerns: UI vs. business logic vs. persistence
• Modular code organization (routes, services, utils, prompts)
• Infrastructure as code via Docker Compose