# shivanetha1/gymlekha architecture

> Architecture diagram of the GitHub repository shivanetha1/gymlekha, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivanetha1/gymlekha
- Repository: https://github.com/shivanetha1/gymlekha

## Overview

Gymlekha is a multi-gym management SaaS for gym owners. Owners create an account, confirm or accept an invitation, complete gym onboarding, and then manage gym workspaces and their members, plans, payments, attendance, and analytics. The diagram preserves these documented product stages and the API/auth layer. Several page and action implementations were not sampled, so their connections are shown only where the README or excerpts support them; database and authorization details are documented at a high level.

Main entry points: [`app/api`](https://github.com/shivanetha1/gymlekha/tree/main/app/api) (Operational API), [`app/(app)/onboarding/actions.ts`](https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/onboarding/actions.ts) (Onboarding actions), [`lib/supabase/server.ts`](https://github.com/shivanetha1/gymlekha/blob/main/lib/supabase/server.ts) (Session client), [`app/auth/confirm/route.ts`](https://github.com/shivanetha1/gymlekha/blob/main/app/auth/confirm/route.ts) (Email verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and identity"]
  node_authui["Signup and login<br/>[auth-form.tsx]"]
  node_authredirect["Auth redirect"]
  node_authroutes["Email verification<br/>[route.ts]"]
  node_authcallback["Legacy callback<br/>[route.ts]"]
  node_browserauth["Browser auth flow"]
end

subgraph group_workspace["Workspace setup"]
  node_onboarding["Gym onboarding"]
  node_onboardingaction["Onboarding actions<br/>[actions.ts]"]
  node_gymdata["Gym workspace data<br/>[gym.ts]"]
end

subgraph group_operations["Gym operations"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_members["Member management"]
  node_plans["Membership plans<br/>[page.tsx]"]
  node_payments["Payment tracking"]
  node_attendance["Attendance tracking"]
  node_analytics["Analytics<br/>[page.tsx]"]
end

subgraph group_platform["API and data"]
  node_session["Session client<br/>[server.ts]"]
  node_supabaseauth["Supabase Auth"]
  node_api["Operational API"]
  node_apiauth["API authorization<br/>[auth.ts]"]
  node_database[("Supabase database")]
end

node_owner(("Gym owner"))

node_owner -->|"signs up"| node_authui
node_authui -.->|"confirms email"| node_authroutes
node_authroutes -->|"verifies token"| node_session
node_authroutes -->|"routes onward"| node_owner
node_authcallback -->|"exchanges code"| node_session
node_authredirect -->|"handles auth state"| node_browserauth
node_browserauth -->|"checks session"| node_supabaseauth
node_session -->|"creates server client"| node_supabaseauth
node_owner -->|"sets up gym"| node_onboarding
node_onboarding -.->|"submits setup"| node_onboardingaction
node_onboardingaction -.->|"creates gym and plans"| node_database
node_onboardingaction -.->|"uses gym data"| node_gymdata
node_owner -->|"enters workspace"| node_dashboard
node_dashboard -.->|"loads summary"| node_database
node_owner -->|"manages members"| node_members
node_owner -->|"manages plans"| node_plans
node_owner -->|"tracks payments"| node_payments
node_owner -->|"records attendance"| node_attendance
node_attendance -->|"marks attendance"| node_onboardingaction
node_owner -->|"reviews insights"| node_analytics
node_members -.->|"uses member routes"| node_api
node_plans -.->|"uses plan routes"| node_api
node_payments -.->|"uses payment routes"| node_api
node_attendance -.->|"uses attendance routes"| node_api
node_analytics -.->|"loads analytics"| node_api
node_api -->|"checks access"| node_apiauth
node_apiauth -->|"requires user"| node_session
node_apiauth -->|"checks gym ownership"| node_database
node_api -->|"reads and writes operations"| node_database
node_analytics -.->|"requests metrics"| node_api

click node_authui "https://github.com/shivanetha1/gymlekha/blob/main/components/auth/auth-form.tsx"
click node_authredirect "https://github.com/shivanetha1/gymlekha/blob/main/components/auth/client-auth-redirect.tsx"
click node_authroutes "https://github.com/shivanetha1/gymlekha/blob/main/app/auth/confirm/route.ts"
click node_authcallback "https://github.com/shivanetha1/gymlekha/blob/main/app/auth/callback/route.ts"
click node_session "https://github.com/shivanetha1/gymlekha/blob/main/lib/supabase/server.ts"
click node_browserauth "https://github.com/shivanetha1/gymlekha/blob/main/lib/auth/client-auth-flow.ts"
click node_onboarding "https://github.com/shivanetha1/gymlekha/blob/main/components/onboarding/gym-onboarding-form.tsx"
click node_onboardingaction "https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/onboarding/actions.ts"
click node_gymdata "https://github.com/shivanetha1/gymlekha/blob/main/lib/data/gym.ts"
click node_dashboard "https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/dashboard/page.tsx"
click node_members "https://github.com/shivanetha1/gymlekha/blob/main/components/members/member-directory.tsx"
click node_plans "https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/plans/page.tsx"
click node_payments "https://github.com/shivanetha1/gymlekha/blob/main/components/payments/payments-manager.tsx"
click node_attendance "https://github.com/shivanetha1/gymlekha/blob/main/components/attendance/attendance-manager.tsx"
click node_analytics "https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/analytics/page.tsx"
click node_api "https://github.com/shivanetha1/gymlekha/tree/main/app/api"
click node_apiauth "https://github.com/shivanetha1/gymlekha/blob/main/lib/api/auth.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_authui,node_authredirect,node_authroutes,node_authcallback,node_browserauth toneBlue
class node_onboarding,node_onboardingaction,node_gymdata toneAmber
class node_dashboard,node_members,node_plans,node_payments,node_attendance,node_analytics toneMint
class node_session,node_supabaseauth,node_api,node_apiauth,node_database toneRose
class node_owner toneIndigo
```

## Components

### Entry and identity

- [Signup and login](https://github.com/shivanetha1/gymlekha/blob/main/components/auth/auth-form.tsx): `components/auth/auth-form.tsx`
- [Auth redirect](https://github.com/shivanetha1/gymlekha/blob/main/components/auth/client-auth-redirect.tsx): `components/auth/client-auth-redirect.tsx`
- [Email verification](https://github.com/shivanetha1/gymlekha/blob/main/app/auth/confirm/route.ts): `app/auth/confirm/route.ts`
- [Legacy callback](https://github.com/shivanetha1/gymlekha/blob/main/app/auth/callback/route.ts): `app/auth/callback/route.ts`
- [Browser auth flow](https://github.com/shivanetha1/gymlekha/blob/main/lib/auth/client-auth-flow.ts): `lib/auth/client-auth-flow.ts`

### Workspace setup

- [Gym onboarding](https://github.com/shivanetha1/gymlekha/blob/main/components/onboarding/gym-onboarding-form.tsx): `components/onboarding/gym-onboarding-form.tsx`
- [Onboarding actions](https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/onboarding/actions.ts): `app/(app)/onboarding/actions.ts`
- [Gym workspace data](https://github.com/shivanetha1/gymlekha/blob/main/lib/data/gym.ts): `lib/data/gym.ts`

### Gym operations

- [Dashboard](https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/dashboard/page.tsx): `app/(app)/dashboard/page.tsx`
- [Member management](https://github.com/shivanetha1/gymlekha/blob/main/components/members/member-directory.tsx): `components/members/member-directory.tsx`
- [Membership plans](https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/plans/page.tsx): `app/(app)/plans/page.tsx`
- [Payment tracking](https://github.com/shivanetha1/gymlekha/blob/main/components/payments/payments-manager.tsx): `components/payments/payments-manager.tsx`
- [Attendance tracking](https://github.com/shivanetha1/gymlekha/blob/main/components/attendance/attendance-manager.tsx): `components/attendance/attendance-manager.tsx`
- [Analytics](https://github.com/shivanetha1/gymlekha/blob/main/app/(app)/analytics/page.tsx): `app/(app)/analytics/page.tsx`

### API and data

- [Session client](https://github.com/shivanetha1/gymlekha/blob/main/lib/supabase/server.ts): `lib/supabase/server.ts`
- **Supabase Auth**
- [Operational API](https://github.com/shivanetha1/gymlekha/tree/main/app/api): `app/api`
- [API authorization](https://github.com/shivanetha1/gymlekha/blob/main/lib/api/auth.ts): `lib/api/auth.ts`
- **Supabase database**

### Other components

- **Gym owner**

## Connections

- Gym owner → Signup and login: signs up
- Signup and login → Email verification: confirms email
- Email verification → Session client: verifies token (evidence: `app/auth/confirm/route.ts`)
- Email verification → Gym owner: routes onward (evidence: `app/auth/confirm/route.ts`)
- Legacy callback → Session client: exchanges code (evidence: `app/auth/callback/route.ts`)
- Auth redirect → Browser auth flow: handles auth state (evidence: `components/auth/client-auth-redirect.tsx`)
- Browser auth flow → Supabase Auth: checks session
- Session client → Supabase Auth: creates server client (evidence: `lib/supabase/server.ts`)
- Gym owner → Gym onboarding: sets up gym
- Gym onboarding → Onboarding actions: submits setup
- Onboarding actions → Supabase database: creates gym and plans
- Onboarding actions → Gym workspace data: uses gym data
- Gym owner → Dashboard: enters workspace
- Dashboard → Supabase database: loads summary
- Gym owner → Member management: manages members
- Gym owner → Membership plans: manages plans
- Gym owner → Payment tracking: tracks payments
- Gym owner → Attendance tracking: records attendance
- Attendance tracking → Onboarding actions: marks attendance (evidence: `components/attendance/attendance-manager.tsx`)
- Gym owner → Analytics: reviews insights
- Member management → Operational API: uses member routes
- Membership plans → Operational API: uses plan routes
- Payment tracking → Operational API: uses payment routes
- Attendance tracking → Operational API: uses attendance routes
- Analytics → Operational API: loads analytics
- Operational API → API authorization: checks access (evidence: `app/api/members/route.ts`)
- API authorization → Session client: requires user (evidence: `lib/api/auth.ts`)
- API authorization → Supabase database: checks gym ownership (evidence: `lib/api/auth.ts`)
- Operational API → Supabase database: reads and writes operations (evidence: `app/api/members/route.ts`)
- Analytics → Operational API: requests metrics
