# vanminhdang0405-web/kltn_web_gym_ai architecture

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

- Interactive diagram: https://gitdiagram.com/vanminhdang0405-web/kltn_web_gym_ai
- Repository: https://github.com/vanminhdang0405-web/kltn_web_gym_ai

## Overview

KOI Fitness is a gym membership and churn-risk management application. Prospective members submit fitness details; the backend requests an AI risk prediction and stores a customer record. Administrators can view, add, delete, and batch-import member records, while users and administrators have separate registration, login, and dashboard views. The sampled sources establish the customer API and its Flask prediction call; unsampled page behavior and prediction-route wiring are not inferred.

Main entry points: [`frontend/src/App.jsx`](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/App.jsx) (Page router), [`backend/server.js`](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/server.js) (Express server), [`backend/routes/customerRoutes.js`](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/routes/customerRoutes.js) (Customer routes), [`backend/controllers/customerController.js`](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/controllers/customerController.js) (Customer handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Page router<br/>[App.jsx]"]
  node_landing["Landing and signup<br/>[LandingPage.jsx]"]
  node_adminui["Member management"]
  node_login["Login page<br/>[Login.jsx]"]
  node_adminreg["Admin registration<br/>[Register.jsx]"]
  node_userreg["User registration<br/>[UserRegister.jsx]"]
  node_userdash["User dashboard<br/>[UserDashboard.jsx]"]
end

subgraph group_identity["Accounts and access"]
  node_authroutes["Account routes<br/>[authRoutes.js]"]
  node_authcontroller["Account handlers<br/>[authController.js]"]
  node_userstore[("User records<br/>[User.js]")]
  node_authmw["Request authentication<br/>[authMiddleware.js]"]
end

subgraph group_members["Member operations"]
  node_api["Express server<br/>[server.js]"]
  node_customerroutes["Customer routes<br/>[customerRoutes.js]"]
  node_customercontroller["Customer handlers"]
  node_customerstore[("Customer records<br/>[Customer.js]")]
end

subgraph group_prediction["Churn prediction"]
  node_mlapi["Prediction API<br/>[app.py]"]
  node_model["Churn model"]
  node_training["Model training<br/>[train_model.py]"]
  node_dataset["Training data<br/>[gym_dataset.csv]"]
end

node_visitor(("Visitor"))
node_admin(("Administrator"))
node_mongodb[("MongoDB")]

node_visitor -->|"submits details"| node_landing
node_landing -->|"posts signup"| node_api
node_admin -.->|"manages members"| node_adminui
node_adminui -->|"calls customer API"| node_api
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_adminreg
node_app -->|"routes to"| node_userreg
node_app -->|"routes to"| node_adminui
node_app -->|"routes to"| node_userdash
node_api -->|"mounts routes"| node_authroutes
node_api -->|"mounts routes"| node_customerroutes
node_authroutes -->|"dispatches requests"| node_authcontroller
node_authcontroller -->|"reads and writes"| node_userstore
node_customerroutes -->|"guards routes"| node_authmw
node_customerroutes -->|"dispatches requests"| node_customercontroller
node_customercontroller -->|"reads and writes"| node_customerstore
node_api -->|"connects to"| node_mongodb
node_customercontroller -->|"requests prediction"| node_mlapi
node_mlapi -.->|"uses model"| node_model
node_training -.->|"trains from"| node_dataset

click node_app "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/App.jsx"
click node_landing "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/LandingPage.jsx"
click node_adminui "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/CustomerManagement.jsx"
click node_login "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/Login.jsx"
click node_adminreg "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/Register.jsx"
click node_userreg "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/UserRegister.jsx"
click node_userdash "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/UserDashboard.jsx"
click node_api "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/server.js"
click node_authroutes "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/routes/authRoutes.js"
click node_authcontroller "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/controllers/authController.js"
click node_userstore "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/models/User.js"
click node_customerroutes "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/routes/customerRoutes.js"
click node_authmw "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/middlewares/authMiddleware.js"
click node_customercontroller "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/controllers/customerController.js"
click node_customerstore "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/models/Customer.js"
click node_mlapi "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/ml-api/app.py"
click node_model "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/ml-api/gym_churn_model.pkl"
click node_training "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/ml-api/train_model.py"
click node_dataset "https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/ml-api/gym_dataset.csv"

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_landing,node_adminui,node_login,node_adminreg,node_userreg,node_userdash toneBlue
class node_authroutes,node_authcontroller,node_userstore,node_authmw,node_mongodb toneAmber
class node_api,node_customerroutes,node_customercontroller,node_customerstore toneMint
class node_mlapi,node_model,node_training,node_dataset toneRose
class node_visitor,node_admin toneIndigo
```

## Components

### Web application

- [Page router](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Landing and signup](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/LandingPage.jsx): `frontend/src/pages/LandingPage.jsx`
- [Member management](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/CustomerManagement.jsx): `frontend/src/pages/CustomerManagement.jsx`
- [Login page](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Admin registration](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/Register.jsx): `frontend/src/pages/Register.jsx`
- [User registration](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/UserRegister.jsx): `frontend/src/pages/UserRegister.jsx`
- [User dashboard](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/frontend/src/pages/UserDashboard.jsx): `frontend/src/pages/UserDashboard.jsx`

### Accounts and access

- [Account routes](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Account handlers](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [User records](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/models/User.js): `backend/models/User.js`
- [Request authentication](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/middlewares/authMiddleware.js): `backend/middlewares/authMiddleware.js`

### Member operations

- [Express server](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/server.js): `backend/server.js`
- [Customer routes](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/routes/customerRoutes.js): `backend/routes/customerRoutes.js`
- [Customer handlers](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/controllers/customerController.js): `backend/controllers/customerController.js`
- [Customer records](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/backend/models/Customer.js): `backend/models/Customer.js`

### Churn prediction

- [Prediction API](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/ml-api/app.py): `ml-api/app.py`
- [Churn model](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/ml-api/gym_churn_model.pkl): `ml-api/gym_churn_model.pkl`
- [Model training](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/ml-api/train_model.py): `ml-api/train_model.py`
- [Training data](https://github.com/vanminhdang0405-web/kltn_web_gym_ai/blob/main/ml-api/gym_dataset.csv): `ml-api/gym_dataset.csv`

### Other components

- **Visitor**
- **Administrator**
- **MongoDB**

## Connections

- Visitor → Landing and signup: submits details (evidence: `frontend/src/pages/LandingPage.jsx`)
- Landing and signup → Express server: posts signup (evidence: `frontend/src/pages/LandingPage.jsx`)
- Administrator → Member management: manages members
- Member management → Express server: calls customer API (evidence: `frontend/src/pages/CustomerManagement.jsx`)
- Page router → Landing and signup: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Login page: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Admin registration: routes to (evidence: `frontend/src/App.jsx`)
- Page router → User registration: routes to (evidence: `frontend/src/App.jsx`)
- Page router → Member management: routes to (evidence: `frontend/src/App.jsx`)
- Page router → User dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Express server → Account routes: mounts routes (evidence: `backend/server.js`)
- Express server → Customer routes: mounts routes (evidence: `backend/server.js`)
- Account routes → Account handlers: dispatches requests (evidence: `backend/routes/authRoutes.js`)
- Account handlers → User records: reads and writes (evidence: `backend/controllers/authController.js`)
- Customer routes → Request authentication: guards routes (evidence: `backend/routes/customerRoutes.js`)
- Customer routes → Customer handlers: dispatches requests (evidence: `backend/routes/customerRoutes.js`)
- Customer handlers → Customer records: reads and writes (evidence: `backend/controllers/customerController.js`)
- Express server → MongoDB: connects to (evidence: `backend/server.js`)
- Customer handlers → Prediction API: requests prediction (evidence: `backend/controllers/customerController.js`)
- Prediction API → Churn model: uses model
- Model training → Training data: trains from
