# phan021/gym_management architecture

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

- Interactive diagram: https://gitdiagram.com/phan021/gym_management
- Repository: https://github.com/phan021/gym_management

## Overview

Gym Management is a role-based gym operations web app: admins, staff, and members use a React interface to manage or access gym services; requests pass through an Express API to SQL Server. The sampled API is a single large route module using SQL queries directly, rather than separate controller/model layers. README capabilities include membership, subscriptions, payments, check-ins, classes, staffing, facilities, dashboards, and reports. Those business areas are grouped below; unsampled subsystem links rely on README documentation, not inspected implementation.

Main entry points: [`Backend/src/routes/api.routes.js`](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js) (API routes), [`Backend/server.js`](https://github.com/phan021/gym_management/blob/main/Backend/server.js) (Express server), [`Backend/src/config/database.js`](https://github.com/phan021/gym_management/blob/main/Backend/src/config/database.js) (SQL connection), [`Frontend/src/App.jsx`](https://github.com/phan021/gym_management/blob/main/Frontend/src/App.jsx) (Role-based app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app["Role-based app<br/>[App.jsx]"]
  node_api_client["API client<br/>[client.js]"]
end

subgraph group_backend["API runtime"]
  node_server["Express server<br/>[server.js]"]
  node_api_routes["API routes<br/>[api.routes.js]"]
  node_auth["Token authorization<br/>[auth.middleware.js]"]
  node_db_config["SQL connection<br/>[database.js]"]
end

subgraph group_operations["Gym operations"]
  node_members["Members and accounts<br/>[api.routes.js]"]
  node_subscriptions["Packages and subscriptions<br/>[api.routes.js]"]
  node_payments["Payments and invoices<br/>[api.routes.js]"]
  node_checkins["Check-in and history<br/>[api.routes.js]"]
  node_classes["Classes and registration<br/>[api.routes.js]"]
  node_staffing["Staff and trainers<br/>[api.routes.js]"]
  node_facilities["Rooms and equipment<br/>[api.routes.js]"]
  node_dashboards["Dashboards and reports<br/>[api.routes.js]"]
end

node_actors(("Gym users"))
node_sqlserver[("SQL Server")]

node_actors -->|"use"| node_app
node_app -->|"requests"| node_api_client
node_api_client -->|"sends API requests"| node_server
node_server -->|"mounts"| node_api_routes
node_server -->|"waits for connection"| node_db_config
node_api_routes -->|"checks tokens"| node_auth
node_api_routes -->|"queries"| node_db_config
node_db_config -->|"connects"| node_sqlserver
node_api_routes -->|"handles"| node_members
node_api_routes -->|"handles"| node_subscriptions
node_api_routes -.->|"handles"| node_payments
node_api_routes -->|"handles"| node_checkins
node_api_routes -->|"handles"| node_classes
node_api_routes -->|"handles"| node_staffing
node_api_routes -.->|"handles"| node_facilities
node_api_routes -.->|"provides"| node_dashboards

click node_app "https://github.com/phan021/gym_management/blob/main/Frontend/src/App.jsx"
click node_api_client "https://github.com/phan021/gym_management/blob/main/Frontend/src/api/client.js"
click node_server "https://github.com/phan021/gym_management/blob/main/Backend/server.js"
click node_api_routes "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"
click node_auth "https://github.com/phan021/gym_management/blob/main/Backend/src/middleware/auth.middleware.js"
click node_db_config "https://github.com/phan021/gym_management/blob/main/Backend/src/config/database.js"
click node_members "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"
click node_subscriptions "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"
click node_payments "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"
click node_checkins "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"
click node_classes "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"
click node_staffing "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"
click node_facilities "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"
click node_dashboards "https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js"

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_app,node_api_client,node_actors toneBlue
class node_server,node_api_routes,node_auth,node_db_config,node_sqlserver toneAmber
class node_members,node_subscriptions,node_payments,node_checkins,node_classes,node_staffing,node_facilities,node_dashboards toneMint
```

## Components

### Web interface

- [Role-based app](https://github.com/phan021/gym_management/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [API client](https://github.com/phan021/gym_management/blob/main/Frontend/src/api/client.js): `Frontend/src/api/client.js`

### API runtime

- [Express server](https://github.com/phan021/gym_management/blob/main/Backend/server.js): `Backend/server.js`
- [API routes](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`
- [Token authorization](https://github.com/phan021/gym_management/blob/main/Backend/src/middleware/auth.middleware.js): `Backend/src/middleware/auth.middleware.js`
- [SQL connection](https://github.com/phan021/gym_management/blob/main/Backend/src/config/database.js): `Backend/src/config/database.js`

### Gym operations

- [Members and accounts](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`
- [Packages and subscriptions](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`
- [Payments and invoices](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`
- [Check-in and history](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`
- [Classes and registration](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`
- [Staff and trainers](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`
- [Rooms and equipment](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`
- [Dashboards and reports](https://github.com/phan021/gym_management/blob/main/Backend/src/routes/api.routes.js): `Backend/src/routes/api.routes.js`

### Other components

- **Gym users**
- **SQL Server**

## Connections

- Gym users → Role-based app: use (evidence: `README.md`)
- Role-based app → API client: requests (evidence: `Frontend/src/App.jsx`)
- API client → Express server: sends API requests (evidence: `README.md`)
- Express server → API routes: mounts (evidence: `Backend/server.js`)
- Express server → SQL connection: waits for connection (evidence: `Backend/server.js`)
- API routes → Token authorization: checks tokens (evidence: `Backend/src/routes/api.routes.js`)
- API routes → SQL connection: queries (evidence: `Backend/src/routes/api.routes.js`)
- SQL connection → SQL Server: connects (evidence: `Backend/src/config/database.js`)
- API routes → Members and accounts: handles (evidence: `Backend/src/routes/api.routes.js`)
- API routes → Packages and subscriptions: handles (evidence: `Backend/src/routes/api.routes.js`)
- API routes → Payments and invoices: handles (evidence: `README.md`)
- API routes → Check-in and history: handles (evidence: `Backend/src/routes/api.routes.js`)
- API routes → Classes and registration: handles (evidence: `Backend/src/routes/api.routes.js`)
- API routes → Staff and trainers: handles (evidence: `Backend/src/routes/api.routes.js`)
- API routes → Rooms and equipment: handles (evidence: `README.md`)
- API routes → Dashboards and reports: provides (evidence: `README.md`)
