# duck3mk/workout-mern architecture

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

- Interactive diagram: https://gitdiagram.com/duck3mk/workout-mern
- Repository: https://github.com/duck3mk/workout-mern

## Overview

Workout-MERN is a workout-tracking application with account signup/login and authenticated workout management. The frontend restores and shares auth state, routes signed-in users to the workout home, and provides workout UI; the backend exposes user and workout routes, applies JWT auth to workout routes, and persists users and workouts. The README gives no product details, and the excerpts do not show frontend-to-backend requests, so that connection is intentionally omitted.

Main entry points: [`frontend/src/hooks/useAuthContext.jsx`](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useAuthContext.jsx) (Auth Hook), [`frontend/src/App.jsx`](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/App.jsx) (App Routing), [`frontend/src/pages/Home.jsx`](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/pages/Home.jsx) (Workout Home), [`frontend/src/hooks/useContext.jsx`](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useContext.jsx) (Workout Hook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_app["App Routing<br/>[App.jsx]"]
  node_navbar["Navigation<br/>[Navbar.jsx]"]
  node_home["Workout Home<br/>[Home.jsx]"]
  node_signup_page["Signup Page<br/>[SignUp.jsx]"]
  node_login_page["Login Page<br/>[login.jsx]"]
  node_workout_form["Workout Form"]
  node_workout_details["Workout Details<br/>[workoutDetails.jsx]"]
end

subgraph group_identity["Identity"]
  node_auth_state["Auth State<br/>[AuthContext.jsx]"]
  node_auth_hook["Auth Hook<br/>[useAuthContext.jsx]"]
  node_login_action["Login Action<br/>[useLogin.jsx]"]
  node_signup_action["Signup Action<br/>[useSignup.jsx]"]
  node_logout_action["Logout Action<br/>[useLogout.jsx]"]
end

subgraph group_workouts["Workout Management"]
  node_workout_state["Workout State<br/>[workoutContext.jsx]"]
  node_workout_hook["Workout Hook<br/>[useContext.jsx]"]
end

subgraph group_backend["Backend Runtime"]
  node_server["API Server<br/>[server.js]"]
  node_user_routes["User Routes<br/>[userRoutes.js]"]
  node_workout_routes["Workout Routes<br/>[workoutRoutes.js]"]
  node_user_controller["Account Controller<br/>[userController.js]"]
  node_workout_controller["Workout Controller"]
  node_auth_middleware["JWT Middleware<br/>[requiredAuth.js]"]
  node_user_model[("User Model<br/>[userSchema.js]")]
  node_workout_model[("Workout Model<br/>[workoutSchema.js]")]
end

node_user(("User"))

node_user -->|"uses app"| node_app
node_app -->|"renders"| node_navbar
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_signup_page
node_app -->|"routes to"| node_login_page
node_app -->|"reads auth"| node_auth_hook
node_navbar -->|"uses"| node_logout_action
node_navbar -->|"reads auth"| node_auth_hook
node_home -->|"renders"| node_workout_form
node_home -->|"renders"| node_workout_details
node_home -->|"reads workouts"| node_workout_hook
node_home -->|"reads auth"| node_auth_hook
node_signup_page -->|"uses"| node_signup_action
node_login_page -->|"uses"| node_login_action
node_workout_form -->|"uses"| node_workout_hook
node_workout_form -->|"uses"| node_auth_hook
node_workout_details -->|"uses"| node_workout_hook
node_workout_details -->|"uses"| node_auth_hook
node_auth_hook -->|"reads context"| node_auth_state
node_login_action -->|"uses"| node_auth_hook
node_signup_action -->|"uses"| node_auth_hook
node_logout_action -->|"uses"| node_auth_hook
node_logout_action -->|"uses"| node_workout_hook
node_workout_hook -->|"reads context"| node_workout_state
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_workout_routes
node_user_routes -->|"routes to"| node_user_controller
node_workout_routes -->|"routes to"| node_workout_controller
node_workout_routes -->|"requires auth"| node_auth_middleware
node_user_controller -->|"calls"| node_user_model
node_workout_controller -->|"queries"| node_workout_model
node_auth_middleware -->|"looks up user"| node_user_model

click node_app "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/App.jsx"
click node_navbar "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/components/Navbar.jsx"
click node_home "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/pages/Home.jsx"
click node_signup_page "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/pages/SignUp.jsx"
click node_login_page "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/pages/login.jsx"
click node_workout_form "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/components/createWorkoutForm.jsx"
click node_workout_details "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/components/workoutDetails.jsx"
click node_auth_state "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/context/AuthContext.jsx"
click node_auth_hook "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useAuthContext.jsx"
click node_login_action "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useLogin.jsx"
click node_signup_action "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useSignup.jsx"
click node_logout_action "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useLogout.jsx"
click node_workout_state "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/context/workoutContext.jsx"
click node_workout_hook "https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useContext.jsx"
click node_server "https://github.com/duck3mk/workout-mern/blob/main/backend/server.js"
click node_user_routes "https://github.com/duck3mk/workout-mern/blob/main/backend/routes/userRoutes.js"
click node_workout_routes "https://github.com/duck3mk/workout-mern/blob/main/backend/routes/workoutRoutes.js"
click node_user_controller "https://github.com/duck3mk/workout-mern/blob/main/backend/controllers/userController.js"
click node_workout_controller "https://github.com/duck3mk/workout-mern/blob/main/backend/controllers/workoutController.js"
click node_auth_middleware "https://github.com/duck3mk/workout-mern/blob/main/backend/middlewere/requiredAuth.js"
click node_user_model "https://github.com/duck3mk/workout-mern/blob/main/backend/models/userSchema.js"
click node_workout_model "https://github.com/duck3mk/workout-mern/blob/main/backend/models/workoutSchema.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_navbar,node_home,node_signup_page,node_login_page,node_workout_form,node_workout_details,node_user toneBlue
class node_auth_state,node_auth_hook,node_login_action,node_signup_action,node_logout_action toneAmber
class node_workout_state,node_workout_hook toneMint
class node_server,node_user_routes,node_workout_routes,node_user_controller,node_workout_controller,node_auth_middleware,node_user_model,node_workout_model toneRose
```

## Components

### Frontend

- [App Routing](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Navigation](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Workout Home](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Signup Page](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/pages/SignUp.jsx): `frontend/src/pages/SignUp.jsx`
- [Login Page](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/pages/login.jsx): `frontend/src/pages/login.jsx`
- [Workout Form](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/components/createWorkoutForm.jsx): `frontend/src/components/createWorkoutForm.jsx`
- [Workout Details](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/components/workoutDetails.jsx): `frontend/src/components/workoutDetails.jsx`

### Identity

- [Auth State](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Auth Hook](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useAuthContext.jsx): `frontend/src/hooks/useAuthContext.jsx`
- [Login Action](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useLogin.jsx): `frontend/src/hooks/useLogin.jsx`
- [Signup Action](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useSignup.jsx): `frontend/src/hooks/useSignup.jsx`
- [Logout Action](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useLogout.jsx): `frontend/src/hooks/useLogout.jsx`

### Workout Management

- [Workout State](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/context/workoutContext.jsx): `frontend/src/context/workoutContext.jsx`
- [Workout Hook](https://github.com/duck3mk/workout-mern/blob/main/frontend/src/hooks/useContext.jsx): `frontend/src/hooks/useContext.jsx`

### Backend Runtime

- [API Server](https://github.com/duck3mk/workout-mern/blob/main/backend/server.js): `backend/server.js`
- [User Routes](https://github.com/duck3mk/workout-mern/blob/main/backend/routes/userRoutes.js): `backend/routes/userRoutes.js`
- [Workout Routes](https://github.com/duck3mk/workout-mern/blob/main/backend/routes/workoutRoutes.js): `backend/routes/workoutRoutes.js`
- [Account Controller](https://github.com/duck3mk/workout-mern/blob/main/backend/controllers/userController.js): `backend/controllers/userController.js`
- [Workout Controller](https://github.com/duck3mk/workout-mern/blob/main/backend/controllers/workoutController.js): `backend/controllers/workoutController.js`
- [JWT Middleware](https://github.com/duck3mk/workout-mern/blob/main/backend/middlewere/requiredAuth.js): `backend/middlewere/requiredAuth.js`
- [User Model](https://github.com/duck3mk/workout-mern/blob/main/backend/models/userSchema.js): `backend/models/userSchema.js`
- [Workout Model](https://github.com/duck3mk/workout-mern/blob/main/backend/models/workoutSchema.js): `backend/models/workoutSchema.js`

### Other components

- **User**

## Connections

- User → App Routing: uses app
- App Routing → Navigation: renders (evidence: `frontend/src/App.jsx`)
- App Routing → Workout Home: routes to (evidence: `frontend/src/App.jsx`)
- App Routing → Signup Page: routes to (evidence: `frontend/src/App.jsx`)
- App Routing → Login Page: routes to (evidence: `frontend/src/App.jsx`)
- App Routing → Auth Hook: reads auth (evidence: `frontend/src/App.jsx`)
- Navigation → Logout Action: uses (evidence: `frontend/src/components/Navbar.jsx`)
- Navigation → Auth Hook: reads auth (evidence: `frontend/src/components/Navbar.jsx`)
- Workout Home → Workout Form: renders (evidence: `frontend/src/pages/Home.jsx`)
- Workout Home → Workout Details: renders (evidence: `frontend/src/pages/Home.jsx`)
- Workout Home → Workout Hook: reads workouts (evidence: `frontend/src/pages/Home.jsx`)
- Workout Home → Auth Hook: reads auth (evidence: `frontend/src/pages/Home.jsx`)
- Signup Page → Signup Action: uses (evidence: `frontend/src/pages/SignUp.jsx`)
- Login Page → Login Action: uses (evidence: `frontend/src/pages/login.jsx`)
- Workout Form → Workout Hook: uses (evidence: `frontend/src/components/createWorkoutForm.jsx`)
- Workout Form → Auth Hook: uses (evidence: `frontend/src/components/createWorkoutForm.jsx`)
- Workout Details → Workout Hook: uses (evidence: `frontend/src/components/workoutDetails.jsx`)
- Workout Details → Auth Hook: uses (evidence: `frontend/src/components/workoutDetails.jsx`)
- Auth Hook → Auth State: reads context (evidence: `frontend/src/hooks/useAuthContext.jsx`)
- Login Action → Auth Hook: uses (evidence: `frontend/src/hooks/useLogin.jsx`)
- Signup Action → Auth Hook: uses (evidence: `frontend/src/hooks/useSignup.jsx`)
- Logout Action → Auth Hook: uses (evidence: `frontend/src/hooks/useLogout.jsx`)
- Logout Action → Workout Hook: uses (evidence: `frontend/src/hooks/useLogout.jsx`)
- Workout Hook → Workout State: reads context (evidence: `frontend/src/hooks/useContext.jsx`)
- API Server → User Routes: mounts (evidence: `backend/server.js`)
- API Server → Workout Routes: mounts (evidence: `backend/server.js`)
- User Routes → Account Controller: routes to (evidence: `backend/routes/userRoutes.js`)
- Workout Routes → Workout Controller: routes to (evidence: `backend/routes/workoutRoutes.js`)
- Workout Routes → JWT Middleware: requires auth (evidence: `backend/routes/workoutRoutes.js`)
- Account Controller → User Model: calls (evidence: `backend/controllers/userController.js`)
- Workout Controller → Workout Model: queries (evidence: `backend/controllers/workoutController.js`)
- JWT Middleware → User Model: looks up user (evidence: `backend/middlewere/requiredAuth.js`)
