# octa-devs/octadevscrm architecture

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

- Interactive diagram: https://gitdiagram.com/octa-devs/octadevscrm
- Repository: https://github.com/octa-devs/octadevscrm

## Overview

OCTA DEVS CRM is an employee portal combining role-based access, CRM records, visitor and team chat, and website administration. The main workflow is an employee signing in, entering the dashboard, and using permission-guarded features whose API routes read or update Supabase-backed data. The graph preserves the README’s major product areas; several UI-to-API links and unsampled route behaviors are not shown because their wiring was not in the excerpts.

Main entry points: [`lib/auth.ts`](https://github.com/octa-devs/octadevscrm/blob/main/lib/auth.ts) (Session and permissions), [`lib/supabase/admin.ts`](https://github.com/octa-devs/octadevscrm/blob/main/lib/supabase/admin.ts) (Supabase admin client), [`app/dashboard/chat/page.tsx`](https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/chat/page.tsx) (Chat workspace), [`app/dashboard/website/page.tsx`](https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/website/page.tsx) (Website admin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and roles"]
  node_login["Sign in<br/>[page.tsx]"]
  node_sessionapi["Session endpoint<br/>[route.ts]"]
  node_auth["Session and permissions<br/>[auth.ts]"]
  node_rolesapi["Role management API<br/>[route.ts]"]
end

subgraph group_crm["CRM workspace"]
  node_crmviews["CRM records views"]
  node_crud["CRM resource UI<br/>[CrudResource.tsx]"]
  node_crmapis["CRM entity API<br/>[route.ts]"]
end

subgraph group_chat["Chat"]
  node_chatview["Chat workspace<br/>[page.tsx]"]
  node_visitorapi["Visitor conversations API<br/>[route.ts]"]
  node_threadapi["Conversation thread API<br/>[route.ts]"]
  node_teamapi["Team chat API<br/>[route.ts]"]
  node_membersapi["Chat team directory<br/>[route.ts]"]
end

subgraph group_admin["Administration"]
  node_websiteview["Website admin<br/>[page.tsx]"]
  node_projectsapi["Website projects API<br/>[route.ts]"]
  node_webteamapi["Website team API<br/>[route.ts]"]
  node_launchapi["Launch settings API<br/>[route.ts]"]
  node_usersview["People management UI<br/>[page.tsx]"]
  node_usersapi["User management API<br/>[route.ts]"]
end

subgraph group_platform["Shared platform"]
  node_dashboard["Dashboard shell<br/>[layout.tsx]"]
  node_crmlib["CRM storage helpers<br/>[crm.ts]"]
  node_supabase[("Supabase")]
  node_adminclient["Supabase admin client<br/>[admin.ts]"]
  node_browserclient["Supabase browser client<br/>[client.ts]"]
end

node_employee(("Employee"))

node_employee -->|"signs in"| node_login
node_login -->|"authenticates with"| node_browserclient
node_employee -->|"uses portal"| node_dashboard
node_dashboard -.->|"loads identity"| node_sessionapi
node_sessionapi -->|"verifies session"| node_auth
node_auth -->|"loads role permissions"| node_adminclient
node_rolesapi -->|"checks permissions"| node_auth
node_rolesapi -->|"manages roles"| node_adminclient
node_crmviews -->|"renders resources"| node_crud
node_crud -.->|"requests records"| node_crmapis
node_crmapis -->|"checks access"| node_auth
node_crmapis -->|"reads and writes"| node_crmlib
node_employee -->|"manages CRM"| node_crmviews
node_chatview -.->|"loads inbox"| node_visitorapi
node_chatview -.->|"manages threads"| node_threadapi
node_chatview -.->|"sends team messages"| node_teamapi
node_teamapi -->|"checks permission"| node_auth
node_teamapi -->|"reads and writes"| node_adminclient
node_employee -->|"uses chat"| node_chatview
node_websiteview -.->|"manages projects"| node_projectsapi
node_websiteview -.->|"manages team"| node_webteamapi
node_websiteview -.->|"updates launch settings"| node_launchapi
node_employee -->|"administers website"| node_websiteview
node_usersview -.->|"manages accounts"| node_usersapi
node_usersapi -->|"checks permission"| node_auth
node_usersapi -->|"manages accounts"| node_adminclient
node_adminclient -.->|"accesses backend"| node_supabase
node_employee -->|"manages people"| node_usersview

click node_login "https://github.com/octa-devs/octadevscrm/blob/main/app/login/page.tsx"
click node_sessionapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/session/route.ts"
click node_auth "https://github.com/octa-devs/octadevscrm/blob/main/lib/auth.ts"
click node_rolesapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/roles/route.ts"
click node_dashboard "https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/layout.tsx"
click node_crmviews "https://github.com/octa-devs/octadevscrm/tree/main/app/dashboard/crm"
click node_crud "https://github.com/octa-devs/octadevscrm/blob/main/components/CrudResource.tsx"
click node_crmapis "https://github.com/octa-devs/octadevscrm/blob/main/app/api/crm/%5Bentity%5D/route.ts"
click node_crmlib "https://github.com/octa-devs/octadevscrm/blob/main/lib/crm.ts"
click node_chatview "https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/chat/page.tsx"
click node_visitorapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/chat/conversations/route.ts"
click node_threadapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/chat/conversations/%5Bid%5D/route.ts"
click node_teamapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/chat/team/route.ts"
click node_membersapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/chat/team/members/route.ts"
click node_websiteview "https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/website/page.tsx"
click node_projectsapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/website/projects/route.ts"
click node_webteamapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/website/team/route.ts"
click node_launchapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/website/launch/route.ts"
click node_usersview "https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/users/page.tsx"
click node_usersapi "https://github.com/octa-devs/octadevscrm/blob/main/app/api/users/route.ts"
click node_adminclient "https://github.com/octa-devs/octadevscrm/blob/main/lib/supabase/admin.ts"
click node_browserclient "https://github.com/octa-devs/octadevscrm/blob/main/lib/supabase/client.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_sessionapi,node_auth,node_rolesapi toneBlue
class node_crmviews,node_crud,node_crmapis toneAmber
class node_chatview,node_visitorapi,node_threadapi,node_teamapi,node_membersapi toneMint
class node_websiteview,node_projectsapi,node_webteamapi,node_launchapi,node_usersview,node_usersapi toneRose
class node_dashboard,node_crmlib,node_supabase,node_adminclient,node_browserclient,node_employee toneIndigo
```

## Components

### Access and roles

- [Sign in](https://github.com/octa-devs/octadevscrm/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Session endpoint](https://github.com/octa-devs/octadevscrm/blob/main/app/api/session/route.ts): `app/api/session/route.ts`
- [Session and permissions](https://github.com/octa-devs/octadevscrm/blob/main/lib/auth.ts): `lib/auth.ts`
- [Role management API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/roles/route.ts): `app/api/roles/route.ts`

### CRM workspace

- [CRM records views](https://github.com/octa-devs/octadevscrm/tree/main/app/dashboard/crm): `app/dashboard/crm`
- [CRM resource UI](https://github.com/octa-devs/octadevscrm/blob/main/components/CrudResource.tsx): `components/CrudResource.tsx`
- [CRM entity API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/crm/%5Bentity%5D/route.ts): `app/api/crm/[entity]/route.ts`

### Chat

- [Chat workspace](https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/chat/page.tsx): `app/dashboard/chat/page.tsx`
- [Visitor conversations API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/chat/conversations/route.ts): `app/api/chat/conversations/route.ts`
- [Conversation thread API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/chat/conversations/%5Bid%5D/route.ts): `app/api/chat/conversations/[id]/route.ts`
- [Team chat API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/chat/team/route.ts): `app/api/chat/team/route.ts`
- [Chat team directory](https://github.com/octa-devs/octadevscrm/blob/main/app/api/chat/team/members/route.ts): `app/api/chat/team/members/route.ts`

### Administration

- [Website admin](https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/website/page.tsx): `app/dashboard/website/page.tsx`
- [Website projects API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/website/projects/route.ts): `app/api/website/projects/route.ts`
- [Website team API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/website/team/route.ts): `app/api/website/team/route.ts`
- [Launch settings API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/website/launch/route.ts): `app/api/website/launch/route.ts`
- [People management UI](https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/users/page.tsx): `app/dashboard/users/page.tsx`
- [User management API](https://github.com/octa-devs/octadevscrm/blob/main/app/api/users/route.ts): `app/api/users/route.ts`

### Shared platform

- [Dashboard shell](https://github.com/octa-devs/octadevscrm/blob/main/app/dashboard/layout.tsx): `app/dashboard/layout.tsx`
- [CRM storage helpers](https://github.com/octa-devs/octadevscrm/blob/main/lib/crm.ts): `lib/crm.ts`
- **Supabase**
- [Supabase admin client](https://github.com/octa-devs/octadevscrm/blob/main/lib/supabase/admin.ts): `lib/supabase/admin.ts`
- [Supabase browser client](https://github.com/octa-devs/octadevscrm/blob/main/lib/supabase/client.ts): `lib/supabase/client.ts`

### Other components

- **Employee**

## Connections

- Employee → Sign in: signs in (evidence: `app/login/page.tsx`)
- Sign in → Supabase browser client: authenticates with (evidence: `app/login/page.tsx`)
- Employee → Dashboard shell: uses portal (evidence: `README.md`)
- Dashboard shell → Session endpoint: loads identity
- Session endpoint → Session and permissions: verifies session (evidence: `app/api/session/route.ts`)
- Session and permissions → Supabase admin client: loads role permissions (evidence: `lib/auth.ts`)
- Role management API → Session and permissions: checks permissions (evidence: `app/api/roles/route.ts`)
- Role management API → Supabase admin client: manages roles (evidence: `app/api/roles/route.ts`)
- CRM records views → CRM resource UI: renders resources (evidence: `app/dashboard/crm/leads/page.tsx`)
- CRM resource UI → CRM entity API: requests records
- CRM entity API → Session and permissions: checks access (evidence: `app/api/crm/[entity]/route.ts`)
- CRM entity API → CRM storage helpers: reads and writes (evidence: `app/api/crm/[entity]/route.ts`)
- Employee → CRM records views: manages CRM (evidence: `README.md`)
- Chat workspace → Visitor conversations API: loads inbox
- Chat workspace → Conversation thread API: manages threads
- Chat workspace → Team chat API: sends team messages
- Team chat API → Session and permissions: checks permission (evidence: `app/api/chat/team/route.ts`)
- Team chat API → Supabase admin client: reads and writes (evidence: `app/api/chat/team/route.ts`)
- Employee → Chat workspace: uses chat (evidence: `README.md`)
- Website admin → Website projects API: manages projects
- Website admin → Website team API: manages team
- Website admin → Launch settings API: updates launch settings
- Employee → Website admin: administers website (evidence: `README.md`)
- People management UI → User management API: manages accounts
- User management API → Session and permissions: checks permission (evidence: `app/api/users/route.ts`)
- User management API → Supabase admin client: manages accounts (evidence: `app/api/users/route.ts`)
- Supabase admin client → Supabase: accesses backend
- Employee → People management UI: manages people (evidence: `README.md`)
