# maunzaidi/gym-management-fastapi architecture

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

- Interactive diagram: https://gitdiagram.com/maunzaidi/gym-management-fastapi
- Repository: https://github.com/maunzaidi/gym-management-fastapi

## Overview

This repository combines a public gym website and admin dashboard with a FastAPI gym-management API. The main operational flow is an admin signing in, managing members, trainers, plans, subscriptions, attendance, payments, classes, and bookings; the backend routes dispatch to resource controllers that use SQLAlchemy models and the async database. The README describes an API-only state, but the supplied tree and sampled frontend files show a substantial frontend. Frontend-to-API wiring is not established by the available excerpts, so those connections are omitted.

Main entry points: [`backend/main.py`](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/main.py) (FastAPI application), [`backend/routes/AdminRoute.py`](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/routes/AdminRoute.py) (Admin auth routes), [`backend/model.py`](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/model.py) (SQLAlchemy domain models), [`backend/utils/helper.py`](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/utils/helper.py) (JWT protection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_public["Public website"]
  node_authui["Sign-in screens<br/>[auth-screen.tsx]"]
  node_dashboard["Admin dashboard"]
  node_webapi["Frontend API clients"]
end

subgraph group_api["API workflows"]
  node_app["FastAPI application<br/>[main.py]"]
  node_authroutes["Admin auth routes<br/>[AdminRoute.py]"]
  node_authlogic["Admin auth logic<br/>[admin.py]"]
  node_jwt["JWT protection<br/>[helper.py]"]
end

subgraph group_domain["Gym operations"]
  node_member["Member management<br/>[member.py]"]
  node_trainer["Trainer management<br/>[trainer.py]"]
  node_plans["Plan management<br/>[membership_plan.py]"]
  node_subscriptions["Membership subscriptions<br/>[membership.py]"]
  node_attendance["Attendance tracking<br/>[attendance.py]"]
  node_classes["Gym class scheduling<br/>[gym_classes.py]"]
  node_bookings["Class bookings<br/>[class_booking.py]"]
  node_payments["Payment management<br/>[payment.py]"]
end

subgraph group_data["Persistence"]
  node_models[("SQLAlchemy domain models<br/>[model.py]")]
  node_db[("Async database<br/>[database.py]")]
end

node_visitor(("Visitor or admin"))

node_visitor -->|"browses"| node_public
node_visitor -->|"signs in"| node_authui
node_visitor -->|"manages gym"| node_dashboard
node_app -->|"registers router"| node_authroutes
node_app -->|"registers member routes"| node_member
node_app -->|"registers plan routes"| node_plans
node_app -->|"registers trainer routes"| node_trainer
node_app -->|"registers attendance routes"| node_attendance
node_app -->|"registers membership routes"| node_subscriptions
node_app -->|"registers class routes"| node_classes
node_app -->|"registers payment routes"| node_payments
node_app -->|"registers booking routes"| node_bookings
node_authroutes -->|"dispatches auth"| node_authlogic
node_authroutes -->|"checks protected routes"| node_jwt
node_authroutes -->|"gets sessions"| node_db
node_jwt -->|"queries admin"| node_db
node_jwt -->|"loads admin model"| node_models
node_subscriptions -->|"queries and saves"| node_models
node_bookings -->|"queries and saves"| node_models
node_models -->|"uses base"| node_db

click node_public "https://github.com/maunzaidi/gym-management-fastapi/tree/main/frontend/app/(public)"
click node_authui "https://github.com/maunzaidi/gym-management-fastapi/blob/main/frontend/components/modules/auth-screen.tsx"
click node_dashboard "https://github.com/maunzaidi/gym-management-fastapi/tree/main/frontend/app/(dashboard)/admin"
click node_webapi "https://github.com/maunzaidi/gym-management-fastapi/tree/main/frontend/lib/api"
click node_app "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/main.py"
click node_authroutes "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/routes/AdminRoute.py"
click node_authlogic "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/admin.py"
click node_jwt "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/utils/helper.py"
click node_member "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/member.py"
click node_trainer "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/trainer.py"
click node_plans "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/membership_plan.py"
click node_subscriptions "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/membership.py"
click node_attendance "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/attendance.py"
click node_classes "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/gym_classes.py"
click node_bookings "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/class_booking.py"
click node_payments "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/payment.py"
click node_models "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/model.py"
click node_db "https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/database.py"

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_public,node_authui,node_dashboard,node_webapi toneBlue
class node_app,node_authroutes,node_authlogic,node_jwt toneAmber
class node_member,node_trainer,node_plans,node_subscriptions,node_attendance,node_classes,node_bookings,node_payments toneMint
class node_models,node_db toneRose
class node_visitor toneIndigo
```

## Components

### Web experience

- [Public website](https://github.com/maunzaidi/gym-management-fastapi/tree/main/frontend/app/(public)): `frontend/app/(public)`
- [Sign-in screens](https://github.com/maunzaidi/gym-management-fastapi/blob/main/frontend/components/modules/auth-screen.tsx): `frontend/components/modules/auth-screen.tsx`
- [Admin dashboard](https://github.com/maunzaidi/gym-management-fastapi/tree/main/frontend/app/(dashboard)/admin): `frontend/app/(dashboard)/admin`
- [Frontend API clients](https://github.com/maunzaidi/gym-management-fastapi/tree/main/frontend/lib/api): `frontend/lib/api`

### API workflows

- [FastAPI application](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/main.py): `backend/main.py`
- [Admin auth routes](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/routes/AdminRoute.py): `backend/routes/AdminRoute.py`
- [Admin auth logic](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/admin.py): `backend/controller/admin.py`
- [JWT protection](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/utils/helper.py): `backend/utils/helper.py`

### Gym operations

- [Member management](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/member.py): `backend/controller/member.py`
- [Trainer management](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/trainer.py): `backend/controller/trainer.py`
- [Plan management](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/membership_plan.py): `backend/controller/membership_plan.py`
- [Membership subscriptions](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/membership.py): `backend/controller/membership.py`
- [Attendance tracking](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/attendance.py): `backend/controller/attendance.py`
- [Gym class scheduling](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/gym_classes.py): `backend/controller/gym_classes.py`
- [Class bookings](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/class_booking.py): `backend/controller/class_booking.py`
- [Payment management](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/controller/payment.py): `backend/controller/payment.py`

### Persistence

- [SQLAlchemy domain models](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/model.py): `backend/model.py`
- [Async database](https://github.com/maunzaidi/gym-management-fastapi/blob/main/backend/database.py): `backend/database.py`

### Other components

- **Visitor or admin**

## Connections

- Visitor or admin → Public website: browses
- Visitor or admin → Sign-in screens: signs in
- Visitor or admin → Admin dashboard: manages gym
- FastAPI application → Admin auth routes: registers router (evidence: `backend/main.py`)
- FastAPI application → Member management: registers member routes (evidence: `backend/main.py`)
- FastAPI application → Plan management: registers plan routes (evidence: `backend/main.py`)
- FastAPI application → Trainer management: registers trainer routes (evidence: `backend/main.py`)
- FastAPI application → Attendance tracking: registers attendance routes (evidence: `backend/main.py`)
- FastAPI application → Membership subscriptions: registers membership routes (evidence: `backend/main.py`)
- FastAPI application → Gym class scheduling: registers class routes (evidence: `backend/main.py`)
- FastAPI application → Payment management: registers payment routes (evidence: `backend/main.py`)
- FastAPI application → Class bookings: registers booking routes (evidence: `backend/main.py`)
- Admin auth routes → Admin auth logic: dispatches auth (evidence: `backend/routes/AdminRoute.py`)
- Admin auth routes → JWT protection: checks protected routes (evidence: `backend/routes/AdminRoute.py`)
- Admin auth routes → Async database: gets sessions (evidence: `backend/routes/AdminRoute.py`)
- JWT protection → Async database: queries admin (evidence: `backend/utils/helper.py`)
- JWT protection → SQLAlchemy domain models: loads admin model (evidence: `backend/utils/helper.py`)
- Membership subscriptions → SQLAlchemy domain models: queries and saves (evidence: `backend/controller/membership.py`)
- Class bookings → SQLAlchemy domain models: queries and saves (evidence: `backend/controller/class_booking.py`)
- SQLAlchemy domain models → Async database: uses base (evidence: `backend/model.py`)
