# rohit79003/trishul_crm architecture

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

- Interactive diagram: https://gitdiagram.com/rohit79003/trishul_crm
- Repository: https://github.com/rohit79003/trishul_crm

## Overview

Trishul CRM is a role-based CRM with a Next.js client and an Express/MongoDB API. Users sign in, work with leads, customers, tasks and team records, and access reporting, settings and an AI co-pilot; API routes apply authentication and role checks before controller operations. The README documents these product areas, while sampled controllers show record filtering and model access. Client-to-API call sites and several unsampled controllers were not shown, so those links are omitted rather than inferred.

Main entry points: [`server/server.js`](https://github.com/rohit79003/trishul_crm/blob/main/server/server.js) (Express API), [`server/models/User.js`](https://github.com/rohit79003/trishul_crm/blob/main/server/models/User.js) (User records), [`server/controllers/employee.controller.js`](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/employee.controller.js) (Team and workload), [`server/routes/customer.routes.js`](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/customer.routes.js) (Customer routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["CRM client"]
  node_login["Sign in<br/>[page.tsx]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_leads_ui["Lead workspace<br/>[page.tsx]"]
  node_customers_ui["Customer directory<br/>[page.tsx]"]
  node_tasks_ui["Task workspace<br/>[page.tsx]"]
  node_employees_ui["Team management<br/>[page.tsx]"]
  node_reports_ui["Analytics reports<br/>[page.tsx]"]
  node_settings_ui["Workspace settings<br/>[page.tsx]"]
  node_assistant_ui["AI co-pilot<br/>[page.tsx]"]
end

subgraph group_api["API access"]
  node_api_server["Express API<br/>[server.js]"]
  node_auth_routes["Authentication routes<br/>[auth.routes.js]"]
  node_customer_routes["Customer routes<br/>[customer.routes.js]"]
  node_lead_routes["Lead routes<br/>[lead.routes.js]"]
  node_task_routes["Task routes<br/>[task.routes.js]"]
  node_employee_routes["Employee routes<br/>[employee.routes.js]"]
  node_report_routes["Report routes<br/>[report.routes.js]"]
  node_settings_routes["Settings routes<br/>[settings.routes.js]"]
  node_assistant_routes["Assistant routes"]
  node_auth_guard["JWT and role checks<br/>[auth.middleware.js]"]
end

subgraph group_domain["CRM capabilities"]
  node_auth_ctrl["Account authentication<br/>[auth.controller.js]"]
  node_customer_ctrl["Customer operations"]
  node_lead_ctrl["Lead pipeline<br/>[lead.controller.js]"]
  node_task_ctrl["Task management<br/>[task.controller.js]"]
  node_employee_ctrl["Team and workload"]
  node_report_ctrl["Analytics reporting"]
  node_settings_ctrl["Company settings"]
  node_assistant_ctrl["AI assistance"]
  node_workload["Workload rules<br/>[workload.js]"]
end

subgraph group_data["Persistence"]
  node_user_model[("User records<br/>[User.js]")]
  node_customer_model[("Customer records<br/>[Customer.js]")]
  node_lead_model[("Lead records<br/>[Lead.js]")]
  node_task_model[("Task records<br/>[Task.js]")]
end

subgraph group_intro["Product introduction"]
end

node_user(("CRM user"))
node_mongo[("MongoDB")]

node_user -->|"signs in"| node_login
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_customer_routes
node_api_server -->|"mounts"| node_lead_routes
node_api_server -->|"mounts"| node_task_routes
node_api_server -->|"mounts"| node_employee_routes
node_api_server -->|"mounts"| node_report_routes
node_api_server -->|"mounts"| node_settings_routes
node_api_server -->|"mounts"| node_assistant_routes
node_auth_routes -->|"dispatches"| node_auth_ctrl
node_customer_routes -->|"dispatches"| node_customer_ctrl
node_customer_routes -->|"authenticates"| node_auth_guard
node_lead_routes -->|"dispatches"| node_lead_ctrl
node_lead_routes -->|"authenticates"| node_auth_guard
node_task_routes -.->|"dispatches"| node_task_ctrl
node_employee_routes -->|"dispatches"| node_employee_ctrl
node_employee_routes -->|"authenticates"| node_auth_guard
node_report_routes -->|"dispatches"| node_report_ctrl
node_settings_routes -->|"dispatches"| node_settings_ctrl
node_assistant_routes -->|"dispatches"| node_assistant_ctrl
node_auth_ctrl -->|"reads/writes"| node_user_model
node_customer_ctrl -->|"reads/writes"| node_customer_model
node_customer_ctrl -->|"filters by team"| node_user_model
node_lead_ctrl -->|"reads/writes"| node_lead_model
node_lead_ctrl -->|"resolves assignees"| node_user_model
node_task_ctrl -->|"reads/writes"| node_task_model
node_task_ctrl -->|"resolves assignees"| node_user_model
node_employee_ctrl -->|"manages accounts"| node_user_model
node_employee_ctrl -->|"aggregates leads"| node_lead_model
node_employee_ctrl -->|"aggregates tasks"| node_task_model
node_employee_ctrl -->|"applies thresholds"| node_workload
node_api_server -->|"connects"| node_mongo
node_customer_model -.->|"persists in"| node_mongo
node_lead_model -.->|"persists in"| node_mongo
node_task_model -.->|"persists in"| node_mongo
node_user_model -.->|"persists in"| node_mongo

click node_login "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(auth)/login/page.tsx"
click node_dashboard "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/dashboard/page.tsx"
click node_leads_ui "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/leads/page.tsx"
click node_customers_ui "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/customers/page.tsx"
click node_tasks_ui "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/tasks/page.tsx"
click node_employees_ui "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/employees/page.tsx"
click node_reports_ui "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/reports/page.tsx"
click node_settings_ui "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/settings/page.tsx"
click node_assistant_ui "https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/ai-assistant/page.tsx"
click node_api_server "https://github.com/rohit79003/trishul_crm/blob/main/server/server.js"
click node_auth_routes "https://github.com/rohit79003/trishul_crm/blob/main/server/routes/auth.routes.js"
click node_customer_routes "https://github.com/rohit79003/trishul_crm/blob/main/server/routes/customer.routes.js"
click node_lead_routes "https://github.com/rohit79003/trishul_crm/blob/main/server/routes/lead.routes.js"
click node_task_routes "https://github.com/rohit79003/trishul_crm/blob/main/server/routes/task.routes.js"
click node_employee_routes "https://github.com/rohit79003/trishul_crm/blob/main/server/routes/employee.routes.js"
click node_report_routes "https://github.com/rohit79003/trishul_crm/blob/main/server/routes/report.routes.js"
click node_settings_routes "https://github.com/rohit79003/trishul_crm/blob/main/server/routes/settings.routes.js"
click node_assistant_routes "https://github.com/rohit79003/trishul_crm/blob/main/server/routes/assistant.routes.js"
click node_auth_guard "https://github.com/rohit79003/trishul_crm/blob/main/server/middleware/auth.middleware.js"
click node_auth_ctrl "https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/auth.controller.js"
click node_customer_ctrl "https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/customer.controller.js"
click node_lead_ctrl "https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/lead.controller.js"
click node_task_ctrl "https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/task.controller.js"
click node_employee_ctrl "https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/employee.controller.js"
click node_report_ctrl "https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/report.controller.js"
click node_settings_ctrl "https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/settings.controller.js"
click node_assistant_ctrl "https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/assistant.controller.js"
click node_workload "https://github.com/rohit79003/trishul_crm/blob/main/server/constants/workload.js"
click node_user_model "https://github.com/rohit79003/trishul_crm/blob/main/server/models/User.js"
click node_customer_model "https://github.com/rohit79003/trishul_crm/blob/main/server/models/Customer.js"
click node_lead_model "https://github.com/rohit79003/trishul_crm/blob/main/server/models/Lead.js"
click node_task_model "https://github.com/rohit79003/trishul_crm/blob/main/server/models/Task.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_login,node_dashboard,node_leads_ui,node_customers_ui,node_tasks_ui,node_employees_ui,node_reports_ui,node_settings_ui,node_assistant_ui,node_user toneBlue
class node_api_server,node_auth_routes,node_customer_routes,node_lead_routes,node_task_routes,node_employee_routes,node_report_routes,node_settings_routes,node_assistant_routes,node_auth_guard,node_mongo toneAmber
class node_auth_ctrl,node_customer_ctrl,node_lead_ctrl,node_task_ctrl,node_employee_ctrl,node_report_ctrl,node_settings_ctrl,node_assistant_ctrl,node_workload toneMint
class node_user_model,node_customer_model,node_lead_model,node_task_model toneRose
```

## Components

### CRM client

- [Sign in](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(auth)/login/page.tsx): `client/app/(auth)/login/page.tsx`
- [Dashboard](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/dashboard/page.tsx): `client/app/(dashboard)/dashboard/page.tsx`
- [Lead workspace](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/leads/page.tsx): `client/app/(dashboard)/leads/page.tsx`
- [Customer directory](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/customers/page.tsx): `client/app/(dashboard)/customers/page.tsx`
- [Task workspace](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/tasks/page.tsx): `client/app/(dashboard)/tasks/page.tsx`
- [Team management](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/employees/page.tsx): `client/app/(dashboard)/employees/page.tsx`
- [Analytics reports](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/reports/page.tsx): `client/app/(dashboard)/reports/page.tsx`
- [Workspace settings](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/settings/page.tsx): `client/app/(dashboard)/settings/page.tsx`
- [AI co-pilot](https://github.com/rohit79003/trishul_crm/blob/main/client/app/(dashboard)/ai-assistant/page.tsx): `client/app/(dashboard)/ai-assistant/page.tsx`

### API access

- [Express API](https://github.com/rohit79003/trishul_crm/blob/main/server/server.js): `server/server.js`
- [Authentication routes](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/auth.routes.js): `server/routes/auth.routes.js`
- [Customer routes](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/customer.routes.js): `server/routes/customer.routes.js`
- [Lead routes](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/lead.routes.js): `server/routes/lead.routes.js`
- [Task routes](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/task.routes.js): `server/routes/task.routes.js`
- [Employee routes](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/employee.routes.js): `server/routes/employee.routes.js`
- [Report routes](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/report.routes.js): `server/routes/report.routes.js`
- [Settings routes](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/settings.routes.js): `server/routes/settings.routes.js`
- [Assistant routes](https://github.com/rohit79003/trishul_crm/blob/main/server/routes/assistant.routes.js): `server/routes/assistant.routes.js`
- [JWT and role checks](https://github.com/rohit79003/trishul_crm/blob/main/server/middleware/auth.middleware.js): `server/middleware/auth.middleware.js`

### CRM capabilities

- [Account authentication](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/auth.controller.js): `server/controllers/auth.controller.js`
- [Customer operations](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/customer.controller.js): `server/controllers/customer.controller.js`
- [Lead pipeline](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/lead.controller.js): `server/controllers/lead.controller.js`
- [Task management](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/task.controller.js): `server/controllers/task.controller.js`
- [Team and workload](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/employee.controller.js): `server/controllers/employee.controller.js`
- [Analytics reporting](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/report.controller.js): `server/controllers/report.controller.js`
- [Company settings](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/settings.controller.js): `server/controllers/settings.controller.js`
- [AI assistance](https://github.com/rohit79003/trishul_crm/blob/main/server/controllers/assistant.controller.js): `server/controllers/assistant.controller.js`
- [Workload rules](https://github.com/rohit79003/trishul_crm/blob/main/server/constants/workload.js): `server/constants/workload.js`

### Persistence

- [User records](https://github.com/rohit79003/trishul_crm/blob/main/server/models/User.js): `server/models/User.js`
- [Customer records](https://github.com/rohit79003/trishul_crm/blob/main/server/models/Customer.js): `server/models/Customer.js`
- [Lead records](https://github.com/rohit79003/trishul_crm/blob/main/server/models/Lead.js): `server/models/Lead.js`
- [Task records](https://github.com/rohit79003/trishul_crm/blob/main/server/models/Task.js): `server/models/Task.js`

### Other components

- **CRM user**
- **MongoDB**

## Connections

- CRM user → Sign in: signs in (evidence: `README.md`)
- Express API → Authentication routes: mounts (evidence: `server/server.js`)
- Express API → Customer routes: mounts (evidence: `server/server.js`)
- Express API → Lead routes: mounts (evidence: `server/server.js`)
- Express API → Task routes: mounts (evidence: `server/server.js`)
- Express API → Employee routes: mounts (evidence: `server/server.js`)
- Express API → Report routes: mounts (evidence: `server/server.js`)
- Express API → Settings routes: mounts (evidence: `server/server.js`)
- Express API → Assistant routes: mounts (evidence: `server/server.js`)
- Authentication routes → Account authentication: dispatches (evidence: `server/routes/auth.routes.js`)
- Customer routes → Customer operations: dispatches (evidence: `server/routes/customer.routes.js`)
- Customer routes → JWT and role checks: authenticates (evidence: `server/routes/customer.routes.js`)
- Lead routes → Lead pipeline: dispatches (evidence: `server/routes/lead.routes.js`)
- Lead routes → JWT and role checks: authenticates (evidence: `server/routes/lead.routes.js`)
- Task routes → Task management: dispatches (evidence: `server/routes/task.routes.js`)
- Employee routes → Team and workload: dispatches (evidence: `server/routes/employee.routes.js`)
- Employee routes → JWT and role checks: authenticates (evidence: `server/routes/employee.routes.js`)
- Report routes → Analytics reporting: dispatches (evidence: `server/routes/report.routes.js`)
- Settings routes → Company settings: dispatches (evidence: `server/routes/settings.routes.js`)
- Assistant routes → AI assistance: dispatches (evidence: `server/routes/assistant.routes.js`)
- Account authentication → User records: reads/writes (evidence: `server/controllers/auth.controller.js`)
- Customer operations → Customer records: reads/writes (evidence: `server/controllers/customer.controller.js`)
- Customer operations → User records: filters by team (evidence: `server/controllers/customer.controller.js`)
- Lead pipeline → Lead records: reads/writes (evidence: `server/controllers/lead.controller.js`)
- Lead pipeline → User records: resolves assignees (evidence: `server/controllers/lead.controller.js`)
- Task management → Task records: reads/writes (evidence: `server/controllers/task.controller.js`)
- Task management → User records: resolves assignees (evidence: `server/controllers/task.controller.js`)
- Team and workload → User records: manages accounts (evidence: `server/controllers/employee.controller.js`)
- Team and workload → Lead records: aggregates leads (evidence: `server/controllers/employee.controller.js`)
- Team and workload → Task records: aggregates tasks (evidence: `server/controllers/employee.controller.js`)
- Team and workload → Workload rules: applies thresholds (evidence: `server/controllers/employee.controller.js`)
- Express API → MongoDB: connects (evidence: `server/server.js`)
- Customer records → MongoDB: persists in
- Lead records → MongoDB: persists in
- Task records → MongoDB: persists in
- User records → MongoDB: persists in
