# haikali3/gymbara architecture

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

- Interactive diagram: https://gitdiagram.com/haikali3/gymbara
- Repository: https://github.com/haikali3/gymbara

## Overview

##### Main Components
- User Interface – This includes all aspects of the “frontend”: the Next.js pages (e.g., app/page.tsx, app/layout.tsx, and specific pages for workouts), and the reusable UI components (like Exercise Card, Timer, Header, Footer, etc.) found under src/components.
- State Management – Highlight the modules and stores in src/stores (for example, exercisesStore.ts, timerStore.ts, useWorkoutStore.ts) and the provider (src/providers/tanstack-provider.tsx). These are responsible for managing global state via Zustand.
- Utility & Services – Represent “utils” and “lib” folders that include utility functions and API service calls (e.g., src/utils/services/api.ts) to encapsulate business logic.
- Configuration & Styling – Although not a distinct runtime component, denote the use of Tailwind (tailwind.config.ts, postcss.config.mjs) and global CSS in app/globals.css, along with Next.js configuration (next.config.ts).
- External & Future Components – Optionally include planned backend integration elements (e.g., PostgreSQL for persistent data storage or user authentication as mentioned in the README’s Future Improvements). Although these are not yet implemented, noting them demonstrates the extensibility of the architecture.

##### Relationships & Data Flows
- Within the application, show the flow:
- From the layout/page components to the UI components (e.g., Workout and Timer components).
- From the UI components to the state management layer (Zustand stores) which allows cross-component state synchronization (e.g., timer updates and exercise session changes).
- From UI components and pages to the utility/services layer for API calls on workout tracking or persistent data operations.

##### Architectural Patterns & Principles
- Component-Based Architecture: Clearly segment Next.js page components and reusable UI components.
- Separation of Concerns: Distinct folders for UI (components), state (stores/providers), business logic (utils/services), and styling.
- Use of Modern Web Frameworks: Emphasize that Next.js handles both server-side rendering and client-side interaction, while Zustand manages application state efficiently.

##### Technologies and Frameworks
- Next.js & React: This framework handles rendering and component life cycles.
- Zustand: The lightweight state management library.
- Tailwind CSS: For rapid UI styling.
- TypeScript: For static type checking.

##### Details and Clarity
- Avoid oversimplification. It’s best to separate the project into as many distinct components as possible to capture all interactions observed in the file tree.
- Use a diagramming tool (such as the provided gymbara.drawio file) if needed to visually represent these components and their relationships.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Client/Browser"]:::client

    subgraph "Pages & Layouts"
        P1["Home Page"]:::ui
        P2["Layout"]:::ui
        P3["Workouts Page"]:::ui
        P4["Full Body Workout Page"]:::ui
    end

    subgraph "UI Components"
        U1["Exercise Card"]:::ui
        U2["Layout Components"]:::ui
        U3["Time Picker"]:::ui
        U4["Workout Section Card"]:::ui
        U5["UI Library"]:::ui
    end

    subgraph "State Management"
        S1["exercisesStore"]:::state
        S2["timerStore"]:::state
        S3["useWorkoutStore"]:::state
        S4["TanStack Provider"]:::state
    end

    subgraph "Utility & Services"
        UT1["Time Picker Utils"]:::utils
        UT2["Lib Utils"]:::utils
        UT3["API Services"]:::utils
    end

    subgraph "Configuration & Styling"
        C1["Next.js Config"]:::config
        C2["Tailwind Config"]:::config
        C3["PostCSS Config"]:::config
        C4["Global CSS"]:::config
    end

    R["Backend Integration (Planned)"]:::planned

    %% Connections between layers
    A -->|"loads"| P1
    P1 -->|"renders"| P2
    P2 -->|"navigates to"| P3
    P3 -->|"leads to"| P4
    P4 -->|"invokes"| U1
    U1 -->|"chains to"| U2
    U2 -->|"triggers"| U3
    U3 -->|"activates"| U4
    U4 -->|"interfaces with"| U5
    U5 -->|"updates state via"| S1
    S1 -->|"communicates with"| S2
    S2 -->|"syncs with"| S3
    S3 -->|"provided by"| S4

    %% UI Components interacting with utilities and state
    U1 -->|"calls"| UT1
    S4 -->|"fetches data via"| UT3
    %% Pages using configuration
    P2 -->|"applies"| C1
    %% Utility layer planning for future integration
    UT3 -->|"future integration"| R

    %% Class definitions for color coding
    classDef client fill:#fff2cc,stroke:#bf9000,stroke-width:2px;
    classDef ui fill:#f9cb9c,stroke:#cc4125,stroke-width:2px;
    classDef state fill:#cfe2f3,stroke:#1155cc,stroke-width:2px;
    classDef utils fill:#ead1dc,stroke:#b45f06,stroke-width:2px;
    classDef config fill:#d9ead3,stroke:#6aa84f,stroke-width:2px;
    classDef planned fill:#fce5cd,stroke:#e69138,stroke-width:2px;
    classDef app fill:#d9d2e9,stroke:#351c75,stroke-width:2px;

    %% Click Events for Pages & Layouts
    click P1 "https://github.com/haikali3/gymbara/blob/main/src/app/page.tsx"
    click P2 "https://github.com/haikali3/gymbara/blob/main/src/app/layout.tsx"
    click P3 "https://github.com/haikali3/gymbara/blob/main/src/app/workouts/page.tsx"
    click P4 "https://github.com/haikali3/gymbara/blob/main/src/app/workouts/full-body/page.tsx"

    %% Click Events for UI Components
    click U1 "https://github.com/haikali3/gymbara/tree/main/src/components/_exercise-card"
    click U2 "https://github.com/haikali3/gymbara/tree/main/src/components/_layout"
    click U3 "https://github.com/haikali3/gymbara/tree/main/src/components/_time-picker"
    click U4 "https://github.com/haikali3/gymbara/tree/main/src/components/_workout-section-card"
    click U5 "https://github.com/haikali3/gymbara/tree/main/src/components/ui"

    %% Click Events for State Management
    click S1 "https://github.com/haikali3/gymbara/blob/main/src/stores/exercisesStore.ts"
    click S2 "https://github.com/haikali3/gymbara/blob/main/src/stores/timerStore.ts"
    click S3 "https://github.com/haikali3/gymbara/blob/main/src/stores/useWorkoutStore.ts"
    click S4 "https://github.com/haikali3/gymbara/blob/main/src/providers/tanstack-provider.tsx"

    %% Click Events for Utility & Services
    click UT1 "https://github.com/haikali3/gymbara/blob/main/src/app/utils/time-picker-utils.tsx"
    click UT2 "https://github.com/haikali3/gymbara/blob/main/src/lib/utils.ts"
    click UT3 "https://github.com/haikali3/gymbara/blob/main/src/utils/services/api.ts"

    %% Click Events for Configuration & Styling
    click C1 "https://github.com/haikali3/gymbara/blob/main/next.config.ts"
    click C2 "https://github.com/haikali3/gymbara/blob/main/tailwind.config.ts"
    click C3 "https://github.com/haikali3/gymbara/blob/main/postcss.config.mjs"
    click C4 "https://github.com/haikali3/gymbara/blob/main/src/app/globals.css"
```
