# jigarsk/fitnesstracker architecture

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

- Interactive diagram: https://gitdiagram.com/jigarsk/fitnesstracker
- Repository: https://github.com/jigarsk/fitnesstracker

## Overview

##### Project type and purpose
- This is a full-stack web application called “FitnessTracker.”
- The frontend is a React + TypeScript single-page app (Vite, Tailwind CSS).
- The backend is an Express/Node.js REST API with routes for authentication, meals, workouts, profiles.
- Data is persisted in a database (likely MongoDB or another NoSQL/SQL store) and there’s a Firebase config file on the frontend for additional services (e.g., hosting, analytics, or auth).

##### File structure
- Top-level:
- index.html, package.json, tailwind.config.js, vite.config.ts, tsconfig files, README.md
- src/ – React source: App.tsx, main.tsx, component library, page views (Landing, Dashboard, Nutrition, Workout, Profile, etc.), API wrappers, context providers, CSS.
- backend/ – Node/Express server: server.js entry point, Routes/ (authRoutes.js, mealRoutes.js, workoutRoutes.js, profileRoutes.js), models/ (User.js, Meals.js, Workouts.js), package.json, .env for DB and secrets.
- Patterns & conventions:
- Frontend: Context API for state management (authContext, nutritionContext, workoutContext, BMRContext).
- Backend: MVC-style separation (models + route handlers).
- Configuration: .env at both levels, ESLint, PostCSS & Tailwind, Vite for bundling.

##### README
- Only a title “# FitnessTracker” is provided; no architectural notes.
- We’ll infer architecture solely from the file tree.

##### Elements
- Blue for frontend elements
- Green for backend services
- Orange for external/cloud services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    User["User Browser"]:::external

    %% Client Layer
    subgraph "Web Client (React + TS)" 
        direction TB
        HTML["index.html"]:::frontend
        Main["src/main.tsx"]:::frontend
        App["src/App.tsx"]:::frontend
        subgraph "Pages & Routing"
            direction TB
            Landing["LandingPage.tsx"]:::frontend
            Dashboard["Dashboard.tsx"]:::frontend
            Login["Login.tsx"]:::frontend
            Signup["Signup.tsx"]:::frontend
            Nutrition["Nutrition.tsx"]:::frontend
            NutritionForm["NutritionForm.tsx"]:::frontend
            Workouts["Workouts.tsx"]:::frontend
            WorkoutForm["WorkoutForm.tsx"]:::frontend
            Profile["Profile.tsx"]:::frontend
            Progress["Progress.tsx"]:::frontend
            Protected["protectedRoutes.tsx"]:::frontend
        end
        subgraph "Components & UI"
            direction TB
            Navbar["Navbar.tsx"]:::frontend
            subgraph "Homepage Sections"
                direction TB
                Header["Header.tsx"]:::frontend
                Hero["HeroSection.tsx"]:::frontend
                Feature["FeatureSection.tsx"]:::frontend
                Activity["ActivitySection.tsx"]:::frontend
                Pricing["PricingSection.tsx"]:::frontend
                Testimonial["TestimonialSection.tsx"]:::frontend
                NewsLetter["NewsLetterSection.tsx"]:::frontend
                Footer["Footer.tsx"]:::frontend
                Icons["Icons.tsx"]:::frontend
            end
        end
        subgraph "State Management (Context)"
            direction TB
            AuthCtx["authContext.tsx"]:::frontend
            NutriCtx["nutritionContext.tsx"]:::frontend
            WorkCtx["workoutContext.tsx"]:::frontend
            BMRCtx["BMRContext.tsx"]:::frontend
        end
        API["authApi.ts"]:::frontend
        Firebase["src/firebase.ts"]:::external
        CSS["src/index.css"]:::frontend
        subgraph "Config & Tooling"
            direction TB
            Tailwind["tailwind.config.js"]:::frontend
            PostCSS["postcss.config.js"]:::frontend
            Vite["vite.config.ts"]:::frontend
            TSApp["tsconfig.app.json"]:::frontend
            TSNode["tsconfig.node.json"]:::frontend
            TSGen["tsconfig.json"]:::frontend
        end
    end

    %% Server Layer
    subgraph "API Server (Node.js + Express)"
        direction TB
        ServerJS["backend/server.js"]:::backend
        subgraph "Routes"
            direction TB
            AuthRoutes["authRoutes.js"]:::backend
            MealRoutes["mealRoutes.js"]:::backend
            WorkoutRoutes["workoutRoutes.js"]:::backend
            ProfileRoutes["profileRoutes.js"]:::backend
        end
        subgraph "Models"
            direction TB
            UserModel["User.js"]:::backend
            MealsModel["Meals.js"]:::backend
            WorkoutsModel["Workouts.js"]:::backend
        end
        BEEnv["backend/.env"]:::backend
    end

    %% Data Layer
    DB[(MongoDB)]:::database

    %% External Services
    subgraph "External Services"
        direction TB
        FirebaseSvc["Firebase"]:::external
    end

    %% Connections
    User -->|"Interacts with UI"| HTML
    HTML --> Main
    Main --> App
    App -->|"Renders Pages"| Landing
    App --> Dashboard
    App --> Login
    App --> Signup
    App --> Nutrition
    App --> Workouts
    App --> Profile
    App --> Progress
    Landing --> Navbar
    Dashboard --> Navbar
    Login --> Navbar
    Signup --> Navbar
    Profile --> Navbar
    Progress --> Navbar
    Navbar --> Brand
    App --> Protected
    Protected --> Dashboard
    App --> API
    API -->|"HTTP/HTTPS JSON"| ServerJS
    ServerJS --> AuthRoutes
    ServerJS --> MealRoutes
    ServerJS --> WorkoutRoutes
    ServerJS --> ProfileRoutes
    AuthRoutes --> UserModel
    MealRoutes --> MealsModel
    WorkoutRoutes --> WorkoutsModel
    ProfileRoutes --> UserModel
    ServerJS --> DB
    App --> Firebase
    ServerJS --> FirebaseSvc

    %% Click Events
    click Main "https://github.com/jigarsk/fitnesstracker/blob/main/src/main.tsx"
    click App "https://github.com/jigarsk/fitnesstracker/blob/main/src/App.tsx"
    click Landing "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/LandingPage.tsx"
    click Dashboard "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Dashboard.tsx"
    click Login "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Login.tsx"
    click Signup "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Signup.tsx"
    click Nutrition "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Nutrition/Nutrition.tsx"
    click NutritionForm "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Nutrition/NutritionForm.tsx"
    click Workouts "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Workout/Workouts.tsx"
    click WorkoutForm "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Workout/WorkoutForm.tsx"
    click Profile "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Profile.tsx"
    click Progress "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/Progress.tsx"
    click Protected "https://github.com/jigarsk/fitnesstracker/blob/main/src/pages/protectedRoutes.tsx"
    click Navbar "https://github.com/jigarsk/fitnesstracker/blob/main/src/components/Navbar.tsx"
    click Header "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/Header.tsx"
    click Hero "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/HeroSection.tsx"
    click Feature "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/FeatureSection.tsx"
    click Activity "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/ActivitySection.tsx"
    click Pricing "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/PricingSection.tsx"
    click Testimonial "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/TestimonialSection.tsx"
    click NewsLetter "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/NewsLetterSection.tsx"
    click Footer "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/Footer.tsx"
    click Icons "https://github.com/jigarsk/fitnesstracker/blob/main/src/Homepage/Icons.tsx"
    click AuthCtx "https://github.com/jigarsk/fitnesstracker/blob/main/src/context/authContext.tsx"
    click NutriCtx "https://github.com/jigarsk/fitnesstracker/blob/main/src/context/nutritionContext.tsx"
    click WorkCtx "https://github.com/jigarsk/fitnesstracker/blob/main/src/context/workoutContext.tsx"
    click BMRCtx "https://github.com/jigarsk/fitnesstracker/blob/main/src/context/BMRContext.tsx"
    click API "https://github.com/jigarsk/fitnesstracker/blob/main/src/api/authApi.ts"
    click Firebase "https://github.com/jigarsk/fitnesstracker/blob/main/src/firebase.ts"
    click CSS "https://github.com/jigarsk/fitnesstracker/blob/main/src/index.css"
    click Tailwind "https://github.com/jigarsk/fitnesstracker/blob/main/tailwind.config.js"
    click PostCSS "https://github.com/jigarsk/fitnesstracker/blob/main/postcss.config.js"
    click Vite "https://github.com/jigarsk/fitnesstracker/blob/main/vite.config.ts"
    click TSApp "https://github.com/jigarsk/fitnesstracker/blob/main/tsconfig.app.json"
    click TSNode "https://github.com/jigarsk/fitnesstracker/blob/main/tsconfig.node.json"
    click TSGen "https://github.com/jigarsk/fitnesstracker/blob/main/tsconfig.json"
    click ServerJS "https://github.com/jigarsk/fitnesstracker/blob/main/backend/server.js"
    click AuthRoutes "https://github.com/jigarsk/fitnesstracker/blob/main/backend/Routes/authRoutes.js"
    click MealRoutes "https://github.com/jigarsk/fitnesstracker/blob/main/backend/Routes/mealRoutes.js"
    click WorkoutRoutes "https://github.com/jigarsk/fitnesstracker/blob/main/backend/Routes/workoutRoutes.js"
    click ProfileRoutes "https://github.com/jigarsk/fitnesstracker/blob/main/backend/Routes/profileRoutes.js"
    click UserModel "https://github.com/jigarsk/fitnesstracker/blob/main/backend/models/User.js"
    click MealsModel "https://github.com/jigarsk/fitnesstracker/blob/main/backend/models/Meals.js"
    click WorkoutsModel "https://github.com/jigarsk/fitnesstracker/blob/main/backend/models/Workouts.js"
    click BEEnv "https://github.com/jigarsk/fitnesstracker/blob/main/backend/.env"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0066CC,color:#000
    classDef backend fill:#DFF2D8,stroke:#339933,color:#000
    classDef external fill:#FFE7C7,stroke:#CC6600,color:#000
    classDef database fill:#E0E0E0,stroke:#888888,color:#000
```
