# well-whale/fe_f-health-sphere architecture

> Architecture diagram of the GitHub repository well-whale/fe_f-health-sphere, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/well-whale/fe_f-health-sphere
- Repository: https://github.com/well-whale/fe_f-health-sphere

## Overview

##### Main System Components
- Frontend Application: Represented by the files in the root (index.html, vite.config.js) and the src directory. Group together key sub-components such as:
- Pages (src/pages – e.g., Dashboard, Band, LoginWithGoogle, Patient).
- Components (src/components – e.g., EarningsReport, RecentPatients) that handle UI segments.
- Layout (src/layout/MainLayout.jsx) which shows the overall page structure.
- Context and State Management (src/context/AuthProvider.jsx) which indicates the authentication flow.
- API Integration Modules (src/api folder including api.js, auth.js, etc.) that abstract communication with the backend.
- Assets and configurations (src/assets, src/firebaseConfig.js) that support branding, media, and external service integration.

- Backend & External Services:
- AI Module: A distinct module illustrating the AI/ML layer (TensorFlow/PyTorch) for medical data analysis.
- IoT Communication: A dedicated component for IoT devices using MQTT which send real-time data.

##### Relationships and Data Flows
- From IoT devices (smart wearables, blood pressure monitors, etc.) sending health data to the Backend Server.
- Communication between the AI module and the Backend, where the AI analyzes the stored/real-time data and triggers notifications/alerts.
- If applicable, show Firebase integration in the authentication flow.

##### Architectural Patterns and Design Principles
- Microservices/Layered Architecture: Even though the provided portion is the frontend, the overall system can be visualized as layered (Presentation, API, Business Logic, Data, External IoT & AI Services).
- Separation of Concerns: The file tree clearly separates UI, state management, and API communication logic (e.g., using separate directories for pages, components, and API).
- Modular Design: The distinct directories for different functionalities (e.g., auth, dashboard, patient) signify an approach that makes each feature independent.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Application (React/Vite)"
        FE1("Frontend Application")  
        FE2("Pages (src/pages)")
        FE3("UI Components (src/components)")
        FE4("Layout (src/layout/MainLayout.jsx)")
        FE5("State Management (src/context/AuthProvider.jsx)")
        FE6("API Integration Modules (src/api)")
        FE7("Assets (src/assets)")
        FE8("Firebase Config (src/firebaseConfig.js)")
    end

    subgraph "Backend & External Services"
        BE1("IoT Devices & MQTT")
        BE2("Backend Server (Node.js/Express)")
        BE3("Database (PostgreSQL/MongoDB)")
        BE4("AI Engine (TensorFlow/PyTorch)")
    end

    FE6 -->|"API_Call"| BE2
    BE1 -->|"IoT_Data"| BE2
    BE2 -->|"Data_Storage"| BE3
    BE2 -->|"Analysis"| BE4
    FE5 -->|"FirebaseAuth"| FE8

    class FE1,FE2,FE3,FE4,FE5,FE6,FE7,FE8 frontend
    class BE2 backend
    class BE3 database
    class BE4 ai
    class BE1 iot

    click FE1 "https://github.com/well-whale/fe_f-health-sphere/tree/main/root"
    click FE2 "https://github.com/well-whale/fe_f-health-sphere/tree/main/src/pages"
    click FE3 "https://github.com/well-whale/fe_f-health-sphere/tree/main/src/components"
    click FE4 "https://github.com/well-whale/fe_f-health-sphere/blob/main/src/layout/MainLayout.jsx"
    click FE5 "https://github.com/well-whale/fe_f-health-sphere/blob/main/src/context/AuthProvider.jsx"
    click FE6 "https://github.com/well-whale/fe_f-health-sphere/tree/main/src/api"
    click FE7 "https://github.com/well-whale/fe_f-health-sphere/tree/main/src/assets"
    click FE8 "https://github.com/well-whale/fe_f-health-sphere/blob/main/src/firebaseConfig.js"

    classDef frontend fill:#B3E5FC,stroke:#0277BD,stroke-width:2px,color:#000;
    classDef backend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px,color:#000;
    classDef database fill:#FFE0B2,stroke:#EF6C00,stroke-width:2px,color:#000;
    classDef ai fill:#FFCDD2,stroke:#C62828,stroke-width:2px,color:#000;
    classDef iot fill:#D1C4E9,stroke:#512DA8,stroke-width:2px,color:#000;
```
