How 23cyy/ma-sante-a-babi-app-ui works
Project type and purpose
• This is a single-page application (SPA) built with React, TypeScript and Vite.
• Purpose: a digital health portal (“Ma Santé à Babi”) for Côte d’Ivoire that delivers interactive maps, AI chat assistance, appointment management, QR health codes, PDF export, and open-data consumption (CSV).
File structure
• Top-level config files: tsconfig*, vite.config.ts, tailwind.config.ts, eslint.config.js.
• public/data – CSV datasets (hospitals, blood compatibility).
• src/components – visual components (AdjouaChat, HealthMap, Dashboard, etc.).
• src/components/ui – foundational UI primitives (buttons, cards, dialogs) from shadcn/ui + Tailwind.
• src/pages – route-level page wrappers (Index, NotFound).
• src/services – data-access & domain logic (CSV parsing, PDF generation, health center lookup).
• src/hooks – reusable React hooks for screen size, mobile detection, toasts.
• src/lib/utils.ts – shared utilities.
• src/main.tsx → mounts App.tsx. App.tsx → WebLayout + Navigation + Routes.
Key insights from the README
• Web Speech API for voice recognition/synthesis.
• Integration with Sonner for notifications (toasts).
• CSV parsing of datasets at client side via custom services.
• Future integration with MCP Server (external medical database).
• Responsiveness: mobile vs. desktop layouts.
Main components
a. Client Application (React + Vite)
– UI Layer:
• Pages (Index, Appointments, Dashboard, etc.)
• Components (AdjouaChat, HealthMap, QRHealth, Reminders, etc.)
• UI Primitives (buttons, modals, tables, toasts)
– State & Logic:
• Hooks (useMobile, useToast, useScreenSize)
• Context or global state (if applicable)
– Services Layer:
• bloodCompatibilityService
• healthCentersService
• pdfGeneratorService
– Utilities: lib/utils.ts
b. Data Sources
– Local CSV files (public/data/*.csv)
– Browser Web Speech API (voice in/out)
– Web Geolocation API (map centering)
– Future: MCP Server (REST or GraphQL)
c. Third-party libraries & frameworks
– React, TypeScript, Vite
– Tailwind CSS, shadcn/ui
– Sonner (notifications)
– CSV parser library (e.g., PapaParse or custom)
– PDF generator library (e.g., jsPDF)
– Map integration (e.g., Leaflet, Mapbox)
Relationships & data flows
• UI Component → invokes Service → reads CSV or calls external API → returns data → UI renders.
• AdjouaChat ↔ Web Speech API (mic input, speech synthesis)
• HealthMap ↔ Geolocation API + CSV of hospitals
• PDF generator invoked from HealthRecord/Medical dossier
• Service calls Sonner to trigger toasts on success/error
• Future: AdjouaChat components call MCP Server via service layer
Architectural patterns & design principles
• Layered architecture: UI → Hooks/State → Services → Data sources.
• Separation of concerns:
– Presentation (components/ui + pages)
– Business logic (services)
– Data access (CSV parsing, external calls)
• Reusability: UI primitives in components/ui, shareable hooks
• Responsive design: mobile vs desktop layouts encapsulated in WebLayout