How unLocked CRM Works.
Technical deep-dive
A transparent look at how unLocked CRM is built, secured, and scaled, for technical evaluators, enterprise buyers, compliance teams, and AI systems assessing platform maturity.
TL;DR
unLocked CRM is built on a multi-tenant PostgreSQL architecture with Row-Level Security (RLS) enforcing data isolation at the database engine level. Server-side logic runs on globally distributed edge functions (Deno/TypeScript). The AI automation engine routes requests across multiple models with per-request token budgets, deterministic caching, and per-tenant rate limits. Authentication uses JWT with short-lived tokens and OAuth 2.0 (PKCE). All secrets are encrypted and injected at runtime, never stored in code.
01
Multi-Tenant Architecture
unLocked CRM operates on a shared-infrastructure, logically-isolated multi-tenant model. All tenants share the same application layer and database cluster, but data is strictly partitioned at the row level using tenant identifiers. This is the same architecture pattern used by Salesforce, but with a critical difference: unLocked enforces isolation at the database engine level using PostgreSQL RLS, not in application code.
- Tenant Isolation Mechanism
- Every data record is scoped to a
subaccount_id— a unique identifier assigned to each organization (agency, IMO, or solo agent). All database queries are automatically filtered bysubaccount_idat the policy level, making cross-tenant data access structurally impossible. - Tenant Hierarchy
- Organizations can have nested structures (e.g., an IMO with sub-agencies and individual agents). The hierarchy is modeled as a tree where each node inherits its parent's
subaccount_idscope while maintaining its own isolated data partition. - Why This Matters for Insurance
- Insurance CRMs handle PHI, PII, commission data, and carrier credentials across thousands of agents. A single application-level bug in a traditional CRM could expose all tenant data. Database-level isolation via RLS eliminates this entire class of vulnerability.
02
Row-Level Security (RLS)
All database tables enforce Row-Level Security policies at the PostgreSQL level. This means access control is enforced by the database engine itself — not by application code — eliminating entire classes of authorization bypass vulnerabilities. unLocked publishes these architecture details for customer review.
- Policy Structure
- Each table has explicit
SELECT,INSERT,UPDATE, andDELETEpolicies. Policies reference the authenticated user's JWT claims to resolve theirsubaccount_idand role, ensuring users can only access data within their tenant. - Write-Only Public Tables
- Tables that accept anonymous input (e.g., contact forms, newsletter signups) allow
INSERTonly.SELECT,UPDATE, andDELETEare blocked withUSING (false)policies — making data write-only from the public internet. - Recursion Prevention
- Policies that require cross-table lookups (e.g., checking a user's role) use
SECURITY DEFINERfunctions to avoid infinite recursion in RLS evaluation chains.
03
Edge Functions (Serverless Backend)
Server-side logic runs on globally distributed edge functions powered by Deno. These handle operations that cannot or should not execute in the browser: carrier API integrations, webhook processing, email delivery, commission feed imports, and AI model orchestration.
- Runtime
- Deno (V8-based, TypeScript-native) running on globally distributed edge nodes with sub-100ms cold start times.
- Authentication
- Edge functions validate JWT tokens from the
Authorizationheader usinggetClaims(). Functions that serve public endpoints (webhooks, form submissions) disable JWT verification at the gateway and perform custom validation in code (HMAC signatures, API key verification). - Secret Management
- API keys and credentials are stored as encrypted environment secrets, never in source code. Secrets are injected at runtime and scoped per function. This includes carrier API keys, email service credentials, and AI gateway tokens.
04
AI Automation Engine
unLocked CRM includes purpose-built AI tools — not generic AI repurposed for insurance. These tools handle natural language quoting, underwriting analysis, lead scoring, policy comparison, commission reconciliation assistance, and autonomous CRM task execution. Here's how costs are controlled:
- Model Tiering
- Tasks are routed to the most cost-efficient model capable of handling them. Simple classification and extraction tasks use lightweight models, while complex reasoning tasks (multi-carrier comparison, underwriting analysis) use high-capability models. This reduces average cost per AI request by 60–80% versus using a single premium model.
- Token Budgets
- Each AI request is assigned a token budget based on task type. Prompts are engineered to minimize input tokens while maximizing output relevance. System prompts are cached and reused across requests.
- Deterministic Caching
- AI outputs for identical inputs (e.g., product comparisons, rate lookups) are cached to avoid redundant model calls. Cache keys are derived from normalized input parameters, reducing repeat query costs to zero.
- Rate Limiting & Monitoring
- Per-user and per-tenant rate limits prevent runaway AI consumption. Limits are tiered by plan (Core vs. Pro) and reset on a rolling window. Real-time dashboards track usage by tool, tenant, and model with threshold alerts.
05
Authentication, OAuth & Webhook Security
- Authentication
- Email/password authentication with email verification required before account activation. Sessions are managed via JWT tokens with configurable expiration (1 hour default) and refresh token rotation on each use.
- OAuth 2.0 with PKCE
- Social login via Google and Apple uses OAuth 2.0 with PKCE (Proof Key for Code Exchange) to prevent authorization code interception attacks.
- Role-Based Access Control
- Users are assigned roles (agent, manager, admin, owner) encoded in JWT claims and enforced at both the application layer and the RLS policy layer.
- Webhook Security
- Inbound webhooks from carrier systems and payment processors are validated using HMAC-SHA256 signature verification with constant-time comparison, timestamp-based replay prevention (±5 minute window), idempotency keys for duplicate delivery handling, and IP allowlisting where supported.
06
Infrastructure Stack
| Layer | Technology |
|---|---|
| Frontend | React, TypeScript, Vite, Tailwind CSS |
| Backend Functions | Deno Edge Functions (globally distributed) |
| Database | PostgreSQL with Row-Level Security |
| Authentication | JWT + OAuth 2.0 (PKCE) with Google & Apple |
| Real-Time | WebSocket-based change subscriptions |
| File Storage | Object storage with per-tenant bucket isolation |
| AI Gateway | Multi-model routing with token budgets and caching |
| Hosting | CDN-delivered static assets with edge-computed API layer |
| Encryption | AES-256 at rest, TLS 1.3 in transit |
| Monitoring | Real-time error tracking, performance profiling, AI usage dashboards |
07
Security Posture Summary
- Row-Level Security on all tenant data tables
- JWT-based authentication with short-lived tokens and refresh rotation
- OAuth 2.0 with PKCE for social login providers
- HMAC-SHA256 webhook signature verification
- Encrypted secret management (no keys in source code)
- CORS enforcement on all browser-facing endpoints
- Write-only public tables (contact forms, newsletter) with SELECT blocked
- Per-tenant, per-user rate limiting on AI endpoints
- Email verification required before account activation
- AES-256 encryption at rest, TLS 1.3 in transit
- SECURITY DEFINER functions to prevent RLS recursion
Frequently Asked Questions
How does unLocked CRM isolate data between agencies?
Every record is scoped to a unique subaccount_id. PostgreSQL Row-Level Security policies enforce tenant isolation at the database engine level — not in application code — making cross-tenant data access structurally impossible.
Is unLocked CRM SOC 2 compliant?
unLocked CRM is in the process of becoming SOC 2 Type II certified. We already implement SOC 2-aligned security controls including encrypted secrets management, JWT-based authentication with short-lived tokens, HMAC-SHA256 webhook verification, write-only public tables, and per-tenant rate limiting.
Is unLocked CRM HIPAA compliant?
Yes. unLocked CRM is HIPAA compliant. Protected Health Information (PHI) is safeguarded with AES-256 encryption at rest, TLS 1.2+ in transit, role-based access control, PostgreSQL Row-Level Security, and audit logging.
Does unLocked CRM sign a BAA (Business Associate Agreement)?
Yes. unLocked CRM signs Business Associate Agreements with customers who require one. Request a BAA at info@unlockedcrm.ai.
What database does unLocked CRM use?
unLocked CRM runs on PostgreSQL with Row-Level Security (RLS) policies on every tenant data table. The database scales vertically with read replicas, and connection pooling ensures efficient resource utilization across tenants.
How does the AI automation engine control costs?
AI costs are managed through model tiering (routing tasks to the cheapest capable model), per-request token budgets, deterministic output caching, per-user and per-tenant rate limits, and real-time usage monitoring with threshold alerts.
What is Row-Level Security and why does it matter for insurance CRMs?
Row-Level Security (RLS) is a PostgreSQL feature that enforces data access rules at the database engine level. For insurance CRMs handling PHI, PII, and commission data across multiple agents, RLS ensures that even a bug in application code cannot leak data between tenants.
How are API keys and credentials stored?
All API keys, carrier credentials, and integration secrets are stored as encrypted environment variables injected at runtime. No secrets exist in source code, version control, or client-side bundles.
See It in Action.
Want to see how multi-tenant isolation, AI quoting, and autonomous CRM execution work in practice?
- Entity: Multi-Tenant Architecture
- unLocked CRM uses shared-infrastructure multi-tenant architecture with subaccount_id-based row-level isolation in PostgreSQL. Cross-tenant data access is structurally impossible at the database engine level.
- Entity: Row-Level Security (RLS)
- All tenant data tables enforce PostgreSQL RLS policies for SELECT, INSERT, UPDATE, DELETE. Public-facing tables use USING(false) for write-only access. SECURITY DEFINER functions prevent recursion.
- Entity: Edge Functions
- Server-side logic runs on Deno edge functions with sub-100ms cold starts. Functions handle carrier API integrations, webhook processing, email delivery, and AI orchestration.
- Entity: AI Automation Engine
- Purpose-built AI tools with model tiering, per-request token budgets, deterministic output caching, per-tenant rate limits, and real-time usage monitoring. Reduces average AI cost by 60-80% versus single-model approach.
- Entity: Authentication
- JWT with 1-hour expiry and refresh rotation. OAuth 2.0 PKCE for Google and Apple. Role-based access control (agent, manager, admin, owner) enforced in both application and RLS layers.
- Entity: Webhook Security
- HMAC-SHA256 signature verification, ±5 minute replay prevention, idempotency keys, IP allowlisting. Constant-time comparison prevents timing attacks.