# mg-dev9/lead-management-m architecture

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

- Interactive diagram: https://gitdiagram.com/mg-dev9/lead-management-m
- Repository: https://github.com/mg-dev9/lead-management-m

## Overview

M is a role-based lead-management web application built with React and Firebase. Users sign in, then role-based routes lead BDMs to create and assign leads, department members to work leads and log calls, and BDMs or superadmins to review converted leads, hand them to Operations, and track quotations and outcomes. Admin capabilities include user management, announcements, lead oversight, and CSV export. The graph shows documented runtime responsibilities; unsampled modules and some Firebase interactions are represented only where README or source-index evidence supports them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/App.jsx) (Role-based routes), [`frontend/src/config/firebase.js`](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/config/firebase.js) (Firebase clients), [`frontend/src/pages/LeadTable.jsx`](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/LeadTable.jsx) (Lead workbench), [`frontend/src/pages/ConfirmedLeads.jsx`](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/ConfirmedLeads.jsx) (Confirmed leads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and navigation"]
  node_app["Role-based routes<br/>[App.jsx]"]
  node_login["Sign-in<br/>[Login.jsx]"]
  node_auth_state["Auth and roles<br/>[AuthContext.jsx]"]
  node_navigation["Navigation and notices<br/>[Sidebar.jsx]"]
  node_user_management["User management<br/>[UserManager.jsx]"]
end

subgraph group_lead_work["Lead workflow"]
  node_lead_assignment["Create and assign leads<br/>[BDMAssign.jsx]"]
  node_lead_table["Lead workbench<br/>[LeadTable.jsx]"]
  node_call_log["Call logging<br/>[CallLogModal.jsx]"]
  node_lead_details["Lead details and chat"]
  node_department_chat["Department chat"]
  node_audit_trail["Audit trail<br/>[AuditTrail.jsx]"]
  node_action_history["Action history"]
end

subgraph group_conversion["Conversion and outcomes"]
  node_confirmed_leads["Confirmed leads<br/>[ConfirmedLeads.jsx]"]
  node_quotation["Quotation tracking<br/>[QuotationModal.jsx]"]
  node_final_outcome["Final outcomes"]
  node_admin["Lead administration<br/>[AdminPanel.jsx]"]
end

subgraph group_platform["Shared services"]
  node_helpers["Lead utilities<br/>[helpers.js]"]
  node_firebase_config["Firebase clients<br/>[firebase.js]"]
  node_firebase_auth{{"Firebase Authentication"}}
  node_firestore[("Firestore")]
  node_storage[("Firebase Storage")]
end

node_user(("CRM user"))

node_user -->|"opens app"| node_app
node_app -->|"routes to"| node_login
node_app -->|"checks session"| node_auth_state
node_app -->|"routes by role"| node_lead_assignment
node_app -->|"routes by role"| node_lead_table
node_app -->|"routes by role"| node_confirmed_leads
node_app -->|"routes by role"| node_admin
node_app -->|"routes by role"| node_user_management
node_login -->|"uses clients"| node_firebase_config
node_auth_state -.->|"uses clients"| node_firebase_config
node_lead_assignment -->|"generates lead IDs"| node_helpers
node_lead_assignment -->|"writes leads and logs"| node_firestore
node_lead_table -->|"reads and updates leads"| node_firestore
node_lead_table -->|"opens call logger"| node_call_log
node_lead_table -->|"opens details"| node_lead_details
node_lead_table -->|"renders chat"| node_department_chat
node_lead_table -->|"renders history"| node_action_history
node_call_log -->|"updates calls and notifications"| node_firestore
node_lead_details -->|"updates leads and chats"| node_firestore
node_lead_details -->|"renders audit trail"| node_audit_trail
node_action_history -->|"listens to leads"| node_firestore
node_confirmed_leads -->|"reads converted leads"| node_firestore
node_confirmed_leads -->|"opens quotation tracking"| node_quotation
node_confirmed_leads -->|"opens outcome form"| node_final_outcome
node_confirmed_leads -->|"assigns Operations handoff"| node_firestore
node_quotation -->|"uses clients"| node_firebase_config
node_final_outcome -->|"uses clients"| node_firebase_config
node_admin -->|"manages leads and announcements"| node_firestore
node_admin -->|"renders history"| node_action_history
node_user_management -->|"manages user records"| node_firestore
node_user_management -->|"creates accounts"| node_firebase_auth
node_navigation -->|"reads notices"| node_firestore
node_navigation -->|"signs out"| node_firebase_auth
node_firebase_config -->|"initializes"| node_firebase_auth
node_firebase_config -->|"initializes"| node_firestore
node_firebase_config -->|"initializes"| node_storage

click node_app "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/App.jsx"
click node_login "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/Login.jsx"
click node_auth_state "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/context/AuthContext.jsx"
click node_navigation "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/Sidebar.jsx"
click node_lead_assignment "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/BDMAssign.jsx"
click node_lead_table "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/LeadTable.jsx"
click node_call_log "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/CallLogModal.jsx"
click node_lead_details "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/LeadDetailsModal.jsx"
click node_department_chat "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/DepartmentGroupChat.jsx"
click node_audit_trail "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/AuditTrail.jsx"
click node_action_history "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/ActionHistoryTrail.jsx"
click node_confirmed_leads "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/ConfirmedLeads.jsx"
click node_quotation "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/QuotationModal.jsx"
click node_final_outcome "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/FinalOutcomeModal.jsx"
click node_admin "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/AdminPanel.jsx"
click node_user_management "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/UserManager.jsx"
click node_helpers "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/utils/helpers.js"
click node_firebase_config "https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/config/firebase.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_login,node_auth_state,node_navigation,node_user_management,node_user toneBlue
class node_lead_assignment,node_lead_table,node_call_log,node_lead_details,node_department_chat,node_audit_trail,node_action_history toneAmber
class node_confirmed_leads,node_quotation,node_final_outcome,node_admin toneMint
class node_helpers,node_firebase_config,node_firebase_auth,node_firestore,node_storage toneRose
```

## Components

### Access and navigation

- [Role-based routes](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign-in](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Auth and roles](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Navigation and notices](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [User management](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/UserManager.jsx): `frontend/src/pages/UserManager.jsx`

### Lead workflow

- [Create and assign leads](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/BDMAssign.jsx): `frontend/src/pages/BDMAssign.jsx`
- [Lead workbench](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/LeadTable.jsx): `frontend/src/pages/LeadTable.jsx`
- [Call logging](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/CallLogModal.jsx): `frontend/src/components/CallLogModal.jsx`
- [Lead details and chat](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/LeadDetailsModal.jsx): `frontend/src/components/LeadDetailsModal.jsx`
- [Department chat](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/DepartmentGroupChat.jsx): `frontend/src/components/DepartmentGroupChat.jsx`
- [Audit trail](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/AuditTrail.jsx): `frontend/src/components/AuditTrail.jsx`
- [Action history](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/ActionHistoryTrail.jsx): `frontend/src/components/ActionHistoryTrail.jsx`

### Conversion and outcomes

- [Confirmed leads](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/ConfirmedLeads.jsx): `frontend/src/pages/ConfirmedLeads.jsx`
- [Quotation tracking](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/QuotationModal.jsx): `frontend/src/components/QuotationModal.jsx`
- [Final outcomes](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/components/FinalOutcomeModal.jsx): `frontend/src/components/FinalOutcomeModal.jsx`
- [Lead administration](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/pages/AdminPanel.jsx): `frontend/src/pages/AdminPanel.jsx`

### Shared services

- [Lead utilities](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/utils/helpers.js): `frontend/src/utils/helpers.js`
- [Firebase clients](https://github.com/mg-dev9/lead-management-m/blob/main/frontend/src/config/firebase.js): `frontend/src/config/firebase.js`
- **Firebase Authentication**
- **Firestore**
- **Firebase Storage**

### Other components

- **CRM user**

## Connections

- CRM user → Role-based routes: opens app (evidence: `README.md`)
- Role-based routes → Sign-in: routes to (evidence: `frontend/src/App.jsx`)
- Role-based routes → Auth and roles: checks session (evidence: `frontend/src/App.jsx`)
- Role-based routes → Create and assign leads: routes by role (evidence: `frontend/src/App.jsx`)
- Role-based routes → Lead workbench: routes by role (evidence: `frontend/src/App.jsx`)
- Role-based routes → Confirmed leads: routes by role (evidence: `frontend/src/App.jsx`)
- Role-based routes → Lead administration: routes by role (evidence: `frontend/src/App.jsx`)
- Role-based routes → User management: routes by role (evidence: `frontend/src/App.jsx`)
- Sign-in → Firebase clients: uses clients (evidence: `frontend/src/pages/Login.jsx`)
- Auth and roles → Firebase clients: uses clients
- Create and assign leads → Lead utilities: generates lead IDs (evidence: `frontend/src/pages/BDMAssign.jsx`)
- Create and assign leads → Firestore: writes leads and logs (evidence: `frontend/src/pages/BDMAssign.jsx`)
- Lead workbench → Firestore: reads and updates leads (evidence: `frontend/src/pages/LeadTable.jsx`)
- Lead workbench → Call logging: opens call logger (evidence: `frontend/src/pages/LeadTable.jsx`)
- Lead workbench → Lead details and chat: opens details (evidence: `frontend/src/pages/LeadTable.jsx`)
- Lead workbench → Department chat: renders chat (evidence: `frontend/src/pages/LeadTable.jsx`)
- Lead workbench → Action history: renders history (evidence: `frontend/src/pages/LeadTable.jsx`)
- Call logging → Firestore: updates calls and notifications (evidence: `frontend/src/components/CallLogModal.jsx`)
- Lead details and chat → Firestore: updates leads and chats (evidence: `frontend/src/components/LeadDetailsModal.jsx`)
- Lead details and chat → Audit trail: renders audit trail (evidence: `frontend/src/components/LeadDetailsModal.jsx`)
- Action history → Firestore: listens to leads (evidence: `frontend/src/components/ActionHistoryTrail.jsx`)
- Confirmed leads → Firestore: reads converted leads (evidence: `frontend/src/pages/ConfirmedLeads.jsx`)
- Confirmed leads → Quotation tracking: opens quotation tracking (evidence: `frontend/src/pages/ConfirmedLeads.jsx`)
- Confirmed leads → Final outcomes: opens outcome form (evidence: `frontend/src/pages/ConfirmedLeads.jsx`)
- Confirmed leads → Firestore: assigns Operations handoff (evidence: `frontend/src/pages/ConfirmedLeads.jsx`)
- Quotation tracking → Firebase clients: uses clients (evidence: `frontend/src/components/QuotationModal.jsx`)
- Final outcomes → Firebase clients: uses clients (evidence: `frontend/src/components/FinalOutcomeModal.jsx`)
- Lead administration → Firestore: manages leads and announcements (evidence: `frontend/src/pages/AdminPanel.jsx`)
- Lead administration → Action history: renders history (evidence: `frontend/src/pages/AdminPanel.jsx`)
- User management → Firestore: manages user records (evidence: `frontend/src/pages/UserManager.jsx`)
- User management → Firebase Authentication: creates accounts (evidence: `frontend/src/pages/UserManager.jsx`)
- Navigation and notices → Firestore: reads notices (evidence: `frontend/src/components/Sidebar.jsx`)
- Navigation and notices → Firebase Authentication: signs out (evidence: `frontend/src/components/Sidebar.jsx`)
- Firebase clients → Firebase Authentication: initializes (evidence: `frontend/src/config/firebase.js`)
- Firebase clients → Firestore: initializes (evidence: `frontend/src/config/firebase.js`)
- Firebase clients → Firebase Storage: initializes (evidence: `frontend/src/config/firebase.js`)
