# noorulameen17/fitgen-ai architecture

> Architecture diagram of the GitHub repository noorulameen17/fitgen-ai, 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/noorulameen17/fitgen-ai
- Repository: https://github.com/noorulameen17/fitgen-ai

## Overview

##### Project Type and Purpose
- The project is a full-stack web application built with Next.js.
- Its structure suggests that it includes both user-facing pages (e.g., healthChat, mealPlan, dashboard, sign-in, sign-up) and backend API routes (found under app/api).
- The use of Supabase in lib/supabaseClient.js indicates that backend data operations or authentication might be handled through that service.

##### Main Components
a. Frontend Client:
- Various page modules under the "app" directory (for example, pages like app/page.js, app/healthChat/page.js, app/mealPlan, etc.).
- Routing and component hierarchies: views like dashboard, generate, healthInput, and the navigation (navbar component).
b. API Layer:
- API endpoints under app/api (healthChat and mealPlan). These are likely handling backend logic and data operations.
c. UI Components:
d. External Services:
- Supabase (via app/lib/supabaseClient.js). This suggests database or authentication operations.
e. Configuration and Build Tools:
- Mention development utilities/configuration like next.config.mjs, tailwind.config.js, postcss.config.js, and jsconfig.json, which inform how the project is built, styled, and deployed.
f. Static Assets:
- Public assets (fonts and others in the public directory), which contribute to the frontend’s presentation.

##### Relationships and Interactions
- How user requests flow from the frontend pages to API endpoints. For example:
- A user interacts with the healthChat page → triggers API endpoint (app/api/healthChat/route.js) → processes data possibly integrating with Supabase.
- How the dashboard, sign-in, sign-up pages wrap other UI components and interact with underlying APIs.
- That UI components are used across multiple pages and that these components handle shared presentation logic within the application.

##### Architectural Patterns and Technologies
- This project is structured with Next.js conventions, separating server-side API routes (within app/api) and client-side rendering (under app pages).
- The use of components hints at a component-based, modular architecture.
- Integrate the use of Tailwind CSS for styling (as indicated by tailwind.config.js and globals.css).
- Client-server model inherent in Next.js, where server components (APIs) work in tandem with client pages.

##### Final Steps
- Out high-level blocks: Frontend (with pages and reusable UI components), API (including routes for healthChat and mealPlan), and External Services (Supabase).
- Inside the Frontend block, further sub-divide to show pages under app (healthChat, healthInput, sign-in/up, dashboard, generate) and common layout components from the components folder.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User Browser"]:::user

    subgraph "Frontend Layer"
        subgraph "Pages"
            Home["Home Page"]:::frontend
            HealthChat["HealthChat Page"]:::frontend
            HealthInput["HealthInput Page"]:::frontend
            Dashboard["Dashboard Page"]:::frontend
            Generate["Generate Page"]:::frontend
            SignIn["Sign-In Page"]:::frontend
            SignUp["Sign-Up Page"]:::frontend
        end
        subgraph "Navigation/Layout"
            Layout["Layout"]:::frontend
            Navbar["Navbar"]:::frontend
        end
        subgraph "UI Components"
            UIComponents["UI Components"]:::ui
            Cardio["Cardio Component"]:::ui
            LoadingState["Loading State"]:::ui
        end
    end

    subgraph "Backend/API Layer"
        HealthChatAPI["Health Chat API"]:::api
        MealPlanAPI["Meal Plan API"]:::api
    end

    subgraph "Configuration & Assets"
        NextConfig["Next.js Config"]:::config
        TailwindConfig["Tailwind CSS Config"]:::config
        GlobalsCSS["Globals CSS"]:::config
        PostCSS["PostCSS Config"]:::config
        JSConfig["JSConfig"]:::config
        Fonts["Fonts & Assets"]:::config
    end

    subgraph "External Services"
        Supabase["Supabase"]:::external
    end

    %% User Requests to Frontend Pages and Navigation/Layout
    User -->|"requests"| Layout
    User -->|"requests"| Home
    User -->|"requests"| HealthChat
    User -->|"requests"| HealthInput
    User -->|"requests"| Dashboard
    User -->|"requests"| Generate
    User -->|"requests"| SignIn
    User -->|"requests"| SignUp

    %% UI Components usage
    Layout -->|"includes"| UIComponents
    Navbar -->|"includes"| UIComponents

    %% API Calls from Frontend Pages
    HealthChat -->|"API_call"| HealthChatAPI
    Dashboard -->|"API_call"| MealPlanAPI

    %% API interactions with External Service
    HealthChatAPI -->|"data"| Supabase
    MealPlanAPI -->|"data"| Supabase

    %% Click Events for Frontend Client (Pages & Layout)
    click Home "https://github.com/noorulameen17/fitgen-ai/blob/main/app/page.js"
    click HealthChat "https://github.com/noorulameen17/fitgen-ai/blob/main/app/healthChat/page.js"
    click HealthInput "https://github.com/noorulameen17/fitgen-ai/blob/main/app/healthInput/page.js"
    click Dashboard "https://github.com/noorulameen17/fitgen-ai/blob/main/app/dashboard/page.js"
    click Generate "https://github.com/noorulameen17/fitgen-ai/blob/main/app/generate/page.js"
    click SignIn "https://github.com/noorulameen17/fitgen-ai/blob/main/app/sign-in/[[...sign-in]]/page.js"
    click SignUp "https://github.com/noorulameen17/fitgen-ai/blob/main/app/sign-up/[[...sign-up]]/page.js"
    click Layout "https://github.com/noorulameen17/fitgen-ai/blob/main/app/layout.js"
    click Navbar "https://github.com/noorulameen17/fitgen-ai/blob/main/app/navbar/page.js"

    %% Click Events for API Layer
    click HealthChatAPI "https://github.com/noorulameen17/fitgen-ai/blob/main/app/api/healthChat/route.js"
    click MealPlanAPI "https://github.com/noorulameen17/fitgen-ai/blob/main/app/api/mealPlan/route.js"

    %% Click Events for UI Components
    click UIComponents "https://github.com/noorulameen17/fitgen-ai/tree/main/components/ui"
    click Cardio "https://github.com/noorulameen17/fitgen-ai/blob/main/components/cardio.js"
    click LoadingState "https://github.com/noorulameen17/fitgen-ai/blob/main/components/loading-state.jsx"

    %% Click Event for External Services
    click Supabase "https://github.com/noorulameen17/fitgen-ai/blob/main/app/lib/supabaseClient.js"

    %% Click Events for Configuration and Assets
    click NextConfig "https://github.com/noorulameen17/fitgen-ai/blob/main/next.config.mjs"
    click TailwindConfig "https://github.com/noorulameen17/fitgen-ai/blob/main/tailwind.config.js"
    click GlobalsCSS "https://github.com/noorulameen17/fitgen-ai/blob/main/app/globals.css"
    click PostCSS "https://github.com/noorulameen17/fitgen-ai/blob/main/postcss.config.js"
    click JSConfig "https://github.com/noorulameen17/fitgen-ai/blob/main/jsconfig.json"
    click Fonts "https://github.com/noorulameen17/fitgen-ai/tree/main/public/fonts"

    classDef frontend fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef api fill:#F9E79F,stroke:#F4D03F,stroke-width:2px;
    classDef external fill:#ABEBC6,stroke:#45B39D,stroke-width:2px;
    classDef config fill:#E8DAEF,stroke:#AF7AC5,stroke-width:2px;
    classDef ui fill:#FCF3CF,stroke:#F7DC6F,stroke-width:2px;
    classDef user fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
```
