# ananth-madura/madhura_crm architecture

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

- Interactive diagram: https://gitdiagram.com/ananth-madura/madhura_crm
- Repository: https://github.com/ananth-madura/madhura_crm

## Overview

This repository is a CRM and business-operations application with a substantial WhatsApp communications suite. Users authenticate into role-based dashboards, manage leads and operational records, and access notifications; CRM events and WhatsApp tools also drive messaging, campaigns, and conversational flows. The frontend calls a Node/Express backend, which routes requests to domain handlers and shared MySQL persistence. The README only describes Create React App setup, so product capabilities are inferred from the file tree and sampled code; unsampled routes and integrations are grouped conservatively.

Main entry points: [`backend/config/database.js`](https://github.com/ananth-madura/madhura_crm/blob/main/backend/config/database.js) (MySQL database), [`backend/server.js`](https://github.com/ananth-madura/madhura_crm/blob/main/backend/server.js) (HTTP server), [`backend/services/waAutomationService.js`](https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waAutomationService.js) (Event automation), [`frontend/src/api/client.js`](https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/api/client.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["App routing<br/>[App.js]"]
  node_authui["Login and session<br/>[AuthContext.jsx]"]
  node_notifications_ui["Notification UI"]
  node_crm_ui["CRM screens"]
  node_wa_ui["WhatsApp screens"]
  node_api["API client<br/>[client.js]"]
end

subgraph group_crm["CRM operations"]
  node_crm_routes["CRM routes"]
  node_task_routes["Tasks and targets<br/>[taskRoutes.js]"]
  node_call_routes["Call reporting"]
  node_quote_routes["Quotations<br/>[quotationRoutes.js]"]
  node_reports["Reports<br/>[reportRoutes.js]"]
end

subgraph group_messaging["WhatsApp suite"]
  node_whatsapp["WhatsApp sessions<br/>[whatsappService.js]"]
  node_wa_api["WhatsApp Cloud API"]
  node_wa_flow["Conversation flows<br/>[waFlowEngine.js]"]
  node_wa_auto["Event automation"]
  node_wa_campaign["Campaign engine"]
  node_wa_load["Account balancing<br/>[waLoadBalancer.js]"]
  node_wa_routes["WhatsApp routes"]
  node_wa_leads["WhatsApp lead capture<br/>[waLeadCapture.js]"]
end

subgraph group_platform["Backend platform"]
  node_server["HTTP server<br/>[server.js]"]
  node_auth["Auth routes<br/>[authRoutes.js]"]
  node_auth_mw["Access control<br/>[authMiddleware.js]"]
  node_db[("MySQL database<br/>[database.js]")]
  node_notify["Live notifications<br/>[notifications.js]"]
end

node_user(("CRM user"))
node_wa_external(("WhatsApp platform"))

node_user -->|"uses"| node_app
node_app -->|"provides session"| node_authui
node_app -->|"routes to"| node_crm_ui
node_app -->|"routes to"| node_wa_ui
node_authui -.->|"requests"| node_api
node_crm_ui -.->|"requests"| node_api
node_wa_ui -.->|"requests"| node_api
node_notifications_ui -.->|"requests"| node_api
node_api -.->|"HTTP requests"| node_server
node_server -->|"mounts routes"| node_auth
node_server -->|"mounts routes"| node_task_routes
node_server -.->|"mounts routes"| node_crm_routes
node_server -.->|"mounts routes"| node_wa_routes
node_auth -->|"queries"| node_db
node_task_routes -->|"queries"| node_db
node_task_routes -->|"checks access"| node_auth_mw
node_crm_routes -.->|"queries"| node_db
node_call_routes -->|"queries"| node_db
node_call_routes -.->|"checks access"| node_auth_mw
node_quote_routes -->|"queries"| node_db
node_quote_routes -->|"checks access"| node_auth_mw
node_reports -->|"queries"| node_db
node_server -->|"initializes socket"| node_notify
node_notify -->|"reads and writes"| node_db
node_server -->|"initializes"| node_db
node_wa_routes -->|"invokes flows"| node_wa_flow
node_wa_routes -->|"starts campaigns"| node_wa_campaign
node_wa_flow -->|"reads and writes"| node_db
node_wa_flow -->|"emits handoff"| node_server
node_wa_campaign -->|"tracks campaigns"| node_db
node_wa_campaign -->|"emits message updates"| node_server
node_wa_auto -->|"checks opt-outs"| node_db
node_wa_auto -->|"emits message updates"| node_server
node_wa_load -->|"reads configuration"| node_db
node_wa_load -->|"uses sessions"| node_whatsapp
node_wa_load -->|"uses API"| node_wa_api
node_whatsapp -->|"emits socket events"| node_server
node_wa_api -.->|"sends messages"| node_wa_external
node_wa_leads -->|"stores leads"| node_db
node_wa_leads -.->|"notifies users"| node_notify
node_wa_routes -.->|"checks access"| node_auth_mw
node_wa_auto -->|"sends messages"| node_whatsapp
node_wa_campaign -.->|"balances sending"| node_wa_load
node_wa_flow -.->|"captures leads"| node_wa_leads
node_call_routes -->|"triggers automation"| node_wa_auto
node_quote_routes -->|"triggers automation"| node_wa_auto

click node_app "https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/App.js"
click node_authui "https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/auth/AuthContext.jsx"
click node_notifications_ui "https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/context/NotificationContext.jsx"
click node_crm_ui "https://github.com/ananth-madura/madhura_crm/tree/main/frontend/src/pages"
click node_wa_ui "https://github.com/ananth-madura/madhura_crm/tree/main/frontend/src/pages"
click node_api "https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/api/client.js"
click node_server "https://github.com/ananth-madura/madhura_crm/blob/main/backend/server.js"
click node_auth "https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/authRoutes.js"
click node_auth_mw "https://github.com/ananth-madura/madhura_crm/blob/main/backend/middleware/authMiddleware.js"
click node_crm_routes "https://github.com/ananth-madura/madhura_crm/tree/main/backend/routes"
click node_task_routes "https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/taskRoutes.js"
click node_call_routes "https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/callReportRoutes.js"
click node_quote_routes "https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/quotationRoutes.js"
click node_reports "https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/reportRoutes.js"
click node_db "https://github.com/ananth-madura/madhura_crm/blob/main/backend/config/database.js"
click node_notify "https://github.com/ananth-madura/madhura_crm/blob/main/backend/sockets/notifications.js"
click node_whatsapp "https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/whatsappService.js"
click node_wa_api "https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/whatsappCloudApi.js"
click node_wa_flow "https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waFlowEngine.js"
click node_wa_auto "https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waAutomationService.js"
click node_wa_campaign "https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waCampaignEngine.js"
click node_wa_load "https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waLoadBalancer.js"
click node_wa_routes "https://github.com/ananth-madura/madhura_crm/tree/main/backend/routes"
click node_wa_leads "https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waLeadCapture.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_authui,node_notifications_ui,node_crm_ui,node_wa_ui,node_api,node_user toneBlue
class node_crm_routes,node_task_routes,node_call_routes,node_quote_routes,node_reports toneAmber
class node_whatsapp,node_wa_api,node_wa_flow,node_wa_auto,node_wa_campaign,node_wa_load,node_wa_routes,node_wa_leads toneMint
class node_server,node_auth,node_auth_mw,node_db,node_notify toneRose
class node_wa_external toneIndigo
```

## Components

### Web application

- [App routing](https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Login and session](https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/auth/AuthContext.jsx): `frontend/src/auth/AuthContext.jsx`
- [Notification UI](https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/context/NotificationContext.jsx): `frontend/src/context/NotificationContext.jsx`
- [CRM screens](https://github.com/ananth-madura/madhura_crm/tree/main/frontend/src/pages): `frontend/src/pages`
- [WhatsApp screens](https://github.com/ananth-madura/madhura_crm/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/ananth-madura/madhura_crm/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### CRM operations

- [CRM routes](https://github.com/ananth-madura/madhura_crm/tree/main/backend/routes): `backend/routes`
- [Tasks and targets](https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/taskRoutes.js): `backend/routes/taskRoutes.js`
- [Call reporting](https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/callReportRoutes.js): `backend/routes/callReportRoutes.js`
- [Quotations](https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/quotationRoutes.js): `backend/routes/quotationRoutes.js`
- [Reports](https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/reportRoutes.js): `backend/routes/reportRoutes.js`

### WhatsApp suite

- [WhatsApp sessions](https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/whatsappService.js): `backend/services/whatsappService.js`
- [WhatsApp Cloud API](https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/whatsappCloudApi.js): `backend/services/whatsappCloudApi.js`
- [Conversation flows](https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waFlowEngine.js): `backend/services/waFlowEngine.js`
- [Event automation](https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waAutomationService.js): `backend/services/waAutomationService.js`
- [Campaign engine](https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waCampaignEngine.js): `backend/services/waCampaignEngine.js`
- [Account balancing](https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waLoadBalancer.js): `backend/services/waLoadBalancer.js`
- [WhatsApp routes](https://github.com/ananth-madura/madhura_crm/tree/main/backend/routes): `backend/routes`
- [WhatsApp lead capture](https://github.com/ananth-madura/madhura_crm/blob/main/backend/services/waLeadCapture.js): `backend/services/waLeadCapture.js`

### Backend platform

- [HTTP server](https://github.com/ananth-madura/madhura_crm/blob/main/backend/server.js): `backend/server.js`
- [Auth routes](https://github.com/ananth-madura/madhura_crm/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Access control](https://github.com/ananth-madura/madhura_crm/blob/main/backend/middleware/authMiddleware.js): `backend/middleware/authMiddleware.js`
- [MySQL database](https://github.com/ananth-madura/madhura_crm/blob/main/backend/config/database.js): `backend/config/database.js`
- [Live notifications](https://github.com/ananth-madura/madhura_crm/blob/main/backend/sockets/notifications.js): `backend/sockets/notifications.js`

### Other components

- **CRM user**
- **WhatsApp platform**

## Connections

- CRM user → App routing: uses (evidence: `frontend/src/App.js`)
- App routing → Login and session: provides session (evidence: `frontend/src/App.js`)
- App routing → CRM screens: routes to (evidence: `frontend/src/App.js`)
- App routing → WhatsApp screens: routes to (evidence: `frontend/src/App.js`)
- Login and session → API client: requests
- CRM screens → API client: requests
- WhatsApp screens → API client: requests
- Notification UI → API client: requests
- API client → HTTP server: HTTP requests
- HTTP server → Auth routes: mounts routes (evidence: `backend/server.js`)
- HTTP server → Tasks and targets: mounts routes (evidence: `backend/server.js`)
- HTTP server → CRM routes: mounts routes (evidence: `backend/server.js`)
- HTTP server → WhatsApp routes: mounts routes (evidence: `backend/server.js`)
- Auth routes → MySQL database: queries (evidence: `backend/routes/authRoutes.js`)
- Tasks and targets → MySQL database: queries (evidence: `backend/routes/taskRoutes.js`)
- Tasks and targets → Access control: checks access (evidence: `backend/routes/taskRoutes.js`)
- CRM routes → MySQL database: queries (evidence: `backend/routes/taskRoutes.js`)
- Call reporting → MySQL database: queries (evidence: `backend/routes/callReportRoutes.js`)
- Call reporting → Access control: checks access (evidence: `backend/routes/callReportRoutes.js`)
- Quotations → MySQL database: queries (evidence: `backend/routes/quotationRoutes.js`)
- Quotations → Access control: checks access (evidence: `backend/routes/quotationRoutes.js`)
- Reports → MySQL database: queries (evidence: `backend/routes/reportRoutes.js`)
- HTTP server → Live notifications: initializes socket (evidence: `backend/server.js`)
- Live notifications → MySQL database: reads and writes (evidence: `backend/sockets/notifications.js`)
- HTTP server → MySQL database: initializes (evidence: `backend/server.js`)
- WhatsApp routes → Conversation flows: invokes flows (evidence: `backend/routes/waFlowRoutes.js`)
- WhatsApp routes → Campaign engine: starts campaigns (evidence: `backend/routes/waCampaignRoutes.js`)
- Conversation flows → MySQL database: reads and writes (evidence: `backend/services/waFlowEngine.js`)
- Conversation flows → HTTP server: emits handoff (evidence: `backend/services/waFlowEngine.js`)
- Campaign engine → MySQL database: tracks campaigns (evidence: `backend/services/waCampaignEngine.js`)
- Campaign engine → HTTP server: emits message updates (evidence: `backend/services/waCampaignEngine.js`)
- Event automation → MySQL database: checks opt-outs (evidence: `backend/services/waAutomationService.js`)
- Event automation → HTTP server: emits message updates (evidence: `backend/services/waAutomationService.js`)
- Account balancing → MySQL database: reads configuration (evidence: `backend/services/waLoadBalancer.js`)
- Account balancing → WhatsApp sessions: uses sessions (evidence: `backend/services/waLoadBalancer.js`)
- Account balancing → WhatsApp Cloud API: uses API (evidence: `backend/services/waLoadBalancer.js`)
- WhatsApp sessions → HTTP server: emits socket events (evidence: `backend/services/whatsappService.js`)
- WhatsApp Cloud API → WhatsApp platform: sends messages
- WhatsApp lead capture → MySQL database: stores leads (evidence: `backend/services/waLeadCapture.js`)
- WhatsApp lead capture → Live notifications: notifies users (evidence: `backend/services/waLeadCapture.js`)
- WhatsApp routes → Access control: checks access (evidence: `backend/routes/taskRoutes.js`)
- Event automation → WhatsApp sessions: sends messages (evidence: `backend/services/waAutomationService.js`)
- Campaign engine → Account balancing: balances sending (evidence: `backend/services/waCampaignEngine.js`)
- Conversation flows → WhatsApp lead capture: captures leads (evidence: `backend/services/waFlowEngine.js`)
- Call reporting → Event automation: triggers automation (evidence: `backend/routes/callReportRoutes.js`)
- Quotations → Event automation: triggers automation (evidence: `backend/routes/quotationRoutes.js`)
