How ujjawalps/healthsavvy works
Project Type & Purpose
• Full-stack web application with a conversational AI chatbot.
• Purpose: let users enter symptom queries in natural language, run a vector-search + LLM pipeline over a medical PDF, and return contextual health guidance.
Main Components
a. Client (Browser)
• HTML/CSS/Vanilla JS (templates/chat.html + static/style.css)
• Renders chat interface, captures user input, displays responses.
b. Web Server (Flask Backend)
• app.py: HTTP endpoints (e.g., “/chat” route)
• template.py & render.yaml: deployment configuration on Render.
c. Business Logic & AI Pipeline
• src/prompt.py: prompt construction for LLM
• src/helper.py: utility functions (e.g., formatting, error handling)
d. Data Ingestion
• store_index.py: reads Data/Medical_book.pdf, uses LangChain to chunk + embed, pushes embeddings to Pinecone
e. Vector Store
• Pinecone (external service): stores and retrieves embeddings for similarity search
f. LLM Service
• OpenAI/Gemini API (external) for generating conversational responses
g. Configuration & Environment
• requirements.txt, setup.py, runtime.txt, .env for API keys
Relationships & Data Flow
1. User types message → Browser sends AJAX POST to Flask “/chat” endpoint
2. Flask handler (app.py) invokes src/prompt to build the LLM prompt
3. Handler calls Pinecone (via LangChain client) to retrieve top-k document embeddings relevant to the query
4. Retrieved context + user query sent to OpenAI/Gemini API
5. LLM response received → Flask returns JSON to front end
6. Browser JS updates chat UI
Separately, on startup or via a CLI command, store_index.py ingests the PDF into Pinecone.
Architectural Patterns & Design Principles
• MVC-like separation:
• View: templates + static assets
• Controller: Flask routes in app.py
• Model: Pinecone vector database + PDF as source data
• Modular code organization: all prompt- and helper-logic in src/
• API orchestration: chaining Pinecone + LLM calls using LangChain
• Externalization of configuration: requirements.txt, runtime.txt, render.yaml, .env
Final Checklist
• Clear component boundaries (Frontend, Backend, External Services, Data Source)
• Annotations for key files and technologies (Flask, LangChain, Pinecone, OpenAI/Gemini)