# purvesh90/crm architecture

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

- Interactive diagram: https://gitdiagram.com/purvesh90/crm
- Repository: https://github.com/purvesh90/crm

## Overview

PulseDesk is a customer-support CRM. Customers submit or track issues through the portal or Telegram; agents triage tickets, manage conversations, and send replies, while the dashboard reports operational metrics. The Express API coordinates ticket operations, persistent JSON-backed data, Telegram messaging, and live SSE updates to the browser. The README documents additional roster, self-service, and Telegram capabilities. Some UI-to-API relationships are documented or visible in excerpts; unsampled implementation details are not inferred.

Main entry points: [`server/index.js`](https://github.com/purvesh90/crm/blob/master/server/index.js) (REST API and Controller), [`server/telegram.js`](https://github.com/purvesh90/crm/blob/master/server/telegram.js) (Telegram Service), [`public/js/app.js`](https://github.com/purvesh90/crm/blob/master/public/js/app.js) (App Coordinator), [`server/db.js`](https://github.com/purvesh90/crm/blob/master/server/db.js) (CRM Data Operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web Workspaces"]
  node_portal["Customer Portal<br/>[index.html]"]
  node_coordinator["App Coordinator<br/>[app.js]"]
  node_auth["Authentication and Roles<br/>[auth.js]"]
  node_tickets_ui["Ticket Workbench<br/>[tickets.js]"]
  node_dashboard["Operations Dashboard<br/>[app.js]"]
  node_analytics_ui["Analytics Charts<br/>[analytics.js]"]
  node_telegram_sim["Telegram Simulator<br/>[telegram.js]"]
end

subgraph group_backend["API Services"]
  node_api["REST API and Controller<br/>[index.js]"]
end

subgraph group_data["CRM Data"]
  node_store[("CRM JSON Store<br/>[crm.json]")]
  node_database["CRM Data Operations<br/>[db.js]"]
end

subgraph group_integrations["Messaging and Events"]
  node_telegram_service["Telegram Service<br/>[telegram.js]"]
  node_event_stream["SSE Broadcast Stream<br/>[index.js]"]
end

node_customer(("Customer"))
node_agent(("Support Agent"))
node_telegram_user(("Telegram Customer"))
node_telegram["Telegram Bot API"]

node_customer -->|"submits or tracks"| node_portal
node_portal -.->|"submits tickets"| node_api
node_telegram_user -->|"sends messages"| node_telegram_service
node_agent -->|"triages tickets"| node_tickets_ui
node_tickets_ui -->|"requests ticket actions"| node_api
node_coordinator -->|"coordinates views"| node_dashboard
node_coordinator -->|"initializes charts"| node_analytics_ui
node_dashboard -->|"fetches analytics"| node_api
node_telegram_sim -->|"simulates messages"| node_api
node_coordinator -->|"listens for updates"| node_event_stream
node_api -->|"calls data operations"| node_database
node_database -->|"reads and writes"| node_store
node_api -->|"dispatches notifications"| node_telegram_service
node_telegram_service -->|"uses CRM data"| node_database
node_api -->|"broadcasts events"| node_event_stream
node_telegram_service -->|"sends and receives"| node_telegram
node_api -.->|"authenticates users"| node_auth

click node_portal "https://github.com/purvesh90/crm/blob/master/public/index.html"
click node_coordinator "https://github.com/purvesh90/crm/blob/master/public/js/app.js"
click node_auth "https://github.com/purvesh90/crm/blob/master/public/js/auth.js"
click node_tickets_ui "https://github.com/purvesh90/crm/blob/master/public/js/tickets.js"
click node_dashboard "https://github.com/purvesh90/crm/blob/master/public/js/app.js"
click node_analytics_ui "https://github.com/purvesh90/crm/blob/master/public/js/analytics.js"
click node_telegram_sim "https://github.com/purvesh90/crm/blob/master/public/js/telegram.js"
click node_api "https://github.com/purvesh90/crm/blob/master/server/index.js"
click node_store "https://github.com/purvesh90/crm/blob/master/server/data/crm.json"
click node_database "https://github.com/purvesh90/crm/blob/master/server/db.js"
click node_telegram_service "https://github.com/purvesh90/crm/blob/master/server/telegram.js"
click node_event_stream "https://github.com/purvesh90/crm/blob/master/server/index.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_portal,node_coordinator,node_auth,node_tickets_ui,node_dashboard,node_analytics_ui,node_telegram_sim toneBlue
class node_api toneAmber
class node_store,node_database,node_telegram toneMint
class node_telegram_service,node_event_stream toneRose
class node_customer,node_agent,node_telegram_user toneIndigo
```

## Components

### Web Workspaces

- [Customer Portal](https://github.com/purvesh90/crm/blob/master/public/index.html): `public/index.html`
- [App Coordinator](https://github.com/purvesh90/crm/blob/master/public/js/app.js): `public/js/app.js`
- [Authentication and Roles](https://github.com/purvesh90/crm/blob/master/public/js/auth.js): `public/js/auth.js`
- [Ticket Workbench](https://github.com/purvesh90/crm/blob/master/public/js/tickets.js): `public/js/tickets.js`
- [Operations Dashboard](https://github.com/purvesh90/crm/blob/master/public/js/app.js): `public/js/app.js`
- [Analytics Charts](https://github.com/purvesh90/crm/blob/master/public/js/analytics.js): `public/js/analytics.js`
- [Telegram Simulator](https://github.com/purvesh90/crm/blob/master/public/js/telegram.js): `public/js/telegram.js`

### API Services

- [REST API and Controller](https://github.com/purvesh90/crm/blob/master/server/index.js): `server/index.js`

### CRM Data

- [CRM JSON Store](https://github.com/purvesh90/crm/blob/master/server/data/crm.json): `server/data/crm.json`
- [CRM Data Operations](https://github.com/purvesh90/crm/blob/master/server/db.js): `server/db.js`

### Messaging and Events

- [Telegram Service](https://github.com/purvesh90/crm/blob/master/server/telegram.js): `server/telegram.js`
- [SSE Broadcast Stream](https://github.com/purvesh90/crm/blob/master/server/index.js): `server/index.js`

### Other components

- **Customer**
- **Support Agent**
- **Telegram Customer**
- **Telegram Bot API**

## Connections

- Customer → Customer Portal: submits or tracks (evidence: `README.md`)
- Customer Portal → REST API and Controller: submits tickets (evidence: `README.md`)
- Telegram Customer → Telegram Service: sends messages (evidence: `README.md`)
- Support Agent → Ticket Workbench: triages tickets (evidence: `README.md`)
- Ticket Workbench → REST API and Controller: requests ticket actions (evidence: `public/js/tickets.js`)
- App Coordinator → Operations Dashboard: coordinates views (evidence: `public/js/app.js`)
- App Coordinator → Analytics Charts: initializes charts (evidence: `public/js/app.js`)
- Operations Dashboard → REST API and Controller: fetches analytics (evidence: `public/js/app.js`)
- Telegram Simulator → REST API and Controller: simulates messages (evidence: `public/js/telegram.js`)
- App Coordinator → SSE Broadcast Stream: listens for updates (evidence: `README.md`)
- REST API and Controller → CRM Data Operations: calls data operations (evidence: `server/index.js`)
- CRM Data Operations → CRM JSON Store: reads and writes (evidence: `server/db.js`)
- REST API and Controller → Telegram Service: dispatches notifications (evidence: `server/index.js`)
- Telegram Service → CRM Data Operations: uses CRM data (evidence: `server/telegram.js`)
- REST API and Controller → SSE Broadcast Stream: broadcasts events (evidence: `server/index.js`)
- Telegram Service → Telegram Bot API: sends and receives (evidence: `README.md`)
- REST API and Controller → Authentication and Roles: authenticates users
