How bigc7292/ai_calling_centra works
Purpose and entry points
AI Calling Center is a multi-tenant calling-operations platform for campaigns, contacts, AI-assisted interactions, compliance, billing, CRM access, and analytics. Primary runtime entry points are the Next.js frontend at apps/frontend/src/app/page.tsx and Express API at services/core-api/src/index.ts. The repository also contains an alternate/legacy-looking App Router tree under apps/frontend/app/page.tsx and a small separate Next.js app under apps/web/app/api/team/route.ts.
Web application and access boundary
The frontend provides protected dashboard, contact, CRM, export, and settings experiences. Authentication is client-side Supabase Auth, with route gating before application content is exposed:
• apps/frontend/src/components/AuthGate.tsx
• apps/frontend/src/lib/supabaseClient.ts
• apps/frontend/src/app/dashboard/page.tsx
The dashboard-oriented tree also includes campaign authoring, lead upload, inbound-call monitoring, analytics visualization, and signup handling:
• apps/frontend/app/dashboard/page.tsx
• apps/frontend/app/dashboard/campaign-creator.tsx
• apps/frontend/app/api/signup/route.ts
Core API orchestration
services/core-api is the central server-side boundary for authenticated business APIs. Its auth module validates access, and quota middleware governs consumption before handlers reach data or external integrations:
• services/core-api/src/index.ts
• services/core-api/src/auth.ts
• services/core-api/src/middleware/quota-check.ts
Route groups organize core workflows: campaigns and bulk contacts, analytics, AI generation, CRM, compliance, billing, human handoff, scheduled jobs, and inbound/social webhooks:
• services/core-api/src/routes/campaigns.ts
• services/core-api/src/routes/analytics.ts
• services/core-api/src/routes/vapi-inbound.ts
Data, tenancy, and compliance
Supabase/PostgreSQL is the system of record, with Supabase Auth/JWT identity and database-level row-level security for tenant isolation. Schema evolution separates initial tenancy, contacts, campaigns, billing, analytics views, AI jobs, A/B fields, alerts, and team RBAC:
• supabase/migrations/000_init.sql
• supabase/migrations/010_rbac_teams.sql
• supabase/policies/all_rls_updates.sql
Supabase Edge Functions handle asynchronous or privileged data operations, including transcript analysis, DNC scrubbing/monitoring, PII erasure, and Stripe webhook processing:
• supabase/functions/analyze_transcript/index.ts
• supabase/functions/bulk_dnc_scrub/index.ts
• supabase/functions/process_stripe_webhook/index.ts
Campaign execution and integrations
Campaign execution is separated into worker processes, while shared libraries encapsulate queues, AI, communication, payments, cache, RBAC, and blockchain clients:
• worker/campaign-executor-update.ts
• lib/campaign-queue.ts
• lib/gemini-script-gen.ts
External service boundaries include Gemini for scripts/insights and inbound analysis, Vapi for inbound calling, Stripe billing, Redis caching/queues, Frappe-style CRM connectivity, and an audit smart contract:
• services/core-api/src/routes/ai.ts
• services/core-api/src/routes/crm.ts
• contracts/AICallingAudit.sol
Deployment and shared packages
The monorepo uses PNPM workspaces with shared types, configuration, and UI packages:
• pnpm-workspace.yaml
• packages/types/src/index.ts
• packages/config/src/index.ts
Production deployment targets Google Cloud Build and Cloud Run containers. API and infrastructure container definitions are explicit:
• cloudbuild.yaml
• infra/cloud-run.yaml
• services/core-api/Dockerfile
Main entry points: index.ts Core API · 000_init.sql Supabase PostgreSQL · quota-check.ts Quota checks · vapi-inbound.ts AI, CRM & inbound routes
Components 22
Web apps
- Next.js frontend · Protected operations dashboard and customer workflows.
apps/frontend/src/app/page.tsx - Auth gate · Gates application content using Supabase sessions.
apps/frontend/src/components/AuthGate.tsx - Dashboard workflows · Campaign authoring, uploads, inbound monitoring, and analytics.
apps/frontend/app/dashboard/page.tsx - Signup endpoint
apps/frontend/app/api/signup/route.ts
Core platform
- Core API · Authenticated business API and integration boundary.
services/core-api/src/index.ts - API auth · Validates access tokens before business routes.
services/core-api/src/auth.ts - Quota checks · Enforces tenant consumption limits.
services/core-api/src/middleware/quota-check.ts - Campaign APIs · Campaign and bulk-contact operations.
services/core-api/src/routes/campaigns.ts - Analytics APIs
services/core-api/src/routes/analytics.ts - AI, CRM & inbound routes · Connects AI generation, CRM, and Vapi inbound webhooks.
services/core-api/src/routes/vapi-inbound.ts
Execution & data
- Campaign executor · Runs campaign execution outside request handling.
worker/campaign-executor-update.ts - Campaign queue
lib/campaign-queue.ts - Supabase PostgreSQL · Tenant data, billing, contacts, campaigns, and analytics under RLS.
supabase/migrations/000_init.sql - Tenant RLS & RBAC · Database-enforced tenant isolation and team roles.
supabase/policies/all_rls_updates.sql - Supabase Edge Functions · Transcript analysis, DNC operations, PII erasure, and Stripe webhooks.
supabase/functions/analyze_transcript/index.ts - Cloud Run deployment · Container deployment for the API and infrastructure.
infra/cloud-run.yaml
External services
- Gemini · Script generation and interaction insights.
- Vapi · Inbound calling integration.
- Stripe
- Redis
- Frappe-style CRM
- Audit smart contract
contracts/AICallingAudit.sol
Connections 24
- Next.js frontend → Auth gate: protects dashboard
- Auth gate → Supabase PostgreSQL: Supabase Auth/JWT
- Dashboard workflows → Next.js frontend: dashboard experience
- Signup endpoint → Supabase PostgreSQL: creates signup data
- Next.js frontend → Core API: authenticated API calls
- Core API → API auth: authenticates
- API auth → Quota checks: authorized requests
- Quota checks → Campaign APIs: campaign workflow
- Quota checks → Analytics APIs: analytics workflow
- Quota checks → AI, CRM & inbound routes: integration workflow
- Campaign APIs → Campaign queue: enqueues execution
- Campaign queue → Campaign executor: dispatches jobs
- Campaign executor → Redis: queue/cache backend
- Campaign executor → Supabase PostgreSQL: reads and records campaigns
- Core API → Supabase PostgreSQL: tenant business data
- Supabase PostgreSQL → Tenant RLS & RBAC: enforces access policies
- AI, CRM & inbound routes → Gemini: AI scripts and insights
- AI, CRM & inbound routes → Vapi: inbound webhooks
- AI, CRM & inbound routes → Frappe-style CRM: CRM access
- Core API → Stripe: billing operations
- Stripe → Supabase Edge Functions: payment webhooks
- Supabase Edge Functions → Supabase PostgreSQL: privileged async updates
- Core API → Audit smart contract: audit records
- Cloud Run deployment → Core API: runs containerized API