# shubhamjain000/crm architecture

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

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

## Overview

Unstop CRM is a sales, cadence, and customer-success platform. The documented workflow moves leads through deal pipelines, schedules cadence follow-ups as tasks, and exposes activity and completion metrics in BI; Zia can also act on CRM work. The repository contains both a Next.js/Prisma application and a substantial Django backend. The README documents product capabilities, while source-index references and excerpts establish only selected internal calls; unsampled subsystem links are omitted.

Main entry points: [`src/lib/crm/detail-routes.ts`](https://github.com/shubhamjain000/crm/blob/main/src/lib/crm/detail-routes.ts) (CRM API routes), [`backend/tasks/models.py`](https://github.com/shubhamjain000/crm/blob/main/backend/tasks/models.py) (CSM cadence), [`src/lib/db.ts`](https://github.com/shubhamjain000/crm/blob/main/src/lib/db.ts) (Prisma database), [`backend/deals/models.py`](https://github.com/shubhamjain000/crm/blob/main/backend/deals/models.py) (Deals and pipelines)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity and tenancy"]
  node_session["Session management<br/>[session.ts]"]
  node_tenant["Tenant resolution<br/>[tenant.ts]"]
  node_audit["Audit logging<br/>[audit.ts]"]
end

subgraph group_crm["CRM and pipelines"]
  node_web_crm["CRM API routes<br/>[detail-routes.ts]"]
  node_crm_handler["Tenant CRM handler<br/>[handler.ts]"]
  node_crm_entities[("Accounts, contacts, leads<br/>[models.py]")]
  node_deals[("Deals and pipelines<br/>[models.py]")]
  node_pipeline_stages[("Pipeline stages<br/>[models_pipeline.py]")]
  node_custom_fields["Custom fields<br/>[custom-fields.ts]"]
end

subgraph group_cadence["Cadence and productivity"]
  node_cadence[("CSM cadence<br/>[models.py]")]
end

subgraph group_insights["AI and analytics"]
  node_analytics["Cadence and sales BI<br/>[services.py]"]
  node_zia["Zia assistant<br/>[services.py]"]
end

subgraph group_platform["Platform services"]
  node_prisma_db[("Prisma database<br/>[db.ts]")]
  node_backend_tenant["Tenant-scoped data<br/>[managers.py]"]
  node_approvals[("Approvals<br/>[models.py]")]
  node_blueprints["Blueprint execution<br/>[services.py]"]
  node_validation["Validation rules<br/>[services.py]"]
  node_crm_ux["CRM activity services<br/>[services.py]"]
  node_notifications["Notifications<br/>[services.py]"]
end

node_sales_user(("Sales user"))

node_sales_user -->|"manages records"| node_web_crm
node_web_crm -->|"authenticates with"| node_session
node_web_crm -->|"resolves tenant"| node_tenant
node_web_crm -->|"delegates updates"| node_crm_handler
node_web_crm -->|"reads and writes"| node_custom_fields
node_web_crm -->|"queries records"| node_prisma_db
node_session -->|"reads sessions"| node_prisma_db
node_tenant -->|"reads membership"| node_prisma_db
node_audit -->|"writes audit"| node_prisma_db
node_sales_user -->|"tracks prospects"| node_crm_entities
node_sales_user -->|"manages opportunities"| node_deals
node_deals -->|"uses stages"| node_pipeline_stages
node_sales_user -->|"records next steps"| node_cadence
node_cadence -->|"reports cadence metrics"| node_analytics
node_sales_user -->|"requests CRM actions"| node_zia
node_zia -->|"sets next steps"| node_cadence
node_cadence -->|"creates follow-up tasks"| node_notifications
node_backend_tenant -->|"scopes queries"| node_backend_tenant
node_crm_ux -->|"fans out alerts"| node_notifications
node_approvals -->|"logs approval activity"| node_crm_ux
node_deals -->|"starts execution"| node_blueprints
node_crm_entities -->|"validates records"| node_validation

click node_web_crm "https://github.com/shubhamjain000/crm/blob/main/src/lib/crm/detail-routes.ts"
click node_crm_handler "https://github.com/shubhamjain000/crm/blob/main/src/lib/crm/handler.ts"
click node_crm_entities "https://github.com/shubhamjain000/crm/blob/main/backend/accounts/models.py"
click node_deals "https://github.com/shubhamjain000/crm/blob/main/backend/deals/models.py"
click node_pipeline_stages "https://github.com/shubhamjain000/crm/blob/main/backend/deals/models_pipeline.py"
click node_custom_fields "https://github.com/shubhamjain000/crm/blob/main/src/lib/crm/custom-fields.ts"
click node_session "https://github.com/shubhamjain000/crm/blob/main/src/lib/auth/session.ts"
click node_tenant "https://github.com/shubhamjain000/crm/blob/main/src/lib/auth/tenant.ts"
click node_audit "https://github.com/shubhamjain000/crm/blob/main/src/lib/auth/audit.ts"
click node_prisma_db "https://github.com/shubhamjain000/crm/blob/main/src/lib/db.ts"
click node_backend_tenant "https://github.com/shubhamjain000/crm/blob/main/backend/api/managers.py"
click node_approvals "https://github.com/shubhamjain000/crm/blob/main/backend/approvals/models.py"
click node_blueprints "https://github.com/shubhamjain000/crm/blob/main/backend/blueprint/services.py"
click node_validation "https://github.com/shubhamjain000/crm/blob/main/backend/validation_rules/services.py"
click node_crm_ux "https://github.com/shubhamjain000/crm/blob/main/backend/crm_ux/services.py"
click node_cadence "https://github.com/shubhamjain000/crm/blob/main/backend/tasks/models.py"
click node_analytics "https://github.com/shubhamjain000/crm/blob/main/backend/analytics/services.py"
click node_zia "https://github.com/shubhamjain000/crm/blob/main/backend/zia_chatbot/services.py"
click node_notifications "https://github.com/shubhamjain000/crm/blob/main/backend/notifications/services.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_session,node_tenant,node_audit,node_sales_user toneBlue
class node_web_crm,node_crm_handler,node_crm_entities,node_deals,node_pipeline_stages,node_custom_fields toneAmber
class node_cadence toneMint
class node_analytics,node_zia toneRose
class node_prisma_db,node_backend_tenant,node_approvals,node_blueprints,node_validation,node_crm_ux,node_notifications toneIndigo
```

## Components

### Identity and tenancy

- [Session management](https://github.com/shubhamjain000/crm/blob/main/src/lib/auth/session.ts): `src/lib/auth/session.ts`
- [Tenant resolution](https://github.com/shubhamjain000/crm/blob/main/src/lib/auth/tenant.ts): `src/lib/auth/tenant.ts`
- [Audit logging](https://github.com/shubhamjain000/crm/blob/main/src/lib/auth/audit.ts): `src/lib/auth/audit.ts`

### CRM and pipelines

- [CRM API routes](https://github.com/shubhamjain000/crm/blob/main/src/lib/crm/detail-routes.ts): `src/lib/crm/detail-routes.ts`
- [Tenant CRM handler](https://github.com/shubhamjain000/crm/blob/main/src/lib/crm/handler.ts): `src/lib/crm/handler.ts`
- [Accounts, contacts, leads](https://github.com/shubhamjain000/crm/blob/main/backend/accounts/models.py): `backend/accounts/models.py`
- [Deals and pipelines](https://github.com/shubhamjain000/crm/blob/main/backend/deals/models.py): `backend/deals/models.py`
- [Pipeline stages](https://github.com/shubhamjain000/crm/blob/main/backend/deals/models_pipeline.py): `backend/deals/models_pipeline.py`
- [Custom fields](https://github.com/shubhamjain000/crm/blob/main/src/lib/crm/custom-fields.ts): `src/lib/crm/custom-fields.ts`

### Cadence and productivity

- [CSM cadence](https://github.com/shubhamjain000/crm/blob/main/backend/tasks/models.py): `backend/tasks/models.py`

### AI and analytics

- [Cadence and sales BI](https://github.com/shubhamjain000/crm/blob/main/backend/analytics/services.py): `backend/analytics/services.py`
- [Zia assistant](https://github.com/shubhamjain000/crm/blob/main/backend/zia_chatbot/services.py): `backend/zia_chatbot/services.py`

### Platform services

- [Prisma database](https://github.com/shubhamjain000/crm/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Tenant-scoped data](https://github.com/shubhamjain000/crm/blob/main/backend/api/managers.py): `backend/api/managers.py`
- [Approvals](https://github.com/shubhamjain000/crm/blob/main/backend/approvals/models.py): `backend/approvals/models.py`
- [Blueprint execution](https://github.com/shubhamjain000/crm/blob/main/backend/blueprint/services.py): `backend/blueprint/services.py`
- [Validation rules](https://github.com/shubhamjain000/crm/blob/main/backend/validation_rules/services.py): `backend/validation_rules/services.py`
- [CRM activity services](https://github.com/shubhamjain000/crm/blob/main/backend/crm_ux/services.py): `backend/crm_ux/services.py`
- [Notifications](https://github.com/shubhamjain000/crm/blob/main/backend/notifications/services.py): `backend/notifications/services.py`

### Other components

- **Sales user**

## Connections

- Sales user → CRM API routes: manages records
- CRM API routes → Session management: authenticates with (evidence: `src/lib/crm/detail-routes.ts`)
- CRM API routes → Tenant resolution: resolves tenant (evidence: `src/lib/crm/detail-routes.ts`)
- CRM API routes → Tenant CRM handler: delegates updates (evidence: `src/lib/crm/detail-routes.ts`)
- CRM API routes → Custom fields: reads and writes (evidence: `src/lib/crm/detail-routes.ts`)
- CRM API routes → Prisma database: queries records (evidence: `src/lib/crm/detail-routes.ts`)
- Session management → Prisma database: reads sessions (evidence: `src/lib/auth/session.ts`)
- Tenant resolution → Prisma database: reads membership (evidence: `src/lib/auth/tenant.ts`)
- Audit logging → Prisma database: writes audit (evidence: `src/lib/auth/audit.ts`)
- Sales user → Accounts, contacts, leads: tracks prospects
- Sales user → Deals and pipelines: manages opportunities
- Deals and pipelines → Pipeline stages: uses stages (evidence: `backend/deals/models_pipeline.py`)
- Sales user → CSM cadence: records next steps
- CSM cadence → Cadence and sales BI: reports cadence metrics
- Sales user → Zia assistant: requests CRM actions
- Zia assistant → CSM cadence: sets next steps
- CSM cadence → Notifications: creates follow-up tasks
- Tenant-scoped data → Tenant-scoped data: scopes queries (evidence: `backend/api/managers.py`)
- CRM activity services → Notifications: fans out alerts (evidence: `backend/feed/signals.py`)
- Approvals → CRM activity services: logs approval activity (evidence: `backend/approvals/signals.py`)
- Deals and pipelines → Blueprint execution: starts execution
- Accounts, contacts, leads → Validation rules: validates records (evidence: `backend/validation_rules/signals.py`)
