How ankitkr-ak007/nabha-health-connect-app works
Project Type and Purpose
• This is a single-page, client-side web application built with React + TypeScript + Vite.
• Purpose: Let users describe symptoms in natural language, call an AI service (Google Gemini or OpenAI) to analyze them, and display results. Supplements include doctor lookup, pharmacy stock, video consultations, and email notifications.
File Structure
• components/ → UI elements & pages (SymptomChecker, FindDoctor, AuthLayout, Modals, etc.).
• contexts/ → React context for authentication & global state.
• hooks/ → Custom hook (useLocalStorage) for persisting tokens or preferences.
• services/ → External-integration layer (geminiService.ts for AI API; emailService.ts for transactional emails).
• data/ → Static data (list of doctors).
• index.tsx / App.tsx → Root component & entry point.
• tsconfig.json, vite.config.ts → Build & bundler configs.
README for Insights
• Tech stack: React, TypeScript, Vite, Tailwind CSS.
• Workflow: User Input → Frontend calls AI service → AI returns analysis → Frontend displays.
Main Components
a. Client / Browser – Hosts the React app (static files served by Vite or a static-hosting provider).
b. React Application
• Presentation Layer: components/*
• State Layer: contexts/AuthContext.tsx
• Data Layer: data/doctors.ts (static lookup)
• Service Layer: services/geminiService.ts, services/emailService.ts
• Utility Layer: hooks/useLocalStorage.ts
c. External Services
• AI API (Google Gemini / OpenAI)
• Email Provider (e.g., SendGrid, SES)
d. Storage
• LocalStorage (via the custom hook) for tokens/preferences
• Environment Variables (.env.local / Vite) for API keys
Relationships & Data Flows
• User → Browser: Enters symptoms, navigates UI.
• UI Components → Context: Read/write auth state.
• Components → Services:
• SymptomChecker calls geminiService → HTTP POST to AI API → parses response → UI displays results.
• Notification or onboarding flows call emailService → sends transactional emails.
• Services → External APIs: Over secure HTTPS (keys from import.meta.env.VITE_API_KEY).
• Hooks → LocalStorage: Persist/rehydrate auth tokens.
Architectural Patterns & Principles
• Component-Based UI (React)
• Separation of Concerns
• Presentation vs. Service vs. Data vs. State
• Context API for cross-component state (Auth)
• Modular Service Layer for easy swapping of AI providers
Essential Elements to Capture
• Clear component groups (UI vs logic vs data vs integration)
• External services explicitly (AI + Email)
• LocalStorage as client-side persistence
• Comprehensive (covers every folder/group in the tree)
• Accurate (reflects real data flows & tech choices)
• Actionable (easy for new team members to understand & extend)