# gmsads/new-gms-crm architecture

> Architecture diagram of the GitHub repository gmsads/new-gms-crm, 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/gmsads/new-gms-crm
- Repository: https://github.com/gmsads/new-gms-crm

## Overview

This is a multi-role CRM/ERP application with a React frontend and Node/Express backend. Users work across sales and lead management, order fulfillment, production, field service, workforce tracking, and administration. The graph highlights the order and lead paths, plus the documented tracking flow and major operational workspaces. The README is empty, and several backend routes and frontend API calls were not sampled; those connections are omitted where their ownership cannot be verified.

Main entry points: [`backend/src/domains/timeline/services/timelineEngine.service.js`](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/timelineEngine.service.js) (Timeline engine), [`frontend/src/App.jsx`](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/App.jsx) (Frontend routes), [`frontend/src/context/AuthContext.jsx`](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/context/AuthContext.jsx) (Session and auth), [`backend/src/domains/telecrm/controllers/lead.controller.js`](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/controllers/lead.controller.js) (TeleCRM lead API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application entry"]
  node_frontend["Frontend routes<br/>[App.jsx]"]
  node_auth["Session and auth<br/>[AuthContext.jsx]"]
end

subgraph group_sales["Sales and leads"]
  node_sales_ui["Sales workspace"]
  node_lead_ui["Lead workspace<br/>[LeadDashboard.jsx]"]
  node_prospect_model[("Prospects<br/>[prospect.model.js]")]
  node_lead_controller["TeleCRM lead API<br/>[lead.controller.js]"]
  node_lead_service["Lead service<br/>[lead.service.js]"]
  node_call_lifecycle["Call lifecycle"]
  node_lead_call_model[("Lead calls<br/>[leadCall.model.js]")]
end

subgraph group_fulfillment["Order fulfillment"]
  node_order_ui["Order workspace<br/>[OrdersPage.jsx]"]
  node_production_ui["Production dashboard"]
  node_service_routes["Service manager routes"]
  node_service_ui["Service dashboard"]
  node_design_routes["Design workflow routes<br/>[DesignRoutes.jsx]"]
  node_order_controller["Order API"]
  node_order_model[("Orders<br/>[order.model.js]")]
  node_order_workflow["Order workflow<br/>[order.workflow.js]"]
end

subgraph group_workforce["Workforce operations"]
  node_tracking_client["GPS tracking client"]
  node_work_widget["Today's work widget"]
  node_timeline_client["Workday ping API"]
  node_timeline_engine["Timeline engine"]
  node_workday_session[("Workday sessions")]
  node_timeline_event[("Timeline events")]
  node_location_segment[("Location segments")]
  node_workday_service["Workday session service"]
  node_movement_detector["Movement detection"]
  node_stop_detector["Stop detection"]
  node_location_intel["Location intelligence"]
  node_summary_service["Workday summary"]
end

node_employee(("Employee"))

node_frontend -->|"mounts"| node_auth
node_frontend -->|"routes to"| node_order_ui
node_frontend -->|"routes to"| node_sales_ui
node_frontend -->|"routes to"| node_lead_ui
node_frontend -->|"routes to"| node_production_ui
node_frontend -->|"routes to"| node_service_routes
node_frontend -->|"routes to"| node_design_routes
node_auth -->|"starts tracking"| node_tracking_client
node_employee -.->|"signs in"| node_auth
node_production_ui -->|"renders"| node_work_widget
node_service_routes -->|"routes to"| node_service_ui
node_order_controller -->|"reads and writes"| node_order_model
node_order_controller -->|"invokes"| node_order_workflow
node_order_controller -->|"reads"| node_prospect_model
node_lead_controller -->|"invokes"| node_lead_service
node_lead_controller -.->|"uses"| node_call_lifecycle
node_lead_controller -->|"creates calls"| node_lead_call_model
node_tracking_client -->|"posts pings"| node_timeline_client
node_auth -->|"posts logout"| node_timeline_client
node_timeline_engine -->|"calls"| node_workday_service
node_timeline_engine -->|"runs detection"| node_stop_detector
node_timeline_engine -->|"uses"| node_location_intel
node_timeline_engine -->|"uses"| node_movement_detector
node_timeline_engine -->|"reads and writes"| node_workday_session
node_timeline_engine -->|"creates events"| node_timeline_event
node_timeline_engine -->|"updates segments"| node_location_segment
node_timeline_engine -.->|"recalculates"| node_summary_service
node_timeline_client -.->|"feeds pings"| node_timeline_engine

click node_frontend "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/App.jsx"
click node_auth "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/context/AuthContext.jsx"
click node_tracking_client "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/services/workforceEngine.service.js"
click node_order_ui "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/orders/pages/OrdersPage.jsx"
click node_sales_ui "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/sales/pages/SalesManagerWorkspace.jsx"
click node_lead_ui "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/leads/pages/LeadDashboard.jsx"
click node_production_ui "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/production/manager/ProductionManagerDashboard.jsx"
click node_work_widget "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/components/widgets/TodayWorkWidget.jsx"
click node_service_routes "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/service/manager/ServiceManagerRoutes.jsx"
click node_service_ui "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/service/manager/ServiceManagerDashboard.jsx"
click node_design_routes "https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/design/DesignRoutes.jsx"
click node_order_controller "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/api/controllers/order.controller.js"
click node_order_model "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/orders/order.model.js"
click node_order_workflow "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/workflows/order.workflow.js"
click node_prospect_model "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/sales/prospects/prospect.model.js"
click node_lead_controller "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/controllers/lead.controller.js"
click node_lead_service "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/services/lead.service.js"
click node_call_lifecycle "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/services/callLifecycle.service.js"
click node_lead_call_model "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/models/leadCall.model.js"
click node_timeline_engine "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/timelineEngine.service.js"
click node_workday_session "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/models/workdaySession.model.js"
click node_timeline_event "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/models/timelineEvent.model.js"
click node_location_segment "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/models/locationSegment.model.js"
click node_workday_service "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/workdaySession.service.js"
click node_movement_detector "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/movementDetector.service.js"
click node_stop_detector "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/stopDetector.service.js"
click node_location_intel "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/locationIntelligence.service.js"
click node_summary_service "https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/workdaySummary.service.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_frontend,node_auth toneBlue
class node_sales_ui,node_lead_ui,node_prospect_model,node_lead_controller,node_lead_service,node_call_lifecycle,node_lead_call_model toneAmber
class node_order_ui,node_production_ui,node_service_routes,node_service_ui,node_design_routes,node_order_controller,node_order_model,node_order_workflow toneMint
class node_tracking_client,node_work_widget,node_timeline_client,node_timeline_engine,node_workday_session,node_timeline_event,node_location_segment,node_workday_service,node_movement_detector,node_stop_detector,node_location_intel,node_summary_service toneRose
class node_employee toneIndigo
```

## Components

### Application entry

- [Frontend routes](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Session and auth](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`

### Sales and leads

- [Sales workspace](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/sales/pages/SalesManagerWorkspace.jsx): `frontend/src/modules/sales/pages/SalesManagerWorkspace.jsx`
- [Lead workspace](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/leads/pages/LeadDashboard.jsx): `frontend/src/modules/leads/pages/LeadDashboard.jsx`
- [Prospects](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/sales/prospects/prospect.model.js): `backend/src/domains/sales/prospects/prospect.model.js`
- [TeleCRM lead API](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/controllers/lead.controller.js): `backend/src/domains/telecrm/controllers/lead.controller.js`
- [Lead service](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/services/lead.service.js): `backend/src/domains/telecrm/services/lead.service.js`
- [Call lifecycle](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/services/callLifecycle.service.js): `backend/src/domains/telecrm/services/callLifecycle.service.js`
- [Lead calls](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/telecrm/models/leadCall.model.js): `backend/src/domains/telecrm/models/leadCall.model.js`

### Order fulfillment

- [Order workspace](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/orders/pages/OrdersPage.jsx): `frontend/src/modules/orders/pages/OrdersPage.jsx`
- [Production dashboard](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/production/manager/ProductionManagerDashboard.jsx): `frontend/src/modules/production/manager/ProductionManagerDashboard.jsx`
- [Service manager routes](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/service/manager/ServiceManagerRoutes.jsx): `frontend/src/modules/service/manager/ServiceManagerRoutes.jsx`
- [Service dashboard](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/service/manager/ServiceManagerDashboard.jsx): `frontend/src/modules/service/manager/ServiceManagerDashboard.jsx`
- [Design workflow routes](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/modules/design/DesignRoutes.jsx): `frontend/src/modules/design/DesignRoutes.jsx`
- [Order API](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/api/controllers/order.controller.js): `backend/src/api/controllers/order.controller.js`
- [Orders](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/orders/order.model.js): `backend/src/domains/orders/order.model.js`
- [Order workflow](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/workflows/order.workflow.js): `backend/src/workflows/order.workflow.js`

### Workforce operations

- [GPS tracking client](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/services/workforceEngine.service.js): `frontend/src/services/workforceEngine.service.js`
- [Today's work widget](https://github.com/gmsads/new-gms-crm/blob/main/frontend/src/components/widgets/TodayWorkWidget.jsx): `frontend/src/components/widgets/TodayWorkWidget.jsx`
- **Workday ping API**
- [Timeline engine](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/timelineEngine.service.js): `backend/src/domains/timeline/services/timelineEngine.service.js`
- [Workday sessions](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/models/workdaySession.model.js): `backend/src/domains/timeline/models/workdaySession.model.js`
- [Timeline events](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/models/timelineEvent.model.js): `backend/src/domains/timeline/models/timelineEvent.model.js`
- [Location segments](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/models/locationSegment.model.js): `backend/src/domains/timeline/models/locationSegment.model.js`
- [Workday session service](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/workdaySession.service.js): `backend/src/domains/timeline/services/workdaySession.service.js`
- [Movement detection](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/movementDetector.service.js): `backend/src/domains/timeline/services/movementDetector.service.js`
- [Stop detection](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/stopDetector.service.js): `backend/src/domains/timeline/services/stopDetector.service.js`
- [Location intelligence](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/locationIntelligence.service.js): `backend/src/domains/timeline/services/locationIntelligence.service.js`
- [Workday summary](https://github.com/gmsads/new-gms-crm/blob/main/backend/src/domains/timeline/services/workdaySummary.service.js): `backend/src/domains/timeline/services/workdaySummary.service.js`

### Other components

- **Employee**

## Connections

- Frontend routes → Session and auth: mounts (evidence: `frontend/src/App.jsx`)
- Frontend routes → Order workspace: routes to (evidence: `frontend/src/App.jsx`)
- Frontend routes → Sales workspace: routes to (evidence: `frontend/src/App.jsx`)
- Frontend routes → Lead workspace: routes to (evidence: `frontend/src/App.jsx`)
- Frontend routes → Production dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Frontend routes → Service manager routes: routes to (evidence: `frontend/src/App.jsx`)
- Frontend routes → Design workflow routes: routes to (evidence: `frontend/src/App.jsx`)
- Session and auth → GPS tracking client: starts tracking (evidence: `frontend/src/context/AuthContext.jsx`)
- Employee → Session and auth: signs in
- Production dashboard → Today's work widget: renders (evidence: `frontend/src/modules/production/manager/ProductionManagerDashboard.jsx`)
- Service manager routes → Service dashboard: routes to (evidence: `frontend/src/modules/service/manager/ServiceManagerRoutes.jsx`)
- Order API → Orders: reads and writes (evidence: `backend/src/api/controllers/order.controller.js`)
- Order API → Order workflow: invokes (evidence: `backend/src/api/controllers/order.controller.js`)
- Order API → Prospects: reads (evidence: `backend/src/api/controllers/order.controller.js`)
- TeleCRM lead API → Lead service: invokes (evidence: `backend/src/domains/telecrm/controllers/lead.controller.js`)
- TeleCRM lead API → Call lifecycle: uses (evidence: `backend/src/domains/telecrm/controllers/lead.controller.js`)
- TeleCRM lead API → Lead calls: creates calls (evidence: `backend/src/domains/telecrm/controllers/lead.controller.js`)
- GPS tracking client → Workday ping API: posts pings (evidence: `frontend/src/services/workforceEngine.service.js`)
- Session and auth → Workday ping API: posts logout (evidence: `frontend/src/context/AuthContext.jsx`)
- Timeline engine → Workday session service: calls (evidence: `backend/src/domains/timeline/services/timelineEngine.service.js`)
- Timeline engine → Stop detection: runs detection (evidence: `backend/src/domains/timeline/services/timelineEngine.service.js`)
- Timeline engine → Location intelligence: uses (evidence: `backend/src/domains/timeline/services/timelineEngine.service.js`)
- Timeline engine → Movement detection: uses (evidence: `backend/src/domains/timeline/services/timelineEngine.service.js`)
- Timeline engine → Workday sessions: reads and writes (evidence: `backend/src/domains/timeline/services/timelineEngine.service.js`)
- Timeline engine → Timeline events: creates events (evidence: `backend/src/domains/timeline/services/timelineEngine.service.js`)
- Timeline engine → Location segments: updates segments (evidence: `backend/src/domains/timeline/services/timelineEngine.service.js`)
- Timeline engine → Workday summary: recalculates (evidence: `backend/src/domains/timeline/services/timelineEngine.service.js`)
- Workday ping API → Timeline engine: feeds pings
