# rishi2600/crm architecture

> Architecture diagram of the GitHub repository rishi2600/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/rishi2600/crm
- Repository: https://github.com/rishi2600/crm

## Overview

CRM supports an Indian sales team through a lifecycle of lead intake and qualification, follow-up scheduling, conversion into deals, and pipeline progression, alongside contact and task management. Its app pages expose these workflows; API routes implement the domain operations and persist records through Prisma to PostgreSQL. Dashboard, analytics, and insights provide separate views of sales outcomes and activity. The tree and README establish the product capabilities; sampled routes support the listed data and scope responsibilities, while unsampled page-to-route wiring is not asserted.

Main entry points: [`src/lib/prisma.ts`](https://github.com/rishi2600/crm/blob/main/src/lib/prisma.ts) (Prisma client), [`src/lib/scope.ts`](https://github.com/rishi2600/crm/blob/main/src/lib/scope.ts) (Access scoping), [`src/app/(app)/dashboard/page.tsx`](https://github.com/rishi2600/crm/blob/main/src/app/(app)/dashboard/page.tsx) (Dashboard), [`src/app/(app)/leads/page.tsx`](https://github.com/rishi2600/crm/blob/main/src/app/(app)/leads/page.tsx) (Lead desk)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Sales workspace"]
  node_leads_ui["Lead desk<br/>[page.tsx]"]
  node_lead_detail_ui["Lead history<br/>[page.tsx]"]
  node_contacts_ui["Contacts<br/>[page.tsx]"]
  node_followups_ui["Follow-ups<br/>[page.tsx]"]
  node_deals_ui["Deal pipeline<br/>[page.tsx]"]
  node_tasks_ui["Tasks<br/>[page.tsx]"]
  node_dashboard_ui["Dashboard<br/>[page.tsx]"]
  node_analytics_ui["Analytics<br/>[page.tsx]"]
  node_login_ui["Login<br/>[page.tsx]"]
end

subgraph group_workflow["Sales operations"]
  node_lead_api["Lead operations<br/>[route.ts]"]
  node_lead_detail_api["Lead detail and status<br/>[route.ts]"]
  node_lead_import_api["Lead CSV import<br/>[route.ts]"]
  node_contacts_api["Contact operations<br/>[route.ts]"]
  node_followups_api["Follow-up operations<br/>[route.ts]"]
  node_deals_api["Deal creation<br/>[route.ts]"]
  node_deal_stage_api["Deal stage changes<br/>[route.ts]"]
  node_tasks_api["Task operations<br/>[route.ts]"]
end

subgraph group_reporting["Reporting and insights"]
  node_dashboard_api["Dashboard data<br/>[route.ts]"]
  node_analytics_api["Sales analytics<br/>[route.ts]"]
  node_insights_api["Lead and follow-up insights<br/>[route.ts]"]
  node_trends_api["Insight trends<br/>[route.ts]"]
end

subgraph group_platform["Access and data"]
  node_auth_api["Login and logout<br/>[route.ts]"]
  node_scope["Access scoping<br/>[scope.ts]"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
end

node_sales_team(("Sales team"))
node_postgres[("PostgreSQL")]

node_sales_team -->|"signs in"| node_login_ui
node_login_ui -->|"submits credentials"| node_auth_api
node_sales_team -->|"works leads"| node_leads_ui
node_sales_team -->|"views contacts"| node_contacts_ui
node_sales_team -->|"manages calls"| node_followups_ui
node_sales_team -->|"moves deals"| node_deals_ui
node_sales_team -->|"tracks tasks"| node_tasks_ui
node_sales_team -->|"reviews activity"| node_dashboard_ui
node_sales_team -->|"reviews performance"| node_analytics_ui
node_leads_ui -->|"manages leads"| node_lead_api
node_leads_ui -->|"imports CSV"| node_lead_import_api
node_lead_detail_ui -->|"views and updates"| node_lead_detail_api
node_contacts_ui -->|"manages contacts"| node_contacts_api
node_followups_ui -->|"schedules and updates"| node_followups_api
node_deals_ui -->|"creates deals"| node_deals_api
node_deals_ui -->|"changes stage"| node_deal_stage_api
node_tasks_ui -->|"manages tasks"| node_tasks_api
node_dashboard_ui -->|"loads summary"| node_dashboard_api
node_dashboard_ui -->|"loads KPI insights"| node_insights_api
node_dashboard_ui -->|"loads trends"| node_trends_api
node_analytics_ui -->|"loads metrics"| node_analytics_api
node_lead_api -->|"resolves visibility"| node_scope
node_lead_detail_api -->|"checks ownership"| node_scope
node_followups_api -->|"resolves visibility"| node_scope
node_tasks_api -->|"resolves visibility"| node_scope
node_analytics_api -->|"resolves visibility"| node_scope
node_insights_api -->|"resolves visibility"| node_scope
node_lead_api -->|"queries records"| node_prisma
node_lead_detail_api -->|"reads and updates"| node_prisma
node_lead_import_api -->|"creates leads"| node_prisma
node_contacts_api -->|"queries and creates"| node_prisma
node_followups_api -->|"reads and creates"| node_prisma
node_deals_api -->|"creates deals"| node_prisma
node_deal_stage_api -->|"updates stages"| node_prisma
node_tasks_api -->|"reads and creates"| node_prisma
node_dashboard_api -->|"aggregates records"| node_prisma
node_analytics_api -->|"aggregates records"| node_prisma
node_insights_api -->|"aggregates activity"| node_prisma
node_trends_api -->|"queries trends"| node_prisma
node_prisma -->|"reads and writes"| node_postgres
node_auth_api -->|"looks up users"| node_prisma

click node_leads_ui "https://github.com/rishi2600/crm/blob/main/src/app/(app)/leads/page.tsx"
click node_lead_detail_ui "https://github.com/rishi2600/crm/blob/main/src/app/(app)/leads/%5Bid%5D/page.tsx"
click node_contacts_ui "https://github.com/rishi2600/crm/blob/main/src/app/(app)/contacts/page.tsx"
click node_followups_ui "https://github.com/rishi2600/crm/blob/main/src/app/(app)/follow-ups/page.tsx"
click node_deals_ui "https://github.com/rishi2600/crm/blob/main/src/app/(app)/deals/page.tsx"
click node_tasks_ui "https://github.com/rishi2600/crm/blob/main/src/app/(app)/tasks/page.tsx"
click node_dashboard_ui "https://github.com/rishi2600/crm/blob/main/src/app/(app)/dashboard/page.tsx"
click node_analytics_ui "https://github.com/rishi2600/crm/blob/main/src/app/(app)/analytics/page.tsx"
click node_login_ui "https://github.com/rishi2600/crm/blob/main/src/app/(auth)/login/page.tsx"
click node_lead_api "https://github.com/rishi2600/crm/blob/main/src/app/api/leads/route.ts"
click node_lead_detail_api "https://github.com/rishi2600/crm/blob/main/src/app/api/leads/%5Bid%5D/route.ts"
click node_lead_import_api "https://github.com/rishi2600/crm/blob/main/src/app/api/leads/bulk/route.ts"
click node_contacts_api "https://github.com/rishi2600/crm/blob/main/src/app/api/contacts/route.ts"
click node_followups_api "https://github.com/rishi2600/crm/blob/main/src/app/api/follow-ups/route.ts"
click node_deals_api "https://github.com/rishi2600/crm/blob/main/src/app/api/deals/route.ts"
click node_deal_stage_api "https://github.com/rishi2600/crm/blob/main/src/app/api/deals/%5Bid%5D/stage/route.ts"
click node_tasks_api "https://github.com/rishi2600/crm/blob/main/src/app/api/tasks/route.ts"
click node_dashboard_api "https://github.com/rishi2600/crm/blob/main/src/app/api/dashboard/route.ts"
click node_analytics_api "https://github.com/rishi2600/crm/blob/main/src/app/api/analytics/dashboard/route.ts"
click node_insights_api "https://github.com/rishi2600/crm/blob/main/src/app/api/insights/summary/route.ts"
click node_trends_api "https://github.com/rishi2600/crm/blob/main/src/app/api/insights/trends/route.ts"
click node_auth_api "https://github.com/rishi2600/crm/blob/main/src/app/api/auth/login/route.ts"
click node_scope "https://github.com/rishi2600/crm/blob/main/src/lib/scope.ts"
click node_prisma "https://github.com/rishi2600/crm/blob/main/src/lib/prisma.ts"

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_leads_ui,node_lead_detail_ui,node_contacts_ui,node_followups_ui,node_deals_ui,node_tasks_ui,node_dashboard_ui,node_analytics_ui,node_login_ui toneBlue
class node_lead_api,node_lead_detail_api,node_lead_import_api,node_contacts_api,node_followups_api,node_deals_api,node_deal_stage_api,node_tasks_api,node_postgres toneAmber
class node_dashboard_api,node_analytics_api,node_insights_api,node_trends_api toneMint
class node_auth_api,node_scope,node_prisma toneRose
class node_sales_team toneIndigo
```

## Components

### Sales workspace

- [Lead desk](https://github.com/rishi2600/crm/blob/main/src/app/(app)/leads/page.tsx): `src/app/(app)/leads/page.tsx`
- [Lead history](https://github.com/rishi2600/crm/blob/main/src/app/(app)/leads/%5Bid%5D/page.tsx): `src/app/(app)/leads/[id]/page.tsx`
- [Contacts](https://github.com/rishi2600/crm/blob/main/src/app/(app)/contacts/page.tsx): `src/app/(app)/contacts/page.tsx`
- [Follow-ups](https://github.com/rishi2600/crm/blob/main/src/app/(app)/follow-ups/page.tsx): `src/app/(app)/follow-ups/page.tsx`
- [Deal pipeline](https://github.com/rishi2600/crm/blob/main/src/app/(app)/deals/page.tsx): `src/app/(app)/deals/page.tsx`
- [Tasks](https://github.com/rishi2600/crm/blob/main/src/app/(app)/tasks/page.tsx): `src/app/(app)/tasks/page.tsx`
- [Dashboard](https://github.com/rishi2600/crm/blob/main/src/app/(app)/dashboard/page.tsx): `src/app/(app)/dashboard/page.tsx`
- [Analytics](https://github.com/rishi2600/crm/blob/main/src/app/(app)/analytics/page.tsx): `src/app/(app)/analytics/page.tsx`
- [Login](https://github.com/rishi2600/crm/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`

### Sales operations

- [Lead operations](https://github.com/rishi2600/crm/blob/main/src/app/api/leads/route.ts): `src/app/api/leads/route.ts`
- [Lead detail and status](https://github.com/rishi2600/crm/blob/main/src/app/api/leads/%5Bid%5D/route.ts): `src/app/api/leads/[id]/route.ts`
- [Lead CSV import](https://github.com/rishi2600/crm/blob/main/src/app/api/leads/bulk/route.ts): `src/app/api/leads/bulk/route.ts`
- [Contact operations](https://github.com/rishi2600/crm/blob/main/src/app/api/contacts/route.ts): `src/app/api/contacts/route.ts`
- [Follow-up operations](https://github.com/rishi2600/crm/blob/main/src/app/api/follow-ups/route.ts): `src/app/api/follow-ups/route.ts`
- [Deal creation](https://github.com/rishi2600/crm/blob/main/src/app/api/deals/route.ts): `src/app/api/deals/route.ts`
- [Deal stage changes](https://github.com/rishi2600/crm/blob/main/src/app/api/deals/%5Bid%5D/stage/route.ts): `src/app/api/deals/[id]/stage/route.ts`
- [Task operations](https://github.com/rishi2600/crm/blob/main/src/app/api/tasks/route.ts): `src/app/api/tasks/route.ts`

### Reporting and insights

- [Dashboard data](https://github.com/rishi2600/crm/blob/main/src/app/api/dashboard/route.ts): `src/app/api/dashboard/route.ts`
- [Sales analytics](https://github.com/rishi2600/crm/blob/main/src/app/api/analytics/dashboard/route.ts): `src/app/api/analytics/dashboard/route.ts`
- [Lead and follow-up insights](https://github.com/rishi2600/crm/blob/main/src/app/api/insights/summary/route.ts): `src/app/api/insights/summary/route.ts`
- [Insight trends](https://github.com/rishi2600/crm/blob/main/src/app/api/insights/trends/route.ts): `src/app/api/insights/trends/route.ts`

### Access and data

- [Login and logout](https://github.com/rishi2600/crm/blob/main/src/app/api/auth/login/route.ts): `src/app/api/auth/login/route.ts`
- [Access scoping](https://github.com/rishi2600/crm/blob/main/src/lib/scope.ts): `src/lib/scope.ts`
- [Prisma client](https://github.com/rishi2600/crm/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`

### Other components

- **Sales team**
- **PostgreSQL**

## Connections

- Sales team → Login: signs in
- Login → Login and logout: submits credentials
- Sales team → Lead desk: works leads
- Sales team → Contacts: views contacts
- Sales team → Follow-ups: manages calls
- Sales team → Deal pipeline: moves deals
- Sales team → Tasks: tracks tasks
- Sales team → Dashboard: reviews activity
- Sales team → Analytics: reviews performance
- Lead desk → Lead operations: manages leads
- Lead desk → Lead CSV import: imports CSV
- Lead history → Lead detail and status: views and updates
- Contacts → Contact operations: manages contacts
- Follow-ups → Follow-up operations: schedules and updates
- Deal pipeline → Deal creation: creates deals
- Deal pipeline → Deal stage changes: changes stage
- Tasks → Task operations: manages tasks
- Dashboard → Dashboard data: loads summary
- Dashboard → Lead and follow-up insights: loads KPI insights
- Dashboard → Insight trends: loads trends
- Analytics → Sales analytics: loads metrics
- Lead operations → Access scoping: resolves visibility
- Lead detail and status → Access scoping: checks ownership
- Follow-up operations → Access scoping: resolves visibility
- Task operations → Access scoping: resolves visibility
- Sales analytics → Access scoping: resolves visibility
- Lead and follow-up insights → Access scoping: resolves visibility
- Lead operations → Prisma client: queries records
- Lead detail and status → Prisma client: reads and updates
- Lead CSV import → Prisma client: creates leads
- Contact operations → Prisma client: queries and creates
- Follow-up operations → Prisma client: reads and creates
- Deal creation → Prisma client: creates deals
- Deal stage changes → Prisma client: updates stages
- Task operations → Prisma client: reads and creates
- Dashboard data → Prisma client: aggregates records
- Sales analytics → Prisma client: aggregates records
- Lead and follow-up insights → Prisma client: aggregates activity
- Insight trends → Prisma client: queries trends
- Prisma client → PostgreSQL: reads and writes
- Login and logout → Prisma client: looks up users
