# ayush-yadav11/heallink architecture

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

- Interactive diagram: https://gitdiagram.com/ayush-yadav11/heallink
- Repository: https://github.com/ayush-yadav11/heallink

## Overview

##### Project Type and Purpose
- This project is a front-end application built with React (leveraging Vite as the build tool) that serves as a smart healthcare assistant. Its main purpose is to provide AI-driven health advice based on user questions, offer multilingual responses (specifically English and Hindi), enable theme toggling (light/dark), and facilitate navigation to doctor recommendations and tips.
- The README emphasizes features such as AI-generated health assessments (via Google Gemini API), language translation (Google Cloud Translation API), and a responsive, animated UI, indicating a rich, interactive user interface for health insights.

##### File Structure
- Top-level files include configuration files like .gitignore, package.json, vite.config.js, and deployment configuration (vercel.json), delineating the project’s setup and deployment processes.
- The "src" directory is the core of the application, containing:
- App.jsx and main.jsx which are entry points for React.
- "pages" directory housing components like Home.jsx, DoctorPage.jsx, and specialized pages for AI responses and health advice.
- "context" folder with ThemeContext.tsx – essential for theme toggling (light/dark mode).
- "hooks" directory indicates custom hooks usage, with examples like useSpeechToText.js indicating enhancements like voice input.
- "utils" directory with gemini.js and translate.js managing calls to external APIs (Google Gemini and Google Cloud Translation).
- Public assets and doctors directory help indicate static resources and possibly image assets related to the UI.

##### README for Additional Insights
- The README confirms the technical stack (React, MUI, Framer Motion, React Router) and integration details with external services like Gemini AI and Google Translation APIs.
- The provided screenshots and project inspiration (GDG hackathon) underscore that the app focuses on usability and accessibility.

a. Main Components:
- Frontend Layer:
- UI Components (Pages such as Home, DoctorPage, HealthTips/AIResponse)
- Theme Management via ThemeContext
- Custom Hooks (e.g., for speech-to-text) providing additional interaction methods.
- API Integration Layer:
- Gemini API Integration handled in utils/gemini.js for retrieving AI-generated health assessments.
- Translation Service integration in utils/translate.js.
- Routing & State Management:
- React Router for navigation between pages.
- Context API (ThemeContext) for global state management (e.g., theme toggling).
- Static Assets & Public Resources:
- Public directory including assets and images for the UI.
- Build and Deployment Configuration:
- Vite for development and bundling.
- Vercel deployment configuration (vercel.json).

b. Directional Relationships and Interactions:
- User interactions in the UI trigger API calls via utility functions (gemini.js and translate.js).
- Responses from external APIs flow back to React components, which update the UI (possibly using animations via Framer Motion).
- The ThemeContext provides global state to components ensuring a consistent theme across routes.
- Navigation between pages is coordinated with React Router.
- Custom hooks (e.g., useSpeechToText) offer additional ways to input queries.

c. Architectural Patterns and Design Principles:
- Component-Based Architecture: Clear separation into pages, components, and context/hook layers.
- Single Page Application (SPA) using React Router for client-side routing.
- Separation of concerns: UI, API integrations, and state management are handled separately.
- Modular design: Utility functions and context/hook customizations enhance maintainability.

d. Relevant Technologies/Frameworks:
- Frontend Framework: React (with Vite for bundling).
- UI Library: Material UI (MUI) for components.
- Animation Library: Framer Motion to animate transitions.
- External APIs: Gemini AI for health advice and Google Cloud Translation API for multilingual support.
- Routing and State: React Router and Context API.

##### Final Advice
- Infrastructure elements such as configuration files (e.g., vite.config.js, vercel.json) in an annotations section to note deployment and build dependencies.
- Aim for a clear and detailed, yet organized, architectural representation that communicates the interactions between user-facing components and backend API integrations.

This approach will allow you, as the principal software engineer, to capture a comprehensive view of HealLink AI’s frontend architecture, highlighting every critical part from user interactions, API integrations, visual and state management, to deployment considerations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Nodes
    User["User"]:::external

    %% Frontend Application Layer
    subgraph "Frontend Application"
      direction TB
      Entrypoint["Entrypoints"]:::frontend
      App["App.jsx"]:::frontend
      Main["main.jsx"]:::frontend
      UI["UI Components (Pages)"]:::ui
      Theme["Theme Management (ThemeContext)"]:::state
      Hooks["Custom Hook (useSpeechToText)"]:::hooks
      APIs["API Integration Layer"]:::api

      %% UI Pages
      Home["Home.jsx"]:::ui
      DoctorPage["DoctorPage.jsx"]:::ui
      AIResponse["AIResponse.jsx"]:::ui
      HealthTips["HealthTips.jsx"]:::ui
      RemoteDoctor["RemoteDoctor.jsx"]:::ui

      %% API Utilities
      Gemini["Gemini Integration (gemini.js)"]:::api
      Translate["Translation Integration (translate.js)"]:::api

      %% Connections within Frontend Application
      Entrypoint --> App
      Entrypoint --> Main
      App --> UI
      Main --> UI
      UI --> Home
      UI --> DoctorPage
      UI --> AIResponse
      UI --> HealthTips
      UI --> RemoteDoctor
      UI --> Theme
      UI --> Hooks
      UI --> APIs
      APIs --> Gemini
      APIs --> Translate
      User -->|"interacts"| UI
    end

    %% Infrastructure & Configurations Layer
    subgraph "Infrastructure & Configurations"
      direction TB
      Build["Build Config (Vite)"]:::infra
      Deployment["Deployment Config (Vercel)"]:::infra
      Assets["Static Assets"]:::assets
      Doctors["Doctors Assets (public/assets/doctors)"]:::assets
    end

    %% Connections with Infrastructure
    App -->|"loaded by"| Build
    Main --> Build
    Build --- Deployment
    UI --- Assets
    Assets --> Doctors

    %% Click Events for components
    click Home "https://github.com/ayush-yadav11/heallink/blob/main/src/pages/Home.jsx"
    click DoctorPage "https://github.com/ayush-yadav11/heallink/blob/main/src/pages/DoctorPage.jsx"
    click AIResponse "https://github.com/ayush-yadav11/heallink/blob/main/src/pages/AIResponse.jsx"
    click HealthTips "https://github.com/ayush-yadav11/heallink/blob/main/src/pages/HealthTips.jsx"
    click RemoteDoctor "https://github.com/ayush-yadav11/heallink/blob/main/src/pages/RemoteDoctor.jsx"
    click Theme "https://github.com/ayush-yadav11/heallink/blob/main/src/context/ThemeContext.tsx"
    click Hooks "https://github.com/ayush-yadav11/heallink/blob/main/src/hooks/useSpeechToText.js"
    click Gemini "https://github.com/ayush-yadav11/heallink/blob/main/src/utils/gemini.js"
    click Translate "https://github.com/ayush-yadav11/heallink/blob/main/src/utils/translate.js"
    click App "https://github.com/ayush-yadav11/heallink/blob/main/src/App.jsx"
    click Main "https://github.com/ayush-yadav11/heallink/blob/main/src/main.jsx"
    click Build "https://github.com/ayush-yadav11/heallink/blob/main/vite.config.js"
    click Deployment "https://github.com/ayush-yadav11/heallink/blob/main/vercel.json"
    click Assets "https://github.com/ayush-yadav11/heallink/tree/main/public"

    %% Styles
    classDef external fill:#f8f8f8,stroke:#333,stroke-width:2px;
    classDef frontend fill:#b3cde0,stroke:#1f78b4,stroke-width:2px;
    classDef ui fill:#a6cee3,stroke:#1f78b4,stroke-width:2px;
    classDef state fill:#fdbf6f,stroke:#ff7f00,stroke-width:2px;
    classDef hooks fill:#cab2d6,stroke:#6a3d9a,stroke-width:2px;
    classDef api fill:#ccebc5,stroke:#33a02c,stroke-width:2px;
    classDef infra fill:#ffcc99,stroke:#e6550d,stroke-width:2px;
    classDef assets fill:#d9d9d9,stroke:#525252,stroke-width:2px;
```
