# r251-cs/mavex architecture

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

- Interactive diagram: https://gitdiagram.com/r251-cs/mavex
- Repository: https://github.com/r251-cs/mavex

## Overview

Mavex is a factory-department management and performance-tracking application. Users sign in, enter a protected React interface, choose a reporting month, and view dashboard or operational department screens; the documented data path sends Firebase ID tokens to the Express API, where authentication and role checks precede modular service/repository handling and Firestore access. The graph preserves the documented production, quality, inventory/planning, maintenance, finance, safety, and violations capabilities. Some backend links reflect the README’s modular pattern; unsampled details are not asserted.

Main entry points: [`server/src/app.js`](https://github.com/r251-cs/mavex/blob/main/server/src/app.js) (Express API), [`client/src/App.jsx`](https://github.com/r251-cs/mavex/blob/main/client/src/App.jsx) (App routes), [`client/src/pages/Dashboard/Dashboard.jsx`](https://github.com/r251-cs/mavex/blob/main/client/src/pages/Dashboard/Dashboard.jsx) (Dashboard), [`client/src/pages`](https://github.com/r251-cs/mavex/tree/main/client/src/pages) (Department screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routes<br/>[App.jsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.jsx]"]
  node_dashboard_hook["Dashboard loader<br/>[useDashboard.js]"]
  node_month["Reporting month<br/>[MonthContext.jsx]"]
  node_department_screens["Department screens"]
  node_department_views["Department views"]
  node_toast["Notifications<br/>[Toast.jsx]"]
  node_client_api["API client<br/>[api.js]"]
end

subgraph group_access["Identity and access"]
  node_client_auth["Client authentication<br/>[AuthContext.jsx]"]
  node_firebase_auth["Firebase Authentication"]
  node_api_app["Express API<br/>[app.js]"]
  node_authenticate["Token verification<br/>[authenticate.js]"]
  node_authorize["Role authorization<br/>[authorize.js]"]
end

subgraph group_operations["Factory operations"]
  node_dashboard_backend["Dashboard module"]
  node_finance["Finance module"]
  node_production["Production module"]
  node_maintenance["Maintenance module"]
  node_inventory["Inventory module"]
  node_quality["Quality module"]
  node_safety["Safety module"]
  node_violations["Violations module"]
end

subgraph group_persistence["Data services"]
  node_firestore[("Cloud Firestore")]
end

node_user(("Factory user"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_department_screens
node_dashboard -->|"loads through"| node_dashboard_hook
node_dashboard_hook -->|"reads month"| node_month
node_dashboard -->|"renders"| node_department_views
node_department_screens -->|"renders"| node_department_views
node_department_screens -->|"uses"| node_toast
node_client_auth -->|"authenticates with"| node_firebase_auth
node_client_auth -.->|"provides token"| node_client_api
node_client_api -->|"calls API"| node_api_app
node_api_app -->|"checks identity"| node_authenticate
node_api_app -->|"mounts routes"| node_dashboard_backend
node_api_app -->|"mounts routes"| node_finance
node_api_app -->|"mounts routes"| node_production
node_api_app -->|"mounts routes"| node_maintenance
node_api_app -->|"mounts routes"| node_inventory
node_api_app -->|"mounts routes"| node_quality
node_api_app -->|"mounts routes"| node_safety
node_api_app -->|"mounts routes"| node_violations
node_dashboard_backend -.->|"reads and writes"| node_firestore
node_finance -.->|"reads and writes"| node_firestore
node_production -.->|"reads and writes"| node_firestore
node_maintenance -.->|"reads and writes"| node_firestore
node_inventory -.->|"reads and writes"| node_firestore
node_quality -.->|"reads and writes"| node_firestore
node_safety -.->|"reads and writes"| node_firestore
node_violations -.->|"reads and writes"| node_firestore

click node_app "https://github.com/r251-cs/mavex/blob/main/client/src/App.jsx"
click node_dashboard "https://github.com/r251-cs/mavex/blob/main/client/src/pages/Dashboard/Dashboard.jsx"
click node_dashboard_hook "https://github.com/r251-cs/mavex/blob/main/client/src/hooks/useDashboard.js"
click node_month "https://github.com/r251-cs/mavex/blob/main/client/src/context/MonthContext.jsx"
click node_department_screens "https://github.com/r251-cs/mavex/tree/main/client/src/pages"
click node_department_views "https://github.com/r251-cs/mavex/tree/main/client/src/components/departments"
click node_toast "https://github.com/r251-cs/mavex/blob/main/client/src/components/common/Toast.jsx"
click node_client_api "https://github.com/r251-cs/mavex/blob/main/client/src/services/api.js"
click node_client_auth "https://github.com/r251-cs/mavex/blob/main/client/src/context/AuthContext.jsx"
click node_api_app "https://github.com/r251-cs/mavex/blob/main/server/src/app.js"
click node_authenticate "https://github.com/r251-cs/mavex/blob/main/server/src/middleware/authenticate.js"
click node_authorize "https://github.com/r251-cs/mavex/blob/main/server/src/middleware/authorize.js"
click node_dashboard_backend "https://github.com/r251-cs/mavex/tree/main/server/src/modules/dashboard"
click node_finance "https://github.com/r251-cs/mavex/tree/main/server/src/modules/finance"
click node_production "https://github.com/r251-cs/mavex/tree/main/server/src/modules/production"
click node_maintenance "https://github.com/r251-cs/mavex/tree/main/server/src/modules/maintenance"
click node_inventory "https://github.com/r251-cs/mavex/tree/main/server/src/modules/inventory"
click node_quality "https://github.com/r251-cs/mavex/tree/main/server/src/modules/quality"
click node_safety "https://github.com/r251-cs/mavex/tree/main/server/src/modules/safety"
click node_violations "https://github.com/r251-cs/mavex/tree/main/server/src/modules/violations"

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_dashboard,node_dashboard_hook,node_month,node_department_screens,node_department_views,node_toast,node_client_api,node_user toneBlue
class node_client_auth,node_firebase_auth,node_api_app,node_authenticate,node_authorize toneAmber
class node_dashboard_backend,node_finance,node_production,node_maintenance,node_inventory,node_quality,node_safety,node_violations toneMint
class node_firestore toneRose
```

## Components

### Client experience

- [App routes](https://github.com/r251-cs/mavex/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Dashboard](https://github.com/r251-cs/mavex/blob/main/client/src/pages/Dashboard/Dashboard.jsx): `client/src/pages/Dashboard/Dashboard.jsx`
- [Dashboard loader](https://github.com/r251-cs/mavex/blob/main/client/src/hooks/useDashboard.js): `client/src/hooks/useDashboard.js`
- [Reporting month](https://github.com/r251-cs/mavex/blob/main/client/src/context/MonthContext.jsx): `client/src/context/MonthContext.jsx`
- [Department screens](https://github.com/r251-cs/mavex/tree/main/client/src/pages): `client/src/pages`
- [Department views](https://github.com/r251-cs/mavex/tree/main/client/src/components/departments): `client/src/components/departments`
- [Notifications](https://github.com/r251-cs/mavex/blob/main/client/src/components/common/Toast.jsx): `client/src/components/common/Toast.jsx`
- [API client](https://github.com/r251-cs/mavex/blob/main/client/src/services/api.js): `client/src/services/api.js`

### Identity and access

- [Client authentication](https://github.com/r251-cs/mavex/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- **Firebase Authentication**
- [Express API](https://github.com/r251-cs/mavex/blob/main/server/src/app.js): `server/src/app.js`
- [Token verification](https://github.com/r251-cs/mavex/blob/main/server/src/middleware/authenticate.js): `server/src/middleware/authenticate.js`
- [Role authorization](https://github.com/r251-cs/mavex/blob/main/server/src/middleware/authorize.js): `server/src/middleware/authorize.js`

### Factory operations

- [Dashboard module](https://github.com/r251-cs/mavex/tree/main/server/src/modules/dashboard): `server/src/modules/dashboard`
- [Finance module](https://github.com/r251-cs/mavex/tree/main/server/src/modules/finance): `server/src/modules/finance`
- [Production module](https://github.com/r251-cs/mavex/tree/main/server/src/modules/production): `server/src/modules/production`
- [Maintenance module](https://github.com/r251-cs/mavex/tree/main/server/src/modules/maintenance): `server/src/modules/maintenance`
- [Inventory module](https://github.com/r251-cs/mavex/tree/main/server/src/modules/inventory): `server/src/modules/inventory`
- [Quality module](https://github.com/r251-cs/mavex/tree/main/server/src/modules/quality): `server/src/modules/quality`
- [Safety module](https://github.com/r251-cs/mavex/tree/main/server/src/modules/safety): `server/src/modules/safety`
- [Violations module](https://github.com/r251-cs/mavex/tree/main/server/src/modules/violations): `server/src/modules/violations`

### Data services

- **Cloud Firestore**

### Other components

- **Factory user**

## Connections

- Factory user → App routes: uses (evidence: `client/src/App.jsx`)
- App routes → Dashboard: routes to (evidence: `client/src/App.jsx`)
- App routes → Department screens: routes to (evidence: `client/src/App.jsx`)
- Dashboard → Dashboard loader: loads through (evidence: `client/src/pages/Dashboard/Dashboard.jsx`)
- Dashboard loader → Reporting month: reads month (evidence: `client/src/hooks/useDashboard.js`)
- Dashboard → Department views: renders (evidence: `client/src/pages/Dashboard/Dashboard.jsx`)
- Department screens → Department views: renders (evidence: `client/src/pages/Production/Production.jsx`)
- Department screens → Notifications: uses (evidence: `client/src/pages/Finance/Finance.jsx`)
- Client authentication → Firebase Authentication: authenticates with (evidence: `client/src/context/AuthContext.jsx`)
- Client authentication → API client: provides token (evidence: `README.md`)
- API client → Express API: calls API (evidence: `README.md`)
- Express API → Token verification: checks identity (evidence: `README.md`)
- Express API → Dashboard module: mounts routes (evidence: `server/src/app.js`)
- Express API → Finance module: mounts routes (evidence: `server/src/app.js`)
- Express API → Production module: mounts routes (evidence: `server/src/app.js`)
- Express API → Maintenance module: mounts routes (evidence: `server/src/app.js`)
- Express API → Inventory module: mounts routes (evidence: `server/src/app.js`)
- Express API → Quality module: mounts routes (evidence: `server/src/app.js`)
- Express API → Safety module: mounts routes (evidence: `server/src/app.js`)
- Express API → Violations module: mounts routes (evidence: `server/src/app.js`)
- Dashboard module → Cloud Firestore: reads and writes (evidence: `README.md`)
- Finance module → Cloud Firestore: reads and writes (evidence: `README.md`)
- Production module → Cloud Firestore: reads and writes (evidence: `README.md`)
- Maintenance module → Cloud Firestore: reads and writes (evidence: `README.md`)
- Inventory module → Cloud Firestore: reads and writes (evidence: `README.md`)
- Quality module → Cloud Firestore: reads and writes (evidence: `README.md`)
- Safety module → Cloud Firestore: reads and writes (evidence: `README.md`)
- Violations module → Cloud Firestore: reads and writes (evidence: `README.md`)
