How ranjeetj06/management works
1. Overall shape
- This is a Next.js 14 App Router application backed by Supabase.
- The app is organized around a multi-workspace CRM/business diary: users sign in, join or create a workspace, and then operate only on data belonging to that organization.
2. Top-level route boundaries
- src/app/(auth) contains the public authentication flow: login and signup.
- src/app/onboarding handles first-time workspace setup after signup.
- src/app/(app) is the authenticated application shell with the main sidebar/layout and all business modules.
3. Authenticated application shell
- src/app/(app)/layout.tsx is the structural boundary for the logged-in area.
- It likely combines auth gating, navigation, and workspace context so all child pages inherit the same shell.
- This shell hosts the operational modules: dashboard, contacts, interactions, deals, leads, pipeline, accounts, tickets, tasks, team, settings, reports, and more.
4. Core business domains
- The central data domains are:
- Contacts: suppliers, buyers, partners
- Interactions: dated diary entries with location, summary, follow-up, and line items
- Deals: firm orders with payment status
- Categories: product taxonomy
- Supporting operational modules include leads, accounts, tickets, tasks, team, communications, documents, knowledge, calendar, and reports.
5. Entity lifecycle routes
- Most primary entities use a consistent CRUD pattern under /(app)/<entity>:
- list page
- new page
- [id] detail page
- [id]/edit page
- This pattern exists for contacts, interactions, deals, accounts, knowledge articles, tickets, and leads, which makes the architecture page-driven and domain-centric rather than API-centric.
6. Specialized workspace views
- Some modules are not simple CRUD pages and act as workspace dashboards or boards:
- leads-board.tsx
- pipeline-board.tsx
- tasks-manager.tsx
- team-manager.tsx
- categories-manager.tsx
- These suggest more interactive, stateful views for organizing records rather than just editing them.
7. Component layer
- src/components holds reusable UI and domain forms.
- There are generic UI primitives in components/ui and domain-specific forms/managers such as contact-form, deal-form, interaction-form, lead-form, ticket-form, automation-manager, communications-manager, documents-manager, integrations-manager, and email-templates-manager.
- This separation implies the app is built from shared primitives plus domain-specific screens.
8. Data access and business logic
- src/lib contains the main non-UI logic:
- Supabase client/server/admin setup
- org and member helpers
- active organization resolution
- CSV export helpers
- reporting and activity helpers
- lead/ticket-related utilities
- src/lib/types.ts likely provides schema-derived TypeScript types that unify client and server code around the Supabase data model.
9. Supabase as the backend boundary
- supabase/migrations defines the actual backend schema and permissions model.
- The data model centers on:
- organizations
- members
- invitations
- categories
- contacts
- interactions and interaction_items
- deals and deal_items
- Row Level Security is a core boundary: each workspace only sees its own rows.
10. Authentication and session flow
- Auth supports email/password, magic link, and Google sign-in.
- src/app/auth/callback/route.ts is the landing point for OAuth and magic-link callbacks.
- src/middleware.ts and src/lib/supabase/middleware.ts handle session refresh/cookie management so authenticated navigation stays consistent.
11. Workspace and team management
- Workspace membership is first-class: users can create a workspace, switch workspaces, and leave a workspace via API routes.
- Team invites are handled through dedicated routes under src/app/api/invitations and src/app/api/invite.
- The README indicates invitation acceptance is tied to signup and database triggers, so team onboarding is partially automated at the backend layer.
12. API surface
- The API routes are narrow and support supporting operations rather than general CRUD:
- CSV export for contacts, deals, interactions, leads, accounts, reports
- invitation accept/decline
- invite creation
- workspace switch/leave
- This means most business data interaction is likely done through server components/forms and Supabase directly, with APIs reserved for cross-cutting actions.
13. External services and deployment
- The app depends materially on Supabase for auth, database, RLS, and invitation/workspace behavior.
- The README describes deployment on Vercel, with environment variables for Supabase URL, anon key, and site URL.
- Google OAuth is optional but affects the auth boundary when enabled.
14. What an architecture diagram should emphasize
- Show three main zones:
- Public auth/onboarding
- Authenticated workspace app
- Supabase backend
- Then connect the app to Supabase through:
- auth/session handling
- organization-scoped data access
- invite/workspace APIs
- export/reporting paths
- The app is not a single monolith of screens; it is a workspace-scoped CRUD + board UI over a Supabase schema with RLS.
Main entry points: layout.tsx App shell · contact-form.tsx Domain forms · server.ts Supabase helpers · 0001_init.sql Schema & RLS
Components 27
Public auth
Sign-in, signup, callback, and first-run workspace setup.
- Home · Public landing route that funnels users into auth or onboarding.
src/app/page.tsx - Auth shell · Shared layout for login and signup routes.
src/app/(auth)/layout.tsx - Login · Email/password, magic-link, and Google sign-in entry.
src/app/(auth)/login/page.tsx - Signup · Account creation flow that leads into workspace onboarding.
src/app/(auth)/signup/page.tsx - Auth callback · Landing route for OAuth and magic-link callbacks.
src/app/auth/callback/route.ts - Onboarding · First-run workspace setup after signup.
src/app/onboarding/page.tsx
Workspace app
Authenticated App Router shell and business modules.
- App shell · Authenticated workspace boundary that wraps all business modules.
src/app/(app)/layout.tsx - Dashboard · Workspace landing page and operational summary.
src/app/(app)/dashboard/page.tsx - Contacts · Workspace-scoped contact records with list/new/detail/edit routes.
src/app/(app)/contacts/page.tsx - Interactions · Diary-style interaction records with items and follow-up context.
src/app/(app)/interactions/page.tsx - Deals · Firm-order records with payment and line-item structure.
src/app/(app)/deals/page.tsx - Leads · Lead management with a board-oriented workspace view.
src/app/(app)/leads/leads-board.tsx - Pipeline · Deal pipeline board for moving opportunities through stages.
src/app/(app)/pipeline/pipeline-board.tsx - Tasks · Stateful task management workspace.
src/app/(app)/tasks/tasks-manager.tsx - Team · Team and membership management workspace.
src/app/(app)/team/team-manager.tsx - Settings · Workspace settings hub including automation, integrations, and roles.
src/app/(app)/settings/page.tsx - Categories · Product and classification taxonomy management.
src/app/(app)/categories/categories-manager.tsx - Communications · Communication tools and email templates.
src/app/(app)/communications/page.tsx - Documents · Workspace document management area.
src/app/(app)/documents/page.tsx - Knowledge · Knowledge base articles with list/new/detail/edit routes.
src/app/(app)/knowledge/page.tsx - Tickets · Support ticket records with a dedicated workspace view.
src/app/(app)/tickets/page.tsx - Reports · Workspace reporting and export-oriented view.
src/app/(app)/reports/page.tsx - API actions · Narrow API surface for exports, invitations, and workspace switching.
src/app/api/export/contacts/route.ts - Domain forms · Reusable domain forms and managers used by CRUD pages and workspace tools.
src/components/contact-form.tsx
Data layer
Shared server/client helpers and Supabase backend schema.
- Supabase helpers · Client, server, middleware, org, member, report, CSV, and activity helpers.
src/lib/supabase/server.ts - Schema types · Shared TypeScript types derived from the backend schema.
src/lib/types.ts - Schema & RLS · Workspace schema, permissions, invitations, and row-level security rules.
supabase/migrations/0001_init.sql
Connections 32
- Home → Auth shell: routes to · Public users enter the auth shell.
- Auth shell → Login: contains · Login is a child route of the auth shell.
- Auth shell → Signup: contains · Signup is a child route of the auth shell.
- Login → Auth callback: auth returns via · OAuth and magic-link completion lands in the callback route.
- Signup → Onboarding: continues to · New users are guided into workspace setup.
- Auth callback → Supabase helpers: session handled by · Callback processing relies on Supabase auth/session helpers.
- Onboarding → Schema & RLS: creates workspace in · First-run setup persists workspace state in the backend schema.
- App shell → Dashboard: hosts · The authenticated shell wraps the main dashboard.
- App shell → Contacts: hosts · Contacts live inside the workspace shell.
- App shell → Interactions: hosts · Interactions live inside the workspace shell.
- App shell → Deals: hosts · Deals live inside the workspace shell.
- App shell → Leads: hosts · Leads board lives inside the workspace shell.
- App shell → Pipeline: hosts · Pipeline board lives inside the workspace shell.
- App shell → Tasks: hosts · Tasks manager lives inside the workspace shell.
- App shell → Team: hosts · Team manager lives inside the workspace shell.
- App shell → Settings: hosts · Settings pages live inside the workspace shell.
- App shell → Categories: hosts · Categories manager lives inside the workspace shell.
- App shell → Communications: hosts · Communications tools live inside the workspace shell.
- App shell → Documents: hosts · Document management lives inside the workspace shell.
- App shell → Knowledge: hosts · Knowledge articles live inside the workspace shell.
- App shell → Tickets: hosts · Support tickets live inside the workspace shell.
- App shell → Reports: hosts · Reporting lives inside the workspace shell.
- Contacts → Domain forms: uses · CRUD pages reuse domain forms and primitives.
- Interactions → Domain forms: uses · Interaction pages reuse domain forms and primitives.
- Deals → Domain forms: uses · Deal pages reuse domain forms and primitives.
- Leads → Domain forms: uses · Lead pages and boards reuse domain forms and managers.
- Tickets → Domain forms: uses · Ticket pages reuse ticket-specific forms and workspace UI.
- API actions → Supabase helpers: delegates to · API routes use shared server helpers and workspace resolution.
- API actions → Schema & RLS: enforces · Invite, export, and workspace actions rely on the backend schema and permissions.
- Supabase helpers → Schema types: shares model · Helpers and UI share schema-derived types.
- Supabase helpers → Schema & RLS: reads/writes · Server helpers operate against the Supabase schema and RLS boundary.
- Schema types → Schema & RLS: derived from · Types mirror the underlying database model.