How yash2002vardhan/naptick_assignment works
Project Type and Purpose
• This repository contains two full-stack AI applications focused on sleep coaching:
• RAG Project: Retrieval-Augmented Generation system using FAISS or Pinecone, OpenAI/Huggingface embeddings, Gradio UI.
• Voice Project: Voice-based sleep assistant with speech-to-text (Whisper), text-to-speech, caching DB, Gradio UI.
File Structure Analysis
• Top-level folders: rag_project/ and voice_project/.
• Each contains:
• main.py (and alternate_main.py in voice) – application entry points launching Gradio interfaces.
• utils/ – modular helpers (embedding generation, vector store, PDF conversion, caching, audio mixing).
• datasets/ – raw input (chat logs, fitbit CSVs, research papers, sleep data).
• Pre-built indices (FAISS folders) in RAG, optional embeddings folder in Voice.
• Docker and docker-compose configs, .env.example for API keys.
Key Architectural Insights from README
• Both use Gradio as the frontend interface, exposing endpoints on port 7860.
• RAG pipelines:
• Data ingestion → embeddings → vector store (FAISS/Pinecone) → similarity search → LLM prompt.
• Supports two embedding engines, two index types.
• Voice pipeline:
• Audio input → Whisper ASR → optional RAG retrieval (in alternate_main) → LLM for response generation → TTS → audio output.
• Caching DB stores conversation history and avoids repeated transcriptions or LLM calls.
Components and Relationships
a. Main Components
• Frontend Layer: Gradio web interface (Rectangles).
• Backend Application: Python runtime container (Docker), orchestrated by Docker-Compose.
• Retrieval Services:
• Vector Store (FAISS or Pinecone)
• Embedding Generator (OpenAI/Huggingface)
• LLM Endpoint: OpenAI API (ChatGPT, Embeddings API).
• Data Layer:
• Datasets (CSV, Markdown, PDFs)
• Pre-built FAISS indices
• Caching Database (e.g., SQLite or local JSON cache) in Voice Project.
• Audio Services (Voice Project): Whisper ASR, TTS engine (OpenAI or other), FFmpeg for processing.
• External Services: Pinecone API (optional), OpenAI API.
1. User → Gradio UI: question (text or audio).
2. In RAG: UI → Backend → Embedding Generator → Vector Store → Top-k docs → LLM Prompt → OpenAI API → Response → UI.
3. In Voice: UI (audio) → Whisper ASR → text → (optional RAG retrieval) → LLM → TTS → FFmpeg → UI (audio).
4. Caching DB reads/writes conversation and embeddings reuse.
5. Docker-Compose connects each container (app, vector store if separate, caching DB).
c. Architectural Patterns and Principles
• Modular pipeline stages (Separation of Concerns).
• Retrieval-Augmented Generation pattern in RAG and alternate Voice.
• Micro-components within single container (could evolve into microservices).
• Containerization for environment parity (Docker + Compose).
• Config-driven via .env files.
d. Technologies and Frameworks
• Python 3.10, Gradio, OpenAI API, Huggingface Embeddings, FAISS, Pinecone SDK, Docker, Docker-Compose, Whisper, FFmpeg, crewai (alternate voice).
• Blue rectangles for compute components (Python services)