# smk1367/grandstream-u6202-crm architecture

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

- Interactive diagram: https://gitdiagram.com/smk1367/grandstream-u6202-crm
- Repository: https://github.com/smk1367/grandstream-u6202-crm

## Overview

This is a UCM6202 CRM: users work through a browser UI to manage customer and sales records, review call activity, and use reports and recordings. The backend also synchronizes CDRs and receives live-call data from the PBX. The sampled backend excerpt supports these capabilities, but omits portions of its routing and startup code, so uncertain wiring—particularly between the TCP listener and the API—is not shown.

Main entry points: [`backend/app/main.py`](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py) (CRM API), [`frontend/index.html`](https://github.com/smk1367/grandstream-u6202-crm/blob/main/frontend/index.html) (CRM interface), [`backend/app/live_listener.py`](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/live_listener.py) (TCP live listener)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_browser["CRM interface<br/>[index.html]"]
end

subgraph group_crm["CRM workflows"]
  node_api["CRM API<br/>[main.py]"]
  node_contacts["Contacts<br/>[main.py]"]
  node_sales["Opportunities and follow-ups<br/>[main.py]"]
  node_reports["CRM reports<br/>[main.py]"]
end

subgraph group_telephony["Telephony integration"]
  node_callhistory["Call history<br/>[main.py]"]
  node_sync["CDR synchronization<br/>[main.py]"]
  node_livehttp["Realtime CDR endpoint<br/>[main.py]"]
  node_listener["TCP live listener<br/>[live_listener.py]"]
  node_recordings["Recording access<br/>[main.py]"]
end

subgraph group_data["Persistence and access"]
  node_auth["Role access<br/>[main.py]"]
  node_database[("CRM database")]
end

node_user(("CRM user"))
node_ucm["UCM6202 PBX"]

node_user -->|"uses"| node_browser
node_browser -->|"requests"| node_api
node_api -->|"checks roles"| node_auth
node_api -->|"serves"| node_contacts
node_api -->|"serves"| node_sales
node_api -->|"serves"| node_callhistory
node_api -->|"serves"| node_reports
node_api -->|"dispatches"| node_sync
node_api -->|"receives"| node_livehttp
node_ucm -->|"posts CDR"| node_livehttp
node_ucm -->|"sends events"| node_listener
node_api -->|"serves"| node_recordings
node_sync -->|"fetches CDRs"| node_ucm
node_recordings -->|"fetches audio"| node_ucm
node_contacts -->|"reads and writes"| node_database
node_sales -->|"reads and writes"| node_database
node_callhistory -->|"reads and writes"| node_database
node_reports -->|"reads"| node_database
node_sync -->|"stores CDRs"| node_database
node_livehttp -.->|"stores call data"| node_database

click node_browser "https://github.com/smk1367/grandstream-u6202-crm/blob/main/frontend/index.html"
click node_api "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"
click node_auth "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"
click node_contacts "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"
click node_sales "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"
click node_callhistory "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"
click node_reports "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"
click node_sync "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"
click node_livehttp "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"
click node_listener "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/live_listener.py"
click node_recordings "https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py"

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_browser,node_user toneBlue
class node_api,node_contacts,node_sales,node_reports toneAmber
class node_callhistory,node_sync,node_livehttp,node_listener,node_recordings toneMint
class node_auth,node_database toneRose
class node_ucm toneIndigo
```

## Components

### User interface

- [CRM interface](https://github.com/smk1367/grandstream-u6202-crm/blob/main/frontend/index.html): `frontend/index.html`

### CRM workflows

- [CRM API](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`
- [Contacts](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`
- [Opportunities and follow-ups](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`
- [CRM reports](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`

### Telephony integration

- [Call history](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`
- [CDR synchronization](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`
- [Realtime CDR endpoint](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`
- [TCP live listener](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/live_listener.py): `backend/app/live_listener.py`
- [Recording access](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`

### Persistence and access

- [Role access](https://github.com/smk1367/grandstream-u6202-crm/blob/main/backend/app/main.py): `backend/app/main.py`
- **CRM database**

### Other components

- **CRM user**
- **UCM6202 PBX**

## Connections

- CRM user → CRM interface: uses
- CRM interface → CRM API: requests
- CRM API → Role access: checks roles
- CRM API → Contacts: serves
- CRM API → Opportunities and follow-ups: serves
- CRM API → Call history: serves
- CRM API → CRM reports: serves
- CRM API → CDR synchronization: dispatches
- CRM API → Realtime CDR endpoint: receives
- UCM6202 PBX → Realtime CDR endpoint: posts CDR
- UCM6202 PBX → TCP live listener: sends events
- CRM API → Recording access: serves
- CDR synchronization → UCM6202 PBX: fetches CDRs
- Recording access → UCM6202 PBX: fetches audio
- Contacts → CRM database: reads and writes
- Opportunities and follow-ups → CRM database: reads and writes
- Call history → CRM database: reads and writes
- CRM reports → CRM database: reads
- CDR synchronization → CRM database: stores CDRs
- Realtime CDR endpoint → CRM database: stores call data
