# tohhongxiang/physio-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/tohhongxiang/physio-tracker
- Repository: https://github.com/tohhongxiang/physio-tracker

## Overview

##### Main Application Components (Top Level)

- Frontend (UI Layer)
- Application Logic Layer
- Data Layer

##### Frontend Layer Components
a) Tab Navigation Structure:
- Home (index)
- Workouts
- Timer
- Logbook
- Account

b) Modal Screens:
- Workout Add Modal

c) Workout Detail Screens:
- Workout View
- Workout Edit
- Workout Start
- Workout Complete

##### Application Logic Layer
Create sections for:
a) Core Logic:
- Workout Management
- Timer Controls
- Exercise Controls
- Form Management

b) Hooks Layer:
- API Hooks (use-create-workout, use-edit-workout, etc.)
- Utility Hooks (use-countdown-timer, use-sound)

##### Data Layer
Include:
- Drizzle ORM
- SQLite Database
- Schema (workouts, workout logs)

##### Integration Points
- API Routes (create-workout, edit-workout, etc.)
- Database Operations
- State Management Flow

##### Connection Types
- Double lines: API calls

##### Component Grouping
Related components in containers:
- UI Components (/components)
- Form Components (/components/workout-form)
- Provider Components (/providers)

##### A high-level overview showing the three main layers

- Workout Creation Flow
- Exercise Execution Flow
- Logging System

##### Important technical details
- React Native
- Drizzle ORM
- SQLite
- React Query (from providers)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#3498db,color:white
    classDef backend fill:#2ecc71,color:white
    classDef data fill:#9b59b6,color:white
    classDef api fill:#e74c3c,color:white
    classDef util fill:#f1c40f,color:black

    %% Main Layers
    subgraph FrontendLayer["Frontend Layer"]
        %% Tab Navigation
        TabNav["Tab Navigation"]
        Home["Home Screen"]
        Workouts["Workouts Screen"]
        Timer["Timer Screen"]
        Logbook["Logbook Screen"]
        Account["Account Screen"]

        %% Modal Screens
        WorkoutAddModal["Workout Add Modal"]

        %% Workout Detail Screens
        WorkoutView["Workout View"]
        WorkoutEdit["Workout Edit"]
        WorkoutStart["Workout Start"]
        WorkoutComplete["Workout Complete"]

        %% Core UI Components
        WorkoutCard["Workout Card"]
        WorkoutDetails["Workout Details"]
        WorkoutForm["Workout Form"]
        WorkoutLogs["Workout Logs"]
        WorkoutStartUI["Workout Start UI"]
    end

    subgraph LogicLayer["Application Logic Layer"]
        %% Core Logic
        WorkoutManagement["Workout Management"]
        TimerControls["Timer Controls"]
        ExerciseControls["Exercise Controls"]
        FormManagement["Form Schema"]

        %% API Hooks
        CreateWorkoutHook["Create Workout Hook"]
        EditWorkoutHook["Edit Workout Hook"]
        DeleteWorkoutHook["Delete Workout Hook"]
        CreateWorkoutLogHook["Create Workout Log Hook"]
    end

    subgraph DataLayer["Data Layer"]
        DrizzleORM["Drizzle ORM"]
        SQLite["SQLite Database"]
        Schema["Database Schema"]
        DBInit["Database Initialization"]
        Migrations["Migrations"]
    end

    subgraph StateManagement["State Management"]
        DBProvider["Database Provider"]
        QueryProvider["Query Client Provider"]
        ThemeProvider["Theme Provider"]
    end

    subgraph Utils["Utilities"]
        FormatDuration["Format Duration"]
        UseSound["Sound Hook"]
        Utils["Utils"]
    end

    %% Relationships
    TabNav --> Home & Workouts & Timer & Logbook & Account
    Workouts --> WorkoutView
    WorkoutView --> WorkoutEdit & WorkoutStart
    WorkoutStart --> WorkoutComplete
    WorkoutAddModal --> WorkoutForm
    WorkoutForm --> FormManagement
    WorkoutStart --> ExerciseControls
    Timer --> TimerControls
    ExerciseControls --> TimerControls
    WorkoutManagement --> CreateWorkoutHook & EditWorkoutHook & DeleteWorkoutHook
    CreateWorkoutHook & EditWorkoutHook & DeleteWorkoutHook --> DrizzleORM
    DrizzleORM --> SQLite
    Schema --> DrizzleORM
    DBInit --> DrizzleORM
    Migrations --> SQLite

    %% Click events
    click TabNav "https://github.com/tohhongxiang/physio-tracker/blob/master/app/(tabs)/_layout.tsx"
    click Home "https://github.com/tohhongxiang/physio-tracker/blob/master/app/(tabs)/index.tsx"
    click Workouts "https://github.com/tohhongxiang/physio-tracker/blob/master/app/(tabs)/workouts/index.tsx"
    click Timer "https://github.com/tohhongxiang/physio-tracker/blob/master/app/(tabs)/timer.tsx"
    click Logbook "https://github.com/tohhongxiang/physio-tracker/blob/master/app/(tabs)/logbook.tsx"
    click Account "https://github.com/tohhongxiang/physio-tracker/blob/master/app/(tabs)/account.tsx"
    click WorkoutAddModal "https://github.com/tohhongxiang/physio-tracker/blob/master/app/(modals)/workouts/add.tsx"
    click WorkoutView "https://github.com/tohhongxiang/physio-tracker/blob/master/app/workouts/[id]/index.tsx"
    click WorkoutEdit "https://github.com/tohhongxiang/physio-tracker/blob/master/app/workouts/[id]/edit.tsx"
    click WorkoutStart "https://github.com/tohhongxiang/physio-tracker/blob/master/app/workouts/[id]/start.tsx"
    click WorkoutComplete "https://github.com/tohhongxiang/physio-tracker/blob/master/app/workouts/[id]/complete.tsx"
    click WorkoutManagement "https://github.com/tohhongxiang/physio-tracker/blob/master/components/workout-form/use-workout-form.ts"
    click TimerControls "https://github.com/tohhongxiang/physio-tracker/blob/master/hooks/use-countdown-timer.ts"
    click ExerciseControls "https://github.com/tohhongxiang/physio-tracker/blob/master/components/workout-start/use-exercise-controls.ts"
    click FormManagement "https://github.com/tohhongxiang/physio-tracker/blob/master/components/workout-form/schema.ts"
    click CreateWorkoutHook "https://github.com/tohhongxiang/physio-tracker/blob/master/hooks/api/use-create-workout.ts"
    click EditWorkoutHook "https://github.com/tohhongxiang/physio-tracker/blob/master/hooks/api/use-edit-workout.ts"
    click CreateWorkoutLogHook "https://github.com/tohhongxiang/physio-tracker/blob/master/hooks/api/use-create-workout-log.ts"
    click DeleteWorkoutHook "https://github.com/tohhongxiang/physio-tracker/blob/master/hooks/api/use-delete-workout.ts"
    click Schema "https://github.com/tohhongxiang/physio-tracker/blob/master/db/schema.ts"
    click DBInit "https://github.com/tohhongxiang/physio-tracker/blob/master/db/initalize.ts"
    click Migrations "https://github.com/tohhongxiang/physio-tracker/blob/master/drizzle/migrations.js"
    click WorkoutCard "https://github.com/tohhongxiang/physio-tracker/blob/master/components/workout-card/index.tsx"
    click WorkoutDetails "https://github.com/tohhongxiang/physio-tracker/blob/master/components/workout-details/index.tsx"
    click WorkoutForm "https://github.com/tohhongxiang/physio-tracker/blob/master/components/workout-form/index.tsx"
    click WorkoutLogs "https://github.com/tohhongxiang/physio-tracker/blob/master/components/workout-logs/index.tsx"
    click WorkoutStartUI "https://github.com/tohhongxiang/physio-tracker/blob/master/components/workout-start/index.tsx"
    click DBProvider "https://github.com/tohhongxiang/physio-tracker/blob/master/providers/database-provider.tsx"
    click QueryProvider "https://github.com/tohhongxiang/physio-tracker/blob/master/providers/query-client-provider.tsx"
    click ThemeProvider "https://github.com/tohhongxiang/physio-tracker/blob/master/providers/theme-provider.tsx"
    click FormatDuration "https://github.com/tohhongxiang/physio-tracker/blob/master/lib/format-duration.ts"
    click Utils "https://github.com/tohhongxiang/physio-tracker/blob/master/lib/utils.ts"
    click UseSound "https://github.com/tohhongxiang/physio-tracker/blob/master/hooks/use-sound.ts"

    %% Style Applications
    class TabNav,Home,Workouts,Timer,Logbook,Account,WorkoutAddModal,WorkoutView,WorkoutEdit,WorkoutStart,WorkoutComplete,WorkoutCard,WorkoutDetails,WorkoutForm,WorkoutLogs,WorkoutStartUI frontend
    class WorkoutManagement,TimerControls,ExerciseControls,FormManagement,CreateWorkoutHook,EditWorkoutHook,DeleteWorkoutHook,CreateWorkoutLogHook backend
    class DrizzleORM,SQLite,Schema,DBInit,Migrations data
    class DBProvider,QueryProvider,ThemeProvider backend
    class FormatDuration,UseSound,Utils util
```
