# infantajayvenus/gymbooku architecture

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

- Interactive diagram: https://gitdiagram.com/infantajayvenus/gymbooku
- Repository: https://github.com/infantajayvenus/gymbooku

## Overview

##### Main Application Architecture

a. Presentation Layer (UI Components)
- Use a container at the top level representing the React application
- Divide into main pages/screens:
- Home/WorkoutTrackerScreen
- WeightTracker
- WorkoutList
- WorkoutPlanner

b. State Management Layer
- Reducers (PlanReducer, WeightReducer, WorkoutReducer, WorkoutTrackReducer)
- To custom hooks that manage state persistence

c. Data Storage Layer
- IndexedDB storage
- Local data models (Plan, Workout, WorkoutRecord, WeightCollection, StreakData)

##### Component Structure
- Main App component
- Reusable components (SetTrackCard, WorkoutTrackCard, StreakCard)
- Form components (PlanForm, WorkoutForm)
- Utility components (SortableList, TabPanel)

##### Data Flow
- User interactions → Components
- Components → Reducers
- Reducers → IndexedDB
- Custom hooks → Components

##### Specific Implementation Details
- Custom hooks (useStreakData, useLatestTrackData, useWeeklyWeightTrackedData)
- Utility functions (getAverage, getWeek, isTimestampToday)

- Blue: UI Components
- Green: Data Storage
- Orange: State Management
- Purple: Utility Functions
- Yellow: Custom Hooks

**[User Interface Layer]**
- ↕
**[Component Layer]**
- ↕
**[Custom Hooks Layer]**
- ↕
**[State Management Layer]**
- ↕
**[Data Storage Layer]**

Important elements to emphasize:
##### The feature modules (workout tracking, weight tracking, planning)

- Component types
- State management flow

Keep the abstraction level focused on the architectural decisions while showing the main features (workout tracking, planning, and streak monitoring) as they are core to the application's purpose.

Remember to highlight the offline-capable nature of the application and how data persistence is handled through the custom hooks and reducers to IndexedDB storage.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        Pages["Pages Container"]
        Home["Home Page"]:::ui
        WeightTracker["Weight Tracker"]:::ui
        WorkoutList["Workout List"]:::ui
        WorkoutPlanner["Workout Planner"]:::ui
        
        Components["UI Components"]
        PlanForm["Plan Form"]:::ui
        WorkoutForm["Workout Form"]:::ui
        SetTrackCard["Set Track Card"]:::ui
        WorkoutTrackCard["Workout Track Card"]:::ui
        StreakCard["Streak Card"]:::ui
        
        SharedUI["Shared UI Elements"]
        TabPanel["Tab Panel"]:::ui
        Puller["Puller"]:::ui
        GymBookuIcon["GymBooku Icon"]:::ui
        ExpandMore["Expand More"]:::ui
    end
    
    subgraph StateManagement
        Reducers["Reducers"]
        PlanReducer["Plan Reducer"]:::state
        WeightReducer["Weight Reducer"]:::state
        WorkoutReducer["Workout Reducer"]:::state
        WorkoutTrackReducer["Workout Track Reducer"]:::state
    end
    
    subgraph DataModels
        Plan["Plan Model"]:::model
        Workout["Workout Model"]:::model
        WorkoutRecord["Workout Record"]:::model
        WeightCollection["Weight Collection"]:::model
        StreakData["Streak Data"]:::model
    end
    
    subgraph CustomHooks
        useLatestTrackData["useLatestTrackData"]:::hook
        usePlannedWorkoutsList["usePlannedWorkoutsList"]:::hook
        useStreakData["useStreakData"]:::hook
        useWeeklyWeightTrackedData["useWeeklyWeightTrackedData"]:::hook
        useDrawer["useDrawer"]:::hook
        useBackButton["useBackButton"]:::hook
        useStoredReducer["useStoredReducer"]:::hook
    end
    
    subgraph DataPersistence
        IndexedDB["IndexedDB Storage"]:::storage
        ServiceWorker["Service Worker"]:::storage
    end
    
    %% Relationships
    Pages --> Components
    Components --> SharedUI
    Reducers --> DataModels
    DataModels --> IndexedDB
    CustomHooks --> Reducers
    ServiceWorker --> IndexedDB
    
    %% Click Events
    click Home "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/pages/Home/index.tsx"
    click WeightTracker "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/pages/WeightTracker.tsx"
    click WorkoutList "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/pages/WorkoutList.tsx"
    click WorkoutPlanner "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/pages/WorkoutPlanner.tsx"
    click PlanForm "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/PlanForm.tsx"
    click WorkoutForm "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/WorkoutForm.tsx"
    click SetTrackCard "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/SetTrackCard.tsx"
    click WorkoutTrackCard "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/WorkoutTrackCard.tsx"
    click StreakCard "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/StreakCard.tsx"
    click TabPanel "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/TabPanel.tsx"
    click Puller "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/Puller.ts"
    click GymBookuIcon "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/GymBookuIcon.tsx"
    click ExpandMore "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/components/ExpandMore.tsx"
    click PlanReducer "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/reducers/PlanReducer.ts"
    click WeightReducer "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/reducers/WeightReducer.ts"
    click WorkoutReducer "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/reducers/WorkoutReducer.ts"
    click WorkoutTrackReducer "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/reducers/WorkoutTrackReducer.ts"
    click Plan "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/models/Plan.ts"
    click Workout "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/models/Workout.ts"
    click WorkoutRecord "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/models/WorkoutRecord.ts"
    click WeightCollection "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/models/WeightCollection.ts"
    click StreakData "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/models/StreakData.ts"
    click useLatestTrackData "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/hooks/useLatestTrackData.ts"
    click usePlannedWorkoutsList "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/hooks/usePlannedWorkoutsList.ts"
    click useStreakData "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/hooks/useStreakData.ts"
    click useWeeklyWeightTrackedData "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/hooks/useWeeklyWeightTrackedData.ts"
    click useDrawer "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/hooks/useDrawer.ts"
    click useBackButton "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/hooks/useBackButton.ts"
    click useStoredReducer "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/hooks/useStoredReducer.ts"
    click ServiceWorker "https://github.com/InfantAjayVenus/GymBooku/blob/dev/src/registerServiceWorker.js"
    
    %% Styles
    classDef ui fill:#2196F3,color:white
    classDef state fill:#FFC107,color:black
    classDef model fill:#4CAF50,color:white
    classDef hook fill:#9C27B0,color:white
    classDef storage fill:#FF5722,color:white
    
    %% Legend
    subgraph Legend
        UI["UI Component"]:::ui
        State["State Management"]:::state
        Model["Data Model"]:::model
        Hook["Custom Hook"]:::hook
        Storage["Storage"]:::storage
    end
```
