# dano796/all-in-one-fitness-app architecture

> Architecture diagram of the GitHub repository dano796/all-in-one-fitness-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dano796/all-in-one-fitness-app
- Repository: https://github.com/dano796/all-in-one-fitness-app

## Overview

##### File structure
- Top-level:
- public/ – static assets, service-worker, manifest (PWA setup)
- src/ – main frontend code
– assets/ – audio files for timers
– components/ – reusable UI widgets (buttons, calculators, lists, loaders, chatbot, etc.)
– layouts/ – page wrappers (AuthLayout, DashboardLayout, CalculatorLayouts, etc.)
– pages/ – route-level views (Landing, Dashboard, FoodDashboard, Routines, Login, Register, etc.)
– lib/ – supabaseClient.ts (initializes Supabase connection), utils.ts
– store/ – global state management (probably Zustand)
– theme.ts / types/ / css files / main.tsx – entrypoint
- Config & tooling: tailwind.config.js, postcss.config.js, vite.config.ts, tsconfigs, eslint.config.js, vercel.json (deployment).

##### README for additional insights
- Frontend: React + Vite + TypeScript, Tailwind, Framer Motion, Swal
- Backend: Supabase (Auth, DB), Node/Express mentioned (but code not in this repo).
- Features: auth, calorie tracker, exercise & hydration logging, custom routines, calculators.

a. Main components:
- Browser / Mobile Client (React SPA)
- UI Layer: Components → Layouts → Pages
- State Layer: store (authStore, other global state)
- Data Layer: supabaseClient + utils
- Static Hosting: Vercel (serves index.html, JS bundle, assets, service-worker)
- Supabase Services:
- Authentication (signup, login, password recovery)
- Database (users, foods, exercises, routines, hydration logs)
- Storage (optional for image uploads via ImageUploadDragDrop)
- External Libraries: Tailwind CSS, Framer Motion, Swal, ChatBot AI API (if any)
b. Relationships & interactions:
- User interacts with the React SPA in their browser.
- SPA fetches & mutates data through supabaseClient → Supabase REST/Gotrue/PostgREST endpoints.
- State store holds user/session data and caches lists (foods, routines).
- Components dispatch actions to the store or call supabaseClient directly.
- Service-worker intercepts requests for offline support / caching.
- Hosting layer delivers the static bundle.
c. Architectural patterns / design principles:
- Single-Page Application (SPA) with client-side routing.
- Component-driven UI (atomic/reusable components).
- Layout-based page composition.
- Global state via lightweight store.
- BaaS for backend to reduce custom server code.
- PWA features (service-worker, manifest).
d. Relevant technologies:
- React, Vite, TypeScript, Tailwind CSS, Framer Motion, Swal
- Zustand (assumed) or similar for state
- Supabase (Auth, Database, Storage)
- Vercel (deployment)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Users and Clients
    User["User"]:::external
    subgraph "Browser / React SPA"
        direction TB
        SPA["React SPA"]:::frontend

        subgraph "UI Components Layer"
            direction TB
            UIComponents["UI Components"]:::frontend
            Progress["Progress Component"]:::frontend
        end

        subgraph "Layouts" 
            direction TB
            AuthLayout["AuthLayout"]:::frontend
            DashboardLayout["DashboardLayout"]:::frontend
            CalorieCalcLayout["CalorieCalculatorLayout"]:::frontend
            FoodSearchLayout["FoodSearchLayout"]:::frontend
            OneRMLayout["OneRMCalculatorLayout"]:::frontend
            RecipeLayout["RecipeLayout"]:::frontend
            WaterLayout["WaterLayout"]:::frontend
        end

        subgraph "Pages"
            direction TB
            LandingPage["LandingPage"]:::frontend
            DashboardPage["Dashboard"]:::frontend
            FoodDashboard["FoodDashboard"]:::frontend
            FoodSearchIAPage["FoodSearchIAPage"]:::frontend
            Routines["Routines"]:::frontend
            RoutineDetails["RoutineDetails"]:::frontend
            WaterDashboard["WaterDashboard"]:::frontend
            RMProgressPage["RMProgressPage"]:::frontend
            ModulesPage["ModulesPage"]:::frontend
            LoginPage["LoginPage"]:::frontend
            RegisterPage["RegisterPage"]:::frontend
            ResetPassword["ResetPassword"]:::frontend
            AuthCallback["AuthCallback"]:::frontend
            ContactPage["ContactPage"]:::frontend
            AboutPage["AboutPage"]:::frontend
            Settings["Settings"]:::frontend
            RegisteredFoods["RegisteredFoods"]:::frontend
            ThemeContext["ThemeContext"]:::frontend
        end

        Store["Auth Store"]:::state
        SupabaseClient["supabaseClient"]:::data
        Utils["utils"]:::data
    end

    subgraph "Hosting & PWA"
        direction TB
        Vercel["Vercel"]:::hosting
        ServiceWorker["service-worker.js"]:::hosting
        Manifest["site.webmanifest"]:::hosting
        IndexHTML["index.html"]:::hosting
    end

    subgraph "Supabase Services"
        direction TB
        AuthService["Auth"]:::cloud
        Database["Database"]:::db
        StorageService["Storage"]:::cloud
    end

    %% Connections
    User -->|"Uses"| SPA
    Vercel -->|"Serves"| IndexHTML
    IndexHTML -->|"Loads"| SPA
    SPA -->|"Renders"| UIComponents
    SPA -->|"Uses"| Progress
    SPA -->|"Applies Layouts"| AuthLayout
    SPA -->|"Applies Layouts"| DashboardLayout
    SPA -->|"Applies Layouts"| CalorieCalcLayout
    SPA -->|"Applies Layouts"| FoodSearchLayout
    SPA -->|"Applies Layouts"| OneRMLayout
    SPA -->|"Applies Layouts"| RecipeLayout
    SPA -->|"Applies Layouts"| WaterLayout
    SPA -->|"Navigates to Pages"| LandingPage
    SPA -->|"Navigates to Pages"| DashboardPage
    SPA -->|"Navigates to Pages"| FoodDashboard
    SPA -->|"Navigates to Pages"| FoodSearchIAPage
    SPA -->|"Navigates to Pages"| Routines
    SPA -->|"Navigates to Pages"| RoutineDetails
    SPA -->|"Navigates to Pages"| WaterDashboard
    SPA -->|"Navigates to Pages"| RMProgressPage
    SPA -->|"Navigates to Pages"| ModulesPage
    SPA -->|"Navigates to Pages"| LoginPage
    SPA -->|"Navigates to Pages"| RegisterPage
    SPA -->|"Navigates to Pages"| ResetPassword
    SPA -->|"Navigates to Pages"| AuthCallback
    SPA -->|"Navigates to Pages"| ContactPage
    SPA -->|"Navigates to Pages"| AboutPage
    SPA -->|"Navigates to Pages"| Settings
    SPA -->|"Navigates to Pages"| RegisteredFoods
    SPA -->|"Navigates to Pages"| ThemeContext
    SPA -->|"Manages State"| Store
    SPA -->|"Calls"| SupabaseClient
    SPA -->|"Calls"| Utils

    SupabaseClient -->|"Auth API"| AuthService
    SupabaseClient -->|"DB API"| Database
    SupabaseClient -->|"Storage API"| StorageService

    ServiceWorker <-->|"Intercepts / Caches"| SPA

    %% Click Events
    click UIComponents "https://github.com/dano796/all-in-one-fitness-app/tree/main/src/components"
    click Progress "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/components/ui/progress.tsx"
    click AuthLayout "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/layouts/AuthLayout.tsx"
    click DashboardLayout "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/layouts/DashboardLayout.tsx"
    click CalorieCalcLayout "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/layouts/CalorieCalculatorLayout.tsx"
    click FoodSearchLayout "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/layouts/FoodSearchLayout.tsx"
    click OneRMLayout "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/layouts/OneRMCalculatorLayout.tsx"
    click RecipeLayout "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/layouts/RecipeLayout.tsx"
    click WaterLayout "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/layouts/WaterLayout.tsx"
    click LandingPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/LandingPage.tsx"
    click DashboardPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/Dashboard.tsx"
    click FoodDashboard "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/FoodDashboard.tsx"
    click FoodSearchIAPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/FoodSearchIAPage.tsx"
    click Routines "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/Routines.tsx"
    click RoutineDetails "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/RoutineDetails.tsx"
    click WaterDashboard "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/WaterDashboard.tsx"
    click RMProgressPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/RMProgressPage.tsx"
    click ModulesPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/ModulesPage.tsx"
    click LoginPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/LoginPage.tsx"
    click RegisterPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/RegisterPage.tsx"
    click ResetPassword "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/ResetPassword.tsx"
    click AuthCallback "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/AuthCallback.tsx"
    click ContactPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/ContactPage.tsx"
    click AboutPage "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/AboutPage.tsx"
    click Settings "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/Settings.tsx"
    click RegisteredFoods "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/RegisteredFoods.tsx"
    click ThemeContext "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/pages/ThemeContext.tsx"
    click Store "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/store/authStore.ts"
    click SupabaseClient "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/lib/supabaseClient.ts"
    click Utils "https://github.com/dano796/all-in-one-fitness-app/blob/main/src/lib/utils.ts"
    click ServiceWorker "https://github.com/dano796/all-in-one-fitness-app/blob/main/public/service-worker.js"
    click Manifest "https://github.com/dano796/all-in-one-fitness-app/blob/main/public/site.webmanifest"
    click IndexHTML "https://github.com/dano796/all-in-one-fitness-app/blob/main/index.html"

    %% Styles
    classDef frontend fill:#E8F1FF,stroke:#0366D6,color:#0366D6;
    classDef state fill:#FFF4E5,stroke:#D97706,color:#D97706;
    classDef data fill:#E8FFE8,stroke:#059669,color:#059669;
    classDef hosting fill:#FFF1F2,stroke:#B91C1C,color:#B91C1C;
    classDef cloud fill:#E8F5FF,stroke:#0369A1,color:#0369A1;
    classDef db fill:#F0FDF4,stroke:#065F46,color:#065F46;
    classDef external fill:#F3F4F6,stroke:#374151,color:#374151;
```
