How dwivediishivam/intercom works
Purpose and entry points
This is a Next.js customer-support platform resembling Intercom: workspace-scoped conversations, contacts, knowledge base, embeddable widget, team operations, and AI-assisted support. Primary UI entry points are the public landing/help pages and authenticated app shell: src/app/page.tsx, src/app/app/page.tsx, src/app/help/page.tsx, and src/app/widget.js/route.ts.
Application surfaces
The authenticated operator experience is assembled from domain-oriented client components: src/components/app-shell.tsx, src/components/conversation-workspace.tsx, and src/components/operations-surfaces.tsx. Authentication and first-run flows are separated at src/app/login/page.tsx, src/app/auth/callback/route.ts, and src/app/onboarding/page.tsx. This boundary distinguishes public/widget traffic from staff workspace operations.
Workspace tenancy and access control
Workspace resources are exposed beneath workspace-scoped API routes, making workspaceId the central tenancy boundary: src/app/api/workspaces/route.ts, src/app/api/workspaces/[workspaceId]/members/[profileId]/route.ts, and src/app/api/workspaces/[workspaceId]/api-tokens/route.ts. Supporting domain logic is concentrated in src/lib/workspaces.ts, src/lib/auth.ts, and src/lib/api-tokens.ts. Invitations, member management, API tokens, domains, and webhooks are therefore controlled as workspace capabilities rather than global resources.
Conversation and support workflow
Conversation handling is the operational core. APIs receive/read messages, apply actions, calculate SLA state, and invoke AI: src/app/api/conversations/[conversationId]/messages/route.ts, src/app/api/conversations/[conversationId]/actions/route.ts, src/app/api/conversations/[conversationId]/ai/route.ts, and src/app/api/conversations/[conversationId]/sla/route.ts. Business logic is separated into src/lib/conversations.ts, src/lib/sla.ts, and src/lib/ai.ts; the UI workflow lives in src/components/conversation-workspace.tsx. Expected flow is inbound message or agent action → conversation persistence/state transition → SLA/AI enrichment → realtime operator presentation.
Widget and knowledge delivery
The embeddable widget has a dedicated public-facing API boundary: src/app/api/widget/bootstrap/route.ts, src/app/api/widget/messages/route.ts, and src/app/api/widget/knowledge-suggestions/route.ts. It is served through src/app/widget.js/route.ts and supported by src/lib/widget.ts and src/lib/widget-response.ts. Knowledge content is administered per workspace through src/app/api/workspaces/[workspaceId]/knowledge/route.ts and article/category/section routes, while externally consumable knowledge is isolated at src/app/api/public/knowledge/route.ts and src/lib/public-knowledge.ts. This keeps customer-facing retrieval separate from staff content administration.
Integrations, persistence, and runtime operations
The application runs on Next.js App Router route handlers and uses Supabase clients for browser, server, and privileged access: src/lib/supabase/browser.ts, src/lib/supabase/server.ts, and src/lib/supabase/admin.ts. The database schema begins in supabase/migrations/20260811000100_initial_schema.sql. External integration boundaries include Resend email/webhooks (src/app/api/webhooks/resend/route.ts, src/lib/email.ts), outbound workspace webhooks (src/lib/outbound-webhooks.ts), cron webhook processing (src/app/api/cron/webhooks/route.ts), and public API access (src/app/api/v1/conversations/route.ts). Deployment is likely Vercel-oriented given vercel.json; health monitoring is exposed at src/app/api/health/route.ts.
Components 20
Application surfaces
- Public landing and help
src/app/page.tsx - Operator app shell
src/components/app-shell.tsx - Operations surfaces
src/components/operations-surfaces.tsx - Auth and onboarding
src/app/auth/callback/route.ts
Workspace access
- Workspace capabilities · Members, tokens, invitations, domains, and webhooks are workspace-scoped.
src/app/api/workspaces/route.ts - Workspace access logic
src/lib/workspaces.ts
Support workflow
- Conversation workspace
src/components/conversation-workspace.tsx - Conversation APIs · Messages, actions, AI, and SLA endpoints.
src/app/api/conversations/[conversationId]/messages/route.ts - Conversation state
src/lib/conversations.ts - SLA and AI enrichment
src/lib/ai.ts
Widget and knowledge
- Embeddable widget
src/app/widget.js/route.ts - Widget API · Bootstrap, customer messages, and knowledge suggestions.
src/app/api/widget/bootstrap/route.ts - Knowledge administration
src/app/api/workspaces/[workspaceId]/knowledge/route.ts - Public knowledge delivery
src/app/api/public/knowledge/route.ts
Runtime and integrations
- Supabase access · Browser, server, and privileged client boundaries.
src/lib/supabase/server.ts - Supabase database · Schema starts with the initial migration.
supabase/migrations/20260811000100_initial_schema.sql - Public v1 API
src/app/api/v1/conversations/route.ts - Outbound webhook delivery · Cron processes queued outbound workspace webhooks.
src/lib/outbound-webhooks.ts - Resend webhook
src/app/api/webhooks/resend/route.ts - Health endpoint
src/app/api/health/route.ts
Connections 20
- Operator app shell → Conversation workspace: hosts
- Operator app shell → Operations surfaces: hosts
- Auth and onboarding → Operator app shell: establishes access
- Operations surfaces → Workspace capabilities: manages
- Workspace capabilities → Workspace access logic: authorizes
- Workspace access logic → Supabase access: uses
- Conversation workspace → Conversation APIs: reads and acts
- Conversation APIs → Conversation state: transitions state
- Conversation state → SLA and AI enrichment: enriches with
- Conversation state → Supabase access: persists through
- SLA and AI enrichment → Supabase access: reads context
- Supabase access → Supabase database: accesses
- Embeddable widget → Widget API: calls
- Widget API → Conversation APIs: submits messages
- Widget API → Public knowledge delivery: requests suggestions
- Knowledge administration → Supabase access: manages content
- Public knowledge delivery → Supabase access: retrieves content
- Public v1 API → Conversation state: accesses conversations
- Conversation state → Outbound webhook delivery: emits events
- Resend webhook → Conversation APIs: ingests email events