# hieptonight/homepod-client architecture

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

- Interactive diagram: https://gitdiagram.com/hieptonight/homepod-client
- Repository: https://github.com/hieptonight/homepod-client

## Overview

##### Main Components
- Frontend (Client-Side Application): Represented by the “src” folder, with components, pages, hooks, and context providers. This layer includes distinct sections such as the dashboard (for device control, sensor data, settings), landing pages, and login pages.
- API Integration Layer: Inside the “src/apis” folder, there are many modules corresponding to Auth, Devices, Homes, SensorData, SensorSetting, and User operations. These modules are used for making HTTP calls (via axiosClient) to the backend server.
- External Services and IoT Infrastructure: Include components for the MQTT broker and BLE Mesh connectivity, which facilitate real-time device communications and sensor data handling.
- Deployment & Configuration Aspects: The presence of Dockerfile, nginx.conf, and other configuration files indicates containerization and a reverse proxy setup. Represent these as part of the deployment/infrastructure layer that sits in front of or alongside the frontend.

##### Relationships and Interactions
- The User interacts with the Frontend (React UI) via browsers.
- The Backend then interacts with the IoT devices (via MQTT or BLE Mesh) and likely manages data storage (e.g., a database not shown in this repository).
- Optionally, include an authentication flow that begins at the login page, passes through the AuthService and related endpoints, and secures routes via the AuthProvider context.

##### Architectural Patterns & Design Principles
- Component-based UI: The frontend uses a modular React architecture – with separation between pages, reusable UI components, context providers, and custom hooks.
- API Abstraction: The abstraction in the “src/apis” folder indicates a well-defined API service layer handling various concerns from authentication to sensor data retrieval.
- Separation of Concerns: There is a clear distinction between UI rendering, state management (via context and hooks), and business logic (API calls), which mirrors client–server separation.
- Infrastructure Readiness: Dockerfile and NGINX configs denote a deployment strategy that leverages containerization and reverse proxy patterns.

##### Precision & Clarity
- Every component is clearly labeled with its function (e.g., “AuthService”, “DeviceService”).
- Notes or callouts for design principles such as “separation of concerns”, “component reusability”, or “real-time data handling” via MQTT.
- That any dependencies (like external image assets referenced in the README for demo purposes) are noted only if they illustrate part of the user experience.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Nodes
    User["User/Browser"]:::user

    %% Deployment Infrastructure Subgraph
    subgraph "Deployment Infrastructure"
        Docker["Docker Container"]:::deployment
        NGINX["NGINX Reverse Proxy"]:::deployment
    end

    %% Frontend Subgraph
    subgraph Frontend
        ReactApp["React Application (Frontend)"]:::frontend
        Dashboard["Dashboard Page"]:::frontend
        Landing["Landing Page"]:::frontend
        Login["Login Page"]:::frontend
        Context["Context/Hooks"]:::frontend
    end

    %% API Integration Subgraph
    subgraph "API Endpoints"
        ApiLayer["API Integration Layer"]:::api
        AuthAPI["Auth API"]:::api
        DeviceAPI["Device API"]:::api
        HomeAPI["Home API"]:::api
        SensorDataAPI["SensorData API"]:::api
        SensorSettingAPI["SensorSetting API"]:::api
        UserAPI["User API"]:::api
        AxiosClient["HTTP Client"]:::api
        MqttIntegration["MQTT Integration"]:::api
    end

    %% Backend and IoT Components
    SpringBoot["Spring Boot Service (Backend)"]:::backend
    MqttBroker["MQTT Broker"]:::iot
    BleMesh["BLE Mesh Network"]:::iot

    %% Connections

    %% Deployment layer connections
    User --> NGINX
    Docker --> ReactApp
    NGINX --> ReactApp
    NGINX --> SpringBoot

    %% Frontend internal routing
    ReactApp --> Dashboard
    ReactApp --> Landing
    ReactApp --> Login
    ReactApp --> Context
    ReactApp --> ApiLayer

    %% API Integration connections
    ApiLayer --> AuthAPI
    ApiLayer --> DeviceAPI
    ApiLayer --> HomeAPI
    ApiLayer --> SensorDataAPI
    ApiLayer --> SensorSettingAPI
    ApiLayer --> UserAPI
    ApiLayer --> AxiosClient
    ApiLayer --> MqttIntegration
    ApiLayer --> SpringBoot

    %% Backend-to-IoT interactions (bidirectional)
    SpringBoot --- MqttBroker
    SpringBoot --- BleMesh

    %% Click Events
    click ReactApp "https://github.com/hieptonight/homepod-client/tree/main/src/"
    click Dashboard "https://github.com/hieptonight/homepod-client/tree/main/src/app/dashboard/"
    click Login "https://github.com/hieptonight/homepod-client/tree/main/src/app/login/"
    click Landing "https://github.com/hieptonight/homepod-client/tree/main/src/app/landing-page/"
    click ApiLayer "https://github.com/hieptonight/homepod-client/tree/main/src/apis/"
    click AuthAPI "https://github.com/hieptonight/homepod-client/tree/main/src/apis/Auth/"
    click DeviceAPI "https://github.com/hieptonight/homepod-client/tree/main/src/apis/Devices/"
    click HomeAPI "https://github.com/hieptonight/homepod-client/tree/main/src/apis/Homes/"
    click SensorDataAPI "https://github.com/hieptonight/homepod-client/tree/main/src/apis/SensorData/"
    click SensorSettingAPI "https://github.com/hieptonight/homepod-client/blob/main/src/apis/SensorSetting/ApplySensorSetting.js"
    click UserAPI "https://github.com/hieptonight/homepod-client/blob/main/src/apis/User/updateUserInfo.js"
    click AxiosClient "https://github.com/hieptonight/homepod-client/blob/main/src/apis/axiosClient.js"
    click MqttIntegration "https://github.com/hieptonight/homepod-client/blob/main/src/apis/Mqtt.js"
    click BleMesh "https://github.com/hieptonight/homepod-client/blob/main/src/components/global/ble-mesh.tsx"
    click Docker "https://github.com/hieptonight/homepod-client/tree/main/Dockerfile"
    click NGINX "https://github.com/hieptonight/homepod-client/blob/main/nginx.conf"

    %% Styles
    classDef user stroke:#333,fill:#BBDAFF,stroke-width:2px;
    classDef frontend stroke:#333,fill:#F7FFA5,stroke-width:2px;
    classDef api stroke:#333,fill:#FFD699,stroke-width:2px;
    classDef backend stroke:#333,fill:#FF9999,stroke-width:2px;
    classDef iot stroke:#333,fill:#C2F0C2,stroke-width:2px;
    classDef deployment stroke:#333,fill:#D9D9D9,stroke-width:2px;
```
