How outperosys/outpero-crm works
1. This is a monolithic Next.js App Router CRM application. The UI, server-side data access, mutations, and a small set of API endpoints all live in one repo rather than being split into separate frontend/backend services.
2. The application is organized around two route groups: an auth area under app/(auth) and the main CRM workspace under app/(crm). The CRM group contains the product’s major screens: dashboard, leads, pipeline, activity, meetings, follow-ups, tasks, services, settings, and financial documents.
3. Authentication appears to be built around Supabase, with both client and server helpers in lib/supabase/*, plus lib/auth.ts and proxy.ts likely enforcing session-based route protection and redirecting unauthenticated users to /login.
4. The main data layer uses Prisma. prisma/schema.prisma, the migration history, lib/prisma.ts, and prisma/seed.ts indicate a relational database-backed domain model with seeded reference data and incremental schema evolution for leads, activities, tasks, follow-ups, proposals, meetings/transcripts, invoices, receipts, services, tags, and settings.
5. User actions are concentrated in the actions/ folder. These server actions are the primary mutation boundary for the app: they handle CRUD and workflow operations for leads, activities, notes, tasks, meetings, follow-ups, invoices, receipts, proposals, proposal templates, services, tags, settings, dashboard data, auth, and AI-assisted features.
6. The frontend is split into route-level pages and reusable feature components. Pages in app/(crm)/* assemble feature-specific components from components/*, with many client-side interactive pieces for dialogs, tables, boards, forms, and quick actions. components/ui/* is the shared design-system layer.
7. The lead domain is the central business object. Lead detail screens pull together related subdomains: activities, notes, tasks, meetings, follow-ups, proposals, and financial documents. This suggests the architecture is lead-centric, with other modules attached to a lead as contextual records rather than isolated workflows.
8. Dashboard and pipeline are analytics-heavy read surfaces. lib/dashboard/* contains scoring and insight logic, while dashboard components show pipeline snapshots, hot leads, financial overview, team snapshot, and AI insights. These screens are derived views over the core CRM data rather than separate datasets.
9. Financial documents are treated as first-class generated artifacts. Invoices and receipts have dedicated create/view/update screens, plus API routes under app/api/financial/.../pdf that generate downloadable PDFs. Supporting code in lib/pdf/* and lib/invoice/utils.ts indicates document rendering is handled server-side from structured business data.
10. AI is an explicit subsystem, not just an incidental helper. lib/ai/* contains OpenAI wiring, prompts, context builders, and placeholder handling; feature components such as follow-up generators, proposal generators, and meeting transcript tools indicate AI is used for drafting, summarization, and document assistance.
11. Proposals and proposal templates form a separate document-authoring workflow. Template management, section editing, and the proposal workspace imply a structured content model for reusable sales/proposal content, with lib/proposal/* and lib/pdf/proposal-document.tsx supporting rendering and export.
12. The app has a strong validation boundary. lib/validations/* centralizes schema checks for each domain entity, which likely protects server actions and keeps form inputs, mutations, and database writes consistent across the feature set.
13. Overall data flow is: authenticated user enters the Next.js app, server-rendered pages fetch domain data through Prisma-backed helpers/actions, interactive client components submit mutations through server actions, and a few specialized API routes generate PDFs or other exportable outputs. The important architectural boundaries are auth/session handling, domain actions, database persistence, AI services, and PDF/document generation.
Main entry points: layout.tsx CRM layout · actions Server actions · [id]/page.tsx Lead detail · dashboard/page.tsx Dashboard
Components 27
Auth
Login and session protection
- Login · Public sign-in screen
app/(auth)/login/page.tsx - Session auth · Supabase client/server helpers and route protection
lib/auth.ts - Supabase · Client and server session integration
lib/supabase
CRM workspace
Main authenticated product routes
- App shell · Global app entry and shared layout
app/layout.tsx - CRM layout · Authenticated shell for the CRM area
app/(crm)/layout.tsx - Dashboard · Analytics and operational overview
app/(crm)/dashboard/page.tsx - Leads · Lead list and management
app/(crm)/leads/page.tsx - Lead detail · Lead-centric workspace with related records
app/(crm)/leads/[id]/page.tsx - Pipeline · Board view for lead flow
app/(crm)/pipeline/page.tsx - Activity · Recent CRM activity feed
app/(crm)/activity/page.tsx - Meetings · Meeting schedule and transcripts
app/(crm)/meetings/page.tsx - Follow-ups · Follow-up queue and completion workflow
app/(crm)/follow-ups/page.tsx - Tasks · Task management surface
app/(crm)/tasks/page.tsx - Services · Service catalog management
app/(crm)/services/page.tsx - Settings · Workspace configuration form
app/(crm)/settings/page.tsx - Financial · Invoices and receipts area
app/(crm)/financial/page.tsx
Core services
Shared server-side business logic
- Server actions · CRUD and workflow mutations for CRM domains
actions - Validation · Domain input validation boundary
lib/validations - Dashboard logic · Scoring and insight derivation
lib/dashboard - AI services · OpenAI prompts, context, and generation helpers
lib/ai
Data layer
Database schema and persistence
Documents
PDF and proposal rendering
- Proposal tools · Proposal templates, renderer, and workspace support
lib/proposal - PDF output · Server-side PDF generation for financial and proposal docs
lib/pdf - Invoice PDF API · Download endpoint for invoice PDFs
app/api/financial/invoices/[id]/pdf/route.ts - Receipt PDF API · Download endpoint for receipt PDFs
app/api/financial/receipts/[id]/pdf/route.ts
Connections 39
- App shell → Login: public auth · Routes unauthenticated users to login
- App shell → CRM layout: workspace shell · Hosts authenticated CRM routes
- Session auth → Supabase: sessions · Wraps Supabase for client and server auth
- CRM layout → Session auth: protects · Requires a valid session before entering the workspace
- CRM layout → Dashboard: entry · Loads dashboard as a primary authenticated screen
- CRM layout → Leads: routes · Provides navigation to the lead list
- CRM layout → Lead detail: routes · Provides navigation to lead detail views
- CRM layout → Pipeline: routes · Provides navigation to the pipeline board
- CRM layout → Activity: routes · Provides navigation to the activity feed
- CRM layout → Meetings: routes · Provides navigation to meetings
- CRM layout → Follow-ups: routes · Provides navigation to follow-up workflows
- CRM layout → Tasks: routes · Provides navigation to tasks
- CRM layout → Services: routes · Provides navigation to service catalog management
- CRM layout → Settings: routes · Provides navigation to workspace settings
- CRM layout → Financial: routes · Provides navigation to financial records
- Dashboard → Dashboard logic: reads · Derives scores, snapshots, and insights
- Dashboard → Server actions: fetches · Uses server actions for dashboard data
- Leads → Server actions: crud · List and mutate leads through server actions
- Lead detail → Server actions: workflows · Coordinates lead-related records and mutations
- Pipeline → Server actions: updates · Moves leads through pipeline stages
- Activity → Server actions: records · Reads and logs activities
- Meetings → Server actions: manages · Schedules and updates meetings and transcripts
- Follow-ups → Server actions: manages · Creates, completes, and drafts follow-ups
- Tasks → Server actions: crud · Task creation and status updates
- Services → Server actions: crud · Maintains the service catalog
- Settings → Server actions: updates · Saves workspace settings
- Financial → Server actions: bills · Creates and updates invoices and receipts
- Server actions → Validation: checks · Validates domain inputs before persistence
- Server actions → Prisma DB: writes · Persists CRM data through Prisma
- Prisma DB → Schema: models · Implements the schema-defined domain model
- Schema → Seed data: bootstraps · Seed script initializes reference data
- Lead detail → Proposal tools: proposals · Shows and edits proposal workflows from lead context
- Lead detail → PDF output: exports · Supports document rendering for financial/proposal artifacts
- Financial → Invoice PDF API: downloads · Invoice PDF export endpoint
- Financial → Receipt PDF API: downloads · Receipt PDF export endpoint
- Server actions → AI services: assists · Uses AI for drafting, summarization, and context-aware generation
- Lead detail → AI services: drafts · AI helpers support notes, follow-ups, and related workflows
- Dashboard → Prisma DB: aggregates · Reads core CRM data for analytics surfaces
- Proposal tools → PDF output: renders · Proposal workspace feeds PDF document generation