Field Notes · Aventary Exclusive

Build the whole product in six layers.How anyone builds a scalable, secure, and governed product.

Every serious product is built in the same six layers. This is the full operating stack — what belongs in each layer, and what makes it scale, stay secure, and stay governed. Tap a layer to see what runs there; the reference tools, how I've built each in production, the operating rules, and how to measure it are underneath.

Three properties every serious product needs
ScalableGrows without breaking. Data & retrieval · background jobs · events · infrastructure · edge/CDN · automated delivery.
SecureClosed by default. Authentication · tenant isolation (RLS) · least-privilege permissions · managed secrets · edge protection.
GovernedProvable and controlled. AI guardrails · evals · audit logs · monitoring · compliance · outcome measurement.
The stack, top to bottom

The six layers

How to read this page
  1. Start with the six layers. Tap any number to expand it and see what runs in that layer.
  2. Open the detail only if you want it. The full comparison, the operating rules, and the client harness are collapsed below.
  3. End at the bottom. "How to measure AI" is the thinking that ties it together.
1Interface & Engagement what people see and touch
webReact · Next.js · Tailwind
adminCustom internal views
paymentsStripe
2Application & Workflows logic, jobs, integrations
backend / apiVercel fns · CF Workers · edge fns
integrationsVantaca · Salesforce · Apollo
workflowsn8n
background jobspg_cron · sweep jobs
events / queues— not used
3Intelligence (AI) models, agents, evals, prompts
modelsAnthropic API · AWS Bedrock
gatewayCustom server-side proxy
guardrailsZod · policy checks
agentsRetell · orchestrator · MCP
evalsRetell + n8n eval flows
promptsSalesforce Prompt Builder
vector / rag— not confirmed
4Data storage, access, isolation, retrieval
databasePostgreSQL / Supabase
data accessPrisma · Supabase client
isolationPostgres RLS + test
searchSecond Brain · Drive
filesGoogle Drive · uploads
5Identity & Access who gets in, who can do what
authSupabase Auth · middleware gate
permissionsRLS owner_id policies
6Platform & Delivery where it runs, how it ships, how it's watched
deployGitHub Actions · Vercel · CF
edgeCloudflare (tunnel · Pages · WAF)
infraDigitalOcean · Vercel · Supabase
infra-as-codedocker-compose · Caddyfile
secretsVercel / env (server-side)
monitoringDatadog · testing · audit logs
The proof

The full breakdown

Reference stack vs. what I've shipped 35 layers
LayerRecommendedCodex / Claude CodeWhat I usedEvidence
Web interfaceNext.js, React, Tailwind, shadcn/uiYesReact, Next.js, TS, TailwindFundingo & SLP package.json
Admin interfaceRetool → custom Next.jsYesCustom internal viewssecond-brain VantacaControlsView.jsx
Backend / APINext.js API routes → NestJSYesVercel fns · CF Workers · edge fnssecond-brain/api/*.js
DatabasePostgreSQL / Supabase / RDSYesSupabase Postgres; self-host on AWSmultiple projects; SLP self-host
Data accessPrisma ORMYesPrisma (SQLite) + Supabase clientFundingo package.json
Tenant isolationPostgres RLS + policiesYesRLS + mandatory isolation testSLP CLAUDE.md §4; insert-only RLS
PermissionsWorkOS RBAC → OpenFGAYesRLS owner_id policiessecond-brain schema.sql; SLP auth.uid()
AuthenticationWorkOS AuthKitYesSupabase Auth · middleware gatetrip _middleware.js; SLP in-mem JWT
AI modelsOpenAI → Anthropic & BedrockYesAnthropic API + AWS Bedrockapi/claude.js; SLP voice server.js
Model gatewayLiteLLM → customYesCustom server-side proxyapi/claude.js (server-side key)
AI guardrailsOpenAI guardrails + ZodYesZod + HIPAA policy checksFundingo zod; SLP CLAUDE.md §0
Agent frameworkOpenAI Agents / Vercel AI SDKYesRetell · orchestrator · MCPapi/orchestrator-run.js; ~/vantaca-mcp
AI evaluationsLangfuse + OpenAI EvalsPartlyRetell + n8n eval flowsattested — Retell evals; n8n scoring
Prompt / version mgmtLangfuseYesSalesforce Prompt Builderattested — Agentforce; Agentblazer Legend
Business workflowsTemporal CloudYesn8n (not Temporal)attested — Vantaca WF (200); SMS spec
Background jobsInngest / Trigger.devYespg_cron · edge fns · sweep jobsapi/sweep.js; rc-scheduler-tick + pg_cron
SearchPostgres FTS → OpenSearchYesSecond Brain · Google Driveconnector: search_all; Drive search_files
Files / documentsAWS S3YesGoogle Drive · Second Brainconnector: Drive; second-brain upload_file
PaymentsStripeYesStripe Buy Buttonattested — SOFA JCC buy_btn · pk_live (Webflow)
External integrationsCustom adapters; NangoYesVantaca · Salesforce · Apollo · RC~/vantaca-mcp (73 endpoints); 3pl-salesforce
Logs & infra monitoringDatadog / CloudWatchYesDatadog (agent + proxy)api/datadog.js; agent v7.80.2 on droplet
Application monitoringSentryYesDatadog (Sentry excluded, PHI)DD monitors on app logs; SLP §1
Product analyticsPostHogYesRetell · n8n analyticsattested — Retell + n8n run analytics
Audit logsWorkOS Audit / append-only PGYesagentlogs (app-level)api/sweep.js + orchestrator-run.js
TestingVitest, Playwright, Pact, k6YesVitest + PlaywrightFundingo & SLP package.json
DeploymentGitHub Actions + VercelYesGitHub Actions · Vercel · CloudflareSLP CI green; git-based deploy
Feature flagsPostHog / LaunchDarklyYesManual master-switchRCControlsView.jsx; rc_scheduler switch
SecretsAWS Secrets ManagerYesVercel env / .env (server-side)process.env in api/claude.js, datadog.js
InfrastructureAWS ECS/Fargate, RDS, S3, CF, WAFYesDigitalOcean · Vercel · CF · AWS Supabasedroplet 134.209.126.217; no ECS
Infrastructure-as-codeTerraformYesdocker-compose · CaddyfileSLP infra/ compose + Caddyfile + setup.sh
Edge protectionAWS WAF / CloudflareYesCloudflare (tunnel · Pages · WAF)vantaca.aventary.com tunnel; CF Pages
Compliance managementVanta / DrataPartlyManual HIPAA hardeningSLP CLAUDE.md §0/§10 + RUNBOOK
Security scanningGH Advanced Security, SemgrepYesCustom hardening checksSLP scripts/check-hardening.sh
Vector / RAG storagepgvectorYesNot confirmedai_memories exists; embeddings unverified
Events and queuesAWS EventBridge / SQSYesNot used
My operating rules 8

How the stack is actually run. personal-ai-hype-cycle ↗

  1. 1
    No single AI existsRoute each task to the model best at it. Many by design.
  2. 2
    Wrap legacy systemsExtend what already runs the business; don't rip it out.
  3. 3
    Build verification loopsAI hallucinates. Use AI to audit AI, and gate on the check.
  4. 4
    Interfaces are temporaryOptimize the workflow underneath, not the dashboard on top.
  5. 5
    Don't build everythingBuy the 80%; spend the build budget on the last 20%.
  6. 6
    Create external memoryKnowledge the AI reaches across sessions — the OS underneath.
  7. 7
    Close feedback loopsAutomate the check so it runs before output reaches a user.
  8. 8
    Make learning intentionalCompound skill across tools so each project speeds the next.
The client harness — 8 questions 8

The tool is commodity; the harness is the advantage. Ask these before buying and every quarter after. the-harness-audit ↗

  1. 1
    AccountabilityOne named owner answerable for its performance.
  2. 2
    RiskSafeguards before AI touches a customer or a dollar.
  3. 3
    ProofTransparency on what it did and how well.
  4. 4
    PaybackQuantify the work actually removed from a human.
  5. 5
    CostKill redundant tools; consolidate the stack.
  6. 6
    AdvantageFeed proprietary data so output can't be copied.
  7. 7
    Quality at scaleVerification keeps pace with output velocity.
  8. 8
    CapabilityDelegate whole tasks, not endless prompt tweaks.

Measuring in a world of AI

Why it matters: a good answer and a finished job are two different things. An agent can write a perfect summary and still route to the wrong team, drop the handoff, or mark a call "resolved" while the caller is already dialing back. Without measurement you can't tell resolved from worsened — and you can't improve what you can't see. The next teams won't win on prompts; they'll win on loops.

Grade the job, not the transcript.
How you measure — evidence-first, never one number
  1. AI describes — raw labels: intent, sentiment, status.
  2. Workflow judges — scores those labels against your rules.
  3. Systems prove — tool calls, records, timestamps, not claims.
  4. Humans calibrate — a gold set defines "good" before judges scale.

One score hides the failures that matter. Keep the dimensions visible — a clean 92 can bury an agent that understood the intent and still did the wrong thing.

What you measure — different at every altitude:

Infra · DevOps

Did the machine do what it said?

Deterministic system facts.

Cheap, boring checks you run on everything: did the tool call fire, was the route confirmed or only guessed, is it up, is it fast. Facts the system should just know.

Model · Dev

Is the AI itself any good?

AI has its own tests.

Evals against a human-set rubric, retrieval grounding (does the context match), judge-vs-human agreement by failure type — not average score. Grade it before you scale it.

Outcome · Business

Did the work actually get done?

Test the outcome, not the text.

The only bar that pays: did the AI resolve, shorten, or worsen the work? First-contact vs. repeat-contact, tied to the P&L. A dispatcher answers it in five seconds.

A scoreboard tells you that you lost; a learning system tells you why, which version caused it, whether it repeated, and when to roll it back. Read the friction and each point becomes the next item on the backlog. the-metrics-became-the-product-backlog ↗

The Operating Stack · By Mendy Ezagui · aventary.com/insights