How 1ajinkya2/ayurvedaai works
Project type and purpose
• This is a full-stack AI-driven web application (“AyurVedaAI”) that provides personalized Ayurvedic recommendations.
• Key features: Prakriti assessment (quiz), scripture analysis (LLM+vector search), personalized remedy suggestions, educational resources, chatbot interface.
File structure
• Top-level:
• backend/ – Python-based API & chatbot logic (Chainlit + LangChain + FAISS)
• frontend/ – React + TypeScript + Vite + Tailwind UI
• testing/ – Jupyter notebooks and datasets for evaluating model outputs
• backend details:
• app.py – main web server (Flask or FastAPI style) integrating Chainlit
• ingest.py – data ingestion pipeline: PDF → embeddings → FAISS vectorstore
• data/ – raw Ayurvedic PDFs
• vectorstore/db_faiss/ – serialized FAISS index
• frontend details:
• src/pages/PrakrutiAnalyzerPage.tsx – quiz UI
• src/pages/Chatbot.tsx – chat interface calling backend
• Tailwind & postCSS configs for styling
• Configs: requirements.txt, package.json files, .gitignore, tsconfig, pnpm/yarn locks.
README
• Confirms use of LLMs (e.g., GPT-3), Node.js/Express.js (but code shows Python), MongoDB (user profiles), and a web frontend.
• Mentions account creation & quiz → personalized recommendations → AI-chatbot interactions.
Main components
a. Frontend (Client):
• Browser UI (React/Vite/Tailwind)
• Prakriti Quiz Module
• Chatbot Module
• Static Educational Content (HTML/CSS/js)
b. Backend API Server:
• HTTP/WebSocket endpoints (app.py + Chainlit)
• Prakriti assessment logic (score computation)
• Chat request handler (LangChain chains + FAISS retrieval)
• Ingestion pipeline service (ingest.py, run offline or as job)
c. Data Layer:
• PDF Data Store (backend/data/)
• Vector Store (FAISS index on disk)
• User Profile DB (MongoDB – user credentials, quiz results, preferences)
d. External Services:
• OpenAI (or other LLM provider) for embeddings & completions
• Email/SMS service (optional, for notifications)
Relationships and interactions
1. User → Frontend UI
2. Frontend Quiz submission → Backend /assess endpoint → MongoDB save → response
3. Frontend Chat message → Backend /chat endpoint →
a. retrieve relevant docs via FAISS
b. call OpenAI for completion
c. return answer stream to UI
4. Ingestion pipeline (offline or scheduled):
• Read PDFs → chunk → embed via OpenAI → index into FAISS
Architectural patterns & design principles
• Client-Server separation
• Modular services: ingestion vs. runtime API
• Retrieval-augmented generation (RAG) pattern: vector store + LLM
• Single-Page Application (SPA) on frontend
• Stateless API servers with persistent data in DBs
Essential elements
• Don’t overcrowd: group related UI elements under a single “Frontend” container
• Both runtime path (user interactions) and offline path (data ingestion)
• Every persistent store and external dependency