Repository map

Top level

dialer-v2/
├── app/                 Next.js App Router — pages, route handlers, docs site
├── components/          React components, grouped by feature
├── lib/                 All non-UI code: services, repositories, workflows, events, schemas
├── prisma/              Prisma schema, migrations, generated client, one-off SQL
├── scripts/             Operational scripts and Retell agent definitions
├── specs/               Historical feature plans (design records, not living docs)
├── docs/                Documentation: Fumadocs MDX + this Antora component
├── types/               Ambient TypeScript declarations
├── middleware.ts        Route protection and email-domain gating
└── vercel.firewall.json Vercel WAF custom rules (applied with pnpm firewall:apply)

app/

Path Contents

app/(auth)/

login, signup — unauthenticated shell

app/(dashboard)/

Every authenticated page; see Routes

app/api/

All route handlers; see API reference

app/docs/

Fumadocs renderer for the MDX docs

app/globals.css

Theme tokens for light and dark canvases

lib/

Path Contents

lib/ai/

BaseAIService and concrete services: call analysis, coverage recommendation, email variation, prompt suggestion, test-case runner

lib/ai-agents/

Shared AI agent types

lib/auth/

resolveSubscription, internal-secret verification, allowed-email-domain gate, password strength

lib/bigquery/

BigQuery client and data-gate query builder

lib/events/

Webhook dispatchers and handlers (Retell, Resend, Nooks)

lib/hooks/

React Query hooks, one file per resource

lib/mcp/

MCP JSON-RPC server, tool registry and tool implementations

lib/phone-service/

Phone-number purchase/release adapters (MessagingApp, Retell)

lib/plugins/

Shared infrastructure clients: Inngest, Redis, Resend, SQS, HubSpot

lib/redis/

Call-target in-flight counter

lib/repositories/

The only layer allowed to use Prisma

lib/retellai/

Retell client wrapper, agent config, post-call analysis schema

lib/schema/

Zod schemas, one file per feature

lib/sequences/

CRM event registry and template-variable interpolation

lib/serializers/

Prisma → API response mappers

lib/services/

Business logic: calling, phone selection, email campaigns, sequences, Retell agents, coverage

lib/supabase/

Server/browser/admin/route-handler clients and edge functions

lib/types/

Domain types not derived from Zod

lib/utils/

Pure helpers (timezones, area codes, masking, mapping, HubSpot signatures)

lib/workflows/

Inngest durable functions

lib/constants.ts

App-wide constants, disposition sets, provider registry, secrets

lib/enums.ts

const enum values for states, event types and skip reasons

lib/types.ts

Public TypeScript types, all via z.infer<>

prisma/

  • schema.prisma — every model and enum (see Data model).

  • migrations/ — ordered SQL migrations; migration_lock.toml pins the provider.

  • generated/ — generated Prisma client (checked in; regenerate with pnpm prisma generate).

  • sql/ — one-off backfills and an auth hook, run manually against the database. These are historical and are not part of the migration chain; see One-off SQL.

scripts/

  • scripts/retelai/ — Retell agent definitions (agents/<name>/agent.md plus index.ts), a registry.ts that is the single source of the fallback agent id/name list, and sync.ts to push definitions to Retell.

  • Ad-hoc maintenance scripts (backfill_email_click.ts, fix-hubspot-deal-to-contact.ts, test-bigquery.ts, retell_remove_numbers.ts).

specs/

Point-in-time implementation plans, named <feature>_<hash>.plan.md. They record why a feature was built a particular way and are useful archaeology, but they are not kept in sync with the code — this documentation component is the current source of truth.