# health-mate-project/healthmate architecture

> Architecture diagram of the GitHub repository health-mate-project/healthmate, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/health-mate-project/healthmate
- Repository: https://github.com/health-mate-project/healthmate

## Overview

##### Main Components

a) Frontend Layer:
- Static HTML pages (login.html, signup.html, main.html)
- Client-side JavaScript
- CSS styling

b) Backend Layer:
- FastAPI server (main.py)
- Authentication system
- ChatGPT integration
- Health recommendation system

c) Database Layer:
- SQLite database (users.db)

d) External Services:
- ChatGPT API

**[Client Layer]**
- ↕️ HTTP/REST
**[Application Layer]**
- ↕️ SQL
**[Data Layer]**
- ↔️ External Services

##### Detailed Component Breakdown

Client Layer:
- UI components for user input
- Static asset handling

Application Layer (FastAPI):
- User Authentication Controller
- Health Recommendation Service
- ChatGPT Integration Service
- API Routes (/user/signup, /user/login, /chat, /healthmate)

Data Layer:
- SQLite database with user table
- Relevant database schema as shown in README

External Services:
- ChatGPT API connection

##### Flow Representation

- User authentication flow
- Health recommendation request/response flow
- ChatGPT API communication
- Database operations

##### Additional Elements

Include:
- API endpoints listing
- Database schema representation
- Security boundaries
- Request/response flow indicators

##### Technical Details to Highlight

- FastAPI framework usage
- RESTful API architecture
- Static file serving
- Database interactions
- External API integration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef api fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        Login["Login Page"]
        Signup["Signup Page"]
        MainApp["Main Application"]
        StaticAssets["Static Assets"]
    end

    %% Backend Layer
    subgraph Backend
        FastAPI["FastAPI Server"]
        AuthService["Authentication Service"]
        HealthService["Health Recommendation Service"]
        ChatService["ChatGPT Integration Service"]
        
        subgraph APIEndpoints
            UserAPI["/user/signup, /user/login"]
            ChatAPI["/chat"]
            HealthAPI["/healthmate"]
        end
    end

    %% Database Layer
    subgraph Database
        SQLite[(SQLite DB)]
    end

    %% External Services
    subgraph External
        ChatGPT["ChatGPT API"]
    end

    %% Relationships
    Login --> FastAPI
    Signup --> FastAPI
    MainApp --> FastAPI
    
    FastAPI --> AuthService
    FastAPI --> HealthService
    FastAPI --> ChatService
    
    AuthService --> UserAPI
    HealthService --> HealthAPI
    ChatService --> ChatAPI
    
    AuthService --> SQLite
    HealthService --> SQLite
    ChatService --> ChatGPT

    %% Styling
    class Login,Signup,MainApp,StaticAssets frontend
    class FastAPI,AuthService,HealthService,ChatService backend
    class UserAPI,ChatAPI,HealthAPI api
    class SQLite database
    class ChatGPT external

    %% Click Events
    click Login "https://github.com/Health-Mate-project/healthmate/blob/dev/app/static/login.html"
    click Signup "https://github.com/Health-Mate-project/healthmate/blob/dev/app/static/signup.html"
    click MainApp "https://github.com/Health-Mate-project/healthmate/blob/dev/app/static/main.html"
    click StaticAssets "https://github.com/Health-Mate-project/healthmate/tree/dev/app/static/"
    click FastAPI "https://github.com/Health-Mate-project/healthmate/blob/dev/app/main.py"
    click SQLite "https://github.com/Health-Mate-project/healthmate/blob/dev/app/users.db"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Component"]:::backend
        Database_L["Database"]:::database
        External_L["External Service"]:::external
        API_L["API Endpoint"]:::api
    end
```
