# 23cyy/ma-sante-a-babi-app-ui architecture

> Architecture diagram of the GitHub repository 23cyy/ma-sante-a-babi-app-ui, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/23cyy/ma-sante-a-babi-app-ui
- Repository: https://github.com/23cyy/ma-sante-a-babi-app-ui

## Overview

##### 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

## Diagram (Mermaid)

```mermaid
graph TB
    %% Entry Point
    Main["src/main.tsx"]:::logic
    App["src/App.tsx"]:::logic

    Main -->|"mounts"| App

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        Pages["Pages"]:::ui
        CoreLayout["Core Layout"]:::ui
        Features["Feature Components"]:::ui
        UIPrimitives["UI Primitives"]:::ui
    end

    %% Logic Layer
    subgraph "Logic Layer"
        direction TB
        Hooks["Hooks"]:::logic
        Services["Services"]:::logic
        Utils["src/lib/utils.ts"]:::logic
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        CSV1[(compatibilit__groupes_sanguins.csv)]:::data
        CSV2[(hospitaux-de-cote-d'ivoire.csv)]:::data
    end

    %% External Integrations
    subgraph "External Integrations"
        direction TB
        SpeechAPI["Web Speech API"]:::external
        GeolocationAPI["Web Geolocation API"]:::external
        MCP["MCP Server (Future)"]:::external
    end

    %% Pages
    Pages -->|"renders"| Index["Index.tsx"]:::ui
    Pages -->|"renders"| NotFound["NotFound.tsx"]:::ui

    %% Core Layout
    CoreLayout -->|"includes"| WebLayout["WebLayout.tsx"]:::ui
    CoreLayout -->|"includes"| Navigation["Navigation.tsx"]:::ui
    CoreLayout -->|"includes"| Sidebar["Sidebar.tsx"]:::ui
    CoreLayout -->|"includes"| Welcome["WelcomeScreen.tsx"]:::ui

    %% Features
    Features --> AdjouaChat["AdjouaChat.tsx"]:::ui
    Features --> HealthMap["HealthMap.tsx"]:::ui
    Features --> QRHealth["QRHealth.tsx"]:::ui
    Features --> BloodComp["BloodCompatibility.tsx"]:::ui
    Features --> Appointments["Appointments.tsx"]:::ui
    Features --> Dashboard["Dashboard.tsx"]:::ui
    Features --> HealthRecord["HealthRecord.tsx"]:::ui
    Features --> Reminders["Reminders.tsx"]:::ui

    %% UI Primitives
    UIPrimitives --> UIFiles["src/components/ui/*"]:::ui

    %% Hooks
    Hooks --> MobileHook["use-mobile.tsx"]:::logic
    Hooks --> ToastHook["use-toast.ts"]:::logic
    Hooks --> ScreenHook["useScreenSize.tsx"]:::logic

    %% Services
    Services --> BloodService["bloodCompatibilityService.ts"]:::logic
    Services --> HealthService["healthCentersService.ts"]:::logic
    Services --> PDFService["pdfGeneratorService.ts"]:::logic

    %% Data flows
    BloodService -->|"GET CSV"| CSV1
    HealthService -->|"GET CSV + geolocation"| CSV2
    PDFService -->|"generates"| HealthRecord

    %% Service to UI notifications
    Services -->|"triggers toasts"| UIPrimitives

    %% Component interactions
    AdjouaChat -->|"speech input/output"| SpeechAPI
    HealthMap -->|"map centering"| GeolocationAPI
    HealthMap -->|"loads hospitals CSV"| CSV2
    AdjouaChat -->|"future REST/GraphQL"| MCP

    %% Entry into UI Layer
    App --> Pages
    App --> CoreLayout

    %% Utilities
    Utils --> Services
    Utils --> Hooks

    %% Click Events
    click Main "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/main.tsx"
    click App "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/App.tsx"
    click Index "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/pages/Index.tsx"
    click NotFound "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/pages/NotFound.tsx"
    click WebLayout "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/WebLayout.tsx"
    click Navigation "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/Navigation.tsx"
    click Sidebar "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/Sidebar.tsx"
    click Welcome "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/WelcomeScreen.tsx"
    click AdjouaChat "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/AdjouaChat.tsx"
    click HealthMap "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/HealthMap.tsx"
    click QRHealth "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/QRHealth.tsx"
    click BloodComp "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/BloodCompatibility.tsx"
    click Appointments "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/Appointments.tsx"
    click Dashboard "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/Dashboard.tsx"
    click HealthRecord "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/HealthRecord.tsx"
    click Reminders "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/components/Reminders.tsx"
    click UIFiles "https://github.com/23cyy/ma-sante-a-babi-app-ui/tree/main/src/components/ui/*"
    click MobileHook "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/hooks/use-mobile.tsx"
    click ToastHook "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/hooks/use-toast.ts"
    click ScreenHook "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/hooks/useScreenSize.tsx"
    click BloodService "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/services/bloodCompatibilityService.ts"
    click HealthService "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/services/healthCentersService.ts"
    click PDFService "https://github.com/23cyy/ma-sante-a-babi-app-ui/blob/main/src/services/pdfGeneratorService.ts"

    %% Styles
    classDef ui fill:#cfe2ff,stroke:#084298,color:#084298
    classDef logic fill:#d1e7dd,stroke:#0f5132,color:#0f5132
    classDef data fill:#fff3cd,stroke:#664d03,color:#664d03
    classDef external fill:#e2e3e5,stroke:#41464b,color:#41464b
```
