Skip to content

Supabase Edge Functions Specification

Overview

Supabase Edge Functions are the main service layer for the application. The codebase currently exposes a large function inventory organized by naming convention rather than by separate deployable services.

Shared Conventions

  • Shared helpers live in supabase/functions/_shared/
  • Most function names are domain-prefixed and act like module APIs
  • Several functions are configured with verify_jwt = false in supabase/config.toml, meaning auth is handled by webhook validation, custom bearer/API keys, or service-role access patterns
  • DB-heavy behavior is often delegated to shared DB wrappers or RPCs

Function Domains

AI and AI review

  • admin-ai-settings
  • agents-convo-response
  • agents-no-intent
  • ai-convo-thread-*
  • ai-no-intent-update-from-agent
  • ai-yes-intent-update-from-agent
  • ai-review-apply-data

Primary role: - admin control plane for AI toggles and prompt drafts - persistence of AI conversation state - callback/update endpoints used by Cloudflare Workers

Analytics and reporting

  • analytic-*
  • report-*
  • github-release-latest

Primary role: - event logging - report feeds and counts - app version lookup

Broadcast and campaign operations

  • broadcast-count
  • broadcast-search
  • campaign-*
  • campaign-lead-*
  • contact-counts
  • eligible-leads-search

Primary role: - campaign CRUD - campaign-lead search/send/delivery tracking - campaign metrics - broadcast-adjacent counts and search

Leads and customer records

  • lead-*
  • vehicle-*
  • warehouse-*
  • lvo-sales-milestones-read
  • sales-sheet-search

Primary role: - lead CRUD/search - addresses, phones, vehicles, audits, billing opportunities, follow-ups, and opportunity updates - sales-sheet data access

This is the largest domain in the function layer and effectively acts as the core CRM API.

Message Center and communications

  • message-*
  • thread-*
  • send-file
  • voicemail-drop
  • call-missed-answered
  • call-recording-transcript
  • transcribe-audio
  • twilio-message-*

Primary role: - inbound/outbound SMS - thread search/read/update - call logging, voicemail open flows, transcript handling - message media send and replay tooling

PBX and telephony helpers

  • lead-pbx-actions
  • lead-pbx-sms-actions
  • thread-call-dial
  • thread-update-last-call-user
  • thread-voicemail-open
  • phone-number-validate
  • groundwire-contacts

Primary role: - PBX-side webhook handoff - click-to-call preflight/analytics - thread activity synchronization with telephony events

Insurance workflows

  • insurance-company-phone-*
  • insurance-followup-reactivation
  • insurance-followups-categories
  • lead-followup-categories
  • query-followup-status

Primary role: - insurance provider phone management - insurance follow-up priority refresh and reactivation - read models used by navbar-driven follow-up workflows

General utility/config functions

  • get-all-app-enums
  • get-google-maps-key
  • geocoding-proxy
  • grammar-check
  • notification-*
  • settings-filter-*
  • store
  • user-create
  • work-order-management

Notable Entry Points

message-inbound

This is a high-importance function. It: - authenticates Twilio webhook traffic - normalizes inbound payloads - resolves thread/lead/message context - gates AI yes/no behavior using global settings and Phoenix-time windows - triggers OCR/extraction and summary-related flows

campaign-metrics

Provides real KPI/aggregate campaign data for broadcast analytics. Current implementation still uses placeholder conversion logic and does not provide a full real time-series backend.

thread-call-dial

Acts as the call preflight/guard path from the UI. It marks active caller state, prevents conflicting live-call ownership, and logs analytics before the PBX click-to-call URL is used.

admin-ai-settings

Admin-only control plane for: - yes/no agent enablement - AI active window - prompt draft persistence in Supabase

ocr-vision

Dual-purpose OCR endpoint: - user-facing VIN detection mode for image preview overlays - update/summary mode used by message/AI flows

As-Built Assessment

  • The function layer is broad and functional, but it is not small or tightly bounded
  • Several flows cross domains, especially Message Center + AI + telephony
  • Naming is generally consistent enough to navigate the system, but ownership would benefit from a formal function map by product surface
  1. message-inbound
  2. thread-* and message-*
  3. campaign-* and campaign-lead-*
  4. lead-*
  5. admin-ai-settings and AI callback functions