# gokul-nygenx/crm-tool architecture

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

- Interactive diagram: https://gitdiagram.com/gokul-nygenx/crm-tool
- Repository: https://github.com/gokul-nygenx/crm-tool

## Overview

This is a web CRM for a professional-services practice. Users sign in, review a financial-year dashboard, and manage client relationships, service packages, compliance work, renewals, invoices, and collections. The Zustand store coordinates CRM records and synchronizes them through the Supabase data layer; authentication also uses Supabase. The tree and excerpts establish the product areas, but do not expose every page-to-store connection, so those links are omitted where unverified.

Main entry points: [`src/context/AuthContext.tsx`](https://github.com/gokul-nygenx/crm-tool/blob/main/src/context/AuthContext.tsx) (Authentication), [`src/app/login/page.tsx`](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/login/page.tsx) (Sign in), [`src/app/api/send-otp/route.ts`](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/api/send-otp/route.ts) (OTP dispatch), [`src/lib/supabaseData.ts`](https://github.com/gokul-nygenx/crm-tool/blob/main/src/lib/supabaseData.ts) (Supabase data access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and Shell"]
  node_login["Sign in<br/>[page.tsx]"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
  node_otp["OTP dispatch<br/>[route.ts]"]
  node_shell["Application shell<br/>[AppShell.tsx]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_search["Global search"]
end

subgraph group_relationships["Client Relationships"]
  node_clients["Client directory<br/>[page.tsx]"]
  node_leads["Lead tracking<br/>[page.tsx]"]
  node_collaborations["Collaborations<br/>[page.tsx]"]
end

subgraph group_operations["Service Operations"]
  node_services["Service catalog<br/>[page.tsx]"]
  node_subservices["Sub-services<br/>[page.tsx]"]
  node_required["Required documents<br/>[page.tsx]"]
  node_assigned["Client services<br/>[page.tsx]"]
  node_renewals["Renewals<br/>[page.tsx]"]
  node_due["Due dates<br/>[page.tsx]"]
  node_automation["Automations<br/>[page.tsx]"]
end

subgraph group_finance["Finance and Workspace"]
  node_invoice["Invoices<br/>[page.tsx]"]
  node_banking["Banking<br/>[page.tsx]"]
  node_drafts["Drafts<br/>[page.tsx]"]
  node_subscription["Subscription<br/>[page.tsx]"]
  node_settings["Workspace settings<br/>[page.tsx]"]
end

subgraph group_data["State and Integrations"]
  node_store["CRM state<br/>[store.ts]"]
  node_dataaccess["Supabase data access<br/>[supabaseData.ts]"]
  node_supabase[("Supabase<br/>[supabase.ts]")]
end

node_user(("Practice user"))
node_smtp["SMTP email"]
node_resend["Resend API"]

node_user -->|"signs in"| node_login
node_login -->|"uses auth"| node_auth
node_auth -->|"checks session"| node_supabase
node_auth -->|"resolves identity"| node_dataaccess
node_auth -->|"upserts profile"| node_supabase
node_login -->|"requests code"| node_otp
node_otp -.->|"sends email"| node_smtp
node_otp -.->|"sends email"| node_resend
node_user -->|"views workspace"| node_dashboard
node_dashboard -->|"renders within"| node_shell
node_clients -->|"renders within"| node_shell
node_invoice -->|"renders within"| node_shell
node_subservices -->|"reads and updates"| node_store
node_store -->|"fetches and syncs"| node_dataaccess
node_dataaccess -->|"reads and writes"| node_supabase
node_user -->|"manages clients"| node_clients
node_user -->|"tracks leads"| node_leads
node_user -->|"manages partners"| node_collaborations
node_user -->|"configures services"| node_services
node_user -->|"tracks documents"| node_required
node_user -->|"assigns services"| node_assigned
node_user -->|"tracks renewals"| node_renewals
node_user -->|"reviews deadlines"| node_due
node_user -->|"configures workflows"| node_automation
node_user -->|"creates invoices"| node_invoice
node_user -->|"reviews banking"| node_banking
node_user -->|"manages drafts"| node_drafts
node_user -->|"manages subscription"| node_subscription
node_user -->|"configures workspace"| node_settings
node_user -->|"searches records"| node_search

click node_login "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/login/page.tsx"
click node_auth "https://github.com/gokul-nygenx/crm-tool/blob/main/src/context/AuthContext.tsx"
click node_otp "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/api/send-otp/route.ts"
click node_shell "https://github.com/gokul-nygenx/crm-tool/blob/main/src/components/AppShell.tsx"
click node_dashboard "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/page.tsx"
click node_search "https://github.com/gokul-nygenx/crm-tool/blob/main/src/components/GlobalSearchModal.tsx"
click node_clients "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/clients/page.tsx"
click node_leads "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/leads/page.tsx"
click node_collaborations "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/collaborations/page.tsx"
click node_services "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/services/page.tsx"
click node_subservices "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/sub-services/page.tsx"
click node_required "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/required-docs/page.tsx"
click node_assigned "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/service-clients/page.tsx"
click node_renewals "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/renewals/page.tsx"
click node_due "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/due-dates/page.tsx"
click node_automation "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/automations/page.tsx"
click node_invoice "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/invoice/page.tsx"
click node_banking "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/banking/page.tsx"
click node_drafts "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/drafts/page.tsx"
click node_subscription "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/subscription/page.tsx"
click node_settings "https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/settings/page.tsx"
click node_store "https://github.com/gokul-nygenx/crm-tool/blob/main/src/lib/store.ts"
click node_dataaccess "https://github.com/gokul-nygenx/crm-tool/blob/main/src/lib/supabaseData.ts"
click node_supabase "https://github.com/gokul-nygenx/crm-tool/blob/main/src/lib/supabase.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_login,node_auth,node_otp,node_shell,node_dashboard,node_search,node_user toneBlue
class node_clients,node_leads,node_collaborations toneAmber
class node_services,node_subservices,node_required,node_assigned,node_renewals,node_due,node_automation,node_resend toneMint
class node_invoice,node_banking,node_drafts,node_subscription,node_settings toneRose
class node_store,node_dataaccess,node_supabase,node_smtp toneIndigo
```

## Components

### Access and Shell

- [Sign in](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/login/page.tsx): `src/app/login/page.tsx`
- [Authentication](https://github.com/gokul-nygenx/crm-tool/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [OTP dispatch](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/api/send-otp/route.ts): `src/app/api/send-otp/route.ts`
- [Application shell](https://github.com/gokul-nygenx/crm-tool/blob/main/src/components/AppShell.tsx): `src/components/AppShell.tsx`
- [Dashboard](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Global search](https://github.com/gokul-nygenx/crm-tool/blob/main/src/components/GlobalSearchModal.tsx): `src/components/GlobalSearchModal.tsx`

### Client Relationships

- [Client directory](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/clients/page.tsx): `src/app/clients/page.tsx`
- [Lead tracking](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/leads/page.tsx): `src/app/leads/page.tsx`
- [Collaborations](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/collaborations/page.tsx): `src/app/collaborations/page.tsx`

### Service Operations

- [Service catalog](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/services/page.tsx): `src/app/services/page.tsx`
- [Sub-services](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/sub-services/page.tsx): `src/app/sub-services/page.tsx`
- [Required documents](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/required-docs/page.tsx): `src/app/required-docs/page.tsx`
- [Client services](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/service-clients/page.tsx): `src/app/service-clients/page.tsx`
- [Renewals](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/renewals/page.tsx): `src/app/renewals/page.tsx`
- [Due dates](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/due-dates/page.tsx): `src/app/due-dates/page.tsx`
- [Automations](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/automations/page.tsx): `src/app/automations/page.tsx`

### Finance and Workspace

- [Invoices](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/invoice/page.tsx): `src/app/invoice/page.tsx`
- [Banking](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/banking/page.tsx): `src/app/banking/page.tsx`
- [Drafts](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/drafts/page.tsx): `src/app/drafts/page.tsx`
- [Subscription](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/subscription/page.tsx): `src/app/subscription/page.tsx`
- [Workspace settings](https://github.com/gokul-nygenx/crm-tool/blob/main/src/app/settings/page.tsx): `src/app/settings/page.tsx`

### State and Integrations

- [CRM state](https://github.com/gokul-nygenx/crm-tool/blob/main/src/lib/store.ts): `src/lib/store.ts`
- [Supabase data access](https://github.com/gokul-nygenx/crm-tool/blob/main/src/lib/supabaseData.ts): `src/lib/supabaseData.ts`
- [Supabase](https://github.com/gokul-nygenx/crm-tool/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`

### Other components

- **Practice user**
- **SMTP email**
- **Resend API**

## Connections

- Practice user → Sign in: signs in
- Sign in → Authentication: uses auth
- Authentication → Supabase: checks session
- Authentication → Supabase data access: resolves identity
- Authentication → Supabase: upserts profile
- Sign in → OTP dispatch: requests code
- OTP dispatch → SMTP email: sends email
- OTP dispatch → Resend API: sends email
- Practice user → Dashboard: views workspace
- Dashboard → Application shell: renders within
- Client directory → Application shell: renders within
- Invoices → Application shell: renders within
- Sub-services → CRM state: reads and updates
- CRM state → Supabase data access: fetches and syncs
- Supabase data access → Supabase: reads and writes
- Practice user → Client directory: manages clients
- Practice user → Lead tracking: tracks leads
- Practice user → Collaborations: manages partners
- Practice user → Service catalog: configures services
- Practice user → Required documents: tracks documents
- Practice user → Client services: assigns services
- Practice user → Renewals: tracks renewals
- Practice user → Due dates: reviews deadlines
- Practice user → Automations: configures workflows
- Practice user → Invoices: creates invoices
- Practice user → Banking: reviews banking
- Practice user → Drafts: manages drafts
- Practice user → Subscription: manages subscription
- Practice user → Workspace settings: configures workspace
- Practice user → Global search: searches records
