Research · Reference Architecture
Version 1.0 · September 2026 · By Jubet M. Padilla
AI is a capability inside the application, not the application architecture itself.
A production AI application is not UI → LLM → Response. It is a coordinated software platform where identity, authorization, data, payments, security, observability, and operations are engineered alongside the AI. This is the full reference: 55 sections, from first principles to a master launch checklist.
The guided path
This is a curriculum, not a wall of text. Seven parts, read in order: foundations before identity, identity before AI, AI before business, business before operations, and the skills system last. Each stop below links straight into the reference.
Part I · Foundations
5 sectionsStart here. What a production AI app is, and the engineering order that keeps it honest.
Part II · Identity & Data
3 sectionsWho can do what, and where the data lives. Auth, tenancy, and file pipelines.
Part III · The AI Layer
6 sectionsThe AI layer itself: models, orchestration, tools, RAG, memory, and guardrails.
Part IV · Business Systems
4 sectionsHow the product makes money: payments, entitlements, metering, and cost control.
Part V · Platform & Operations
15 sectionsHow it survives contact with reality: jobs, caching, monitoring, deployment, incidents.
Part VI · The Skills System
8 sectionsTurn the whole stack into reusable skills that teach an AI agent to engineer, not just generate.
Part VII · Reference
14 sectionsThe appendix: governance, readiness levels, and the master launch checklist.
The one-minute version
Architecture at a glance
User
Web / Mobile / API
Edge / CDN / WAF
Identity + Authorization
Application / Domain Logic
AI Orchestration
Data + External Systems
Observability + Evaluation
Billing / Usage / Operations
Production Infrastructure
Where to start
Building an AI SaaS?
Parts III–IVOrchestration, RAG, and guardrails first, then payments, entitlements, and metering.
Doing a security review?
§6 · §14 · §49Auth boundaries, the AI security pipeline, and the responsibilities that must stay separate.
Preparing for launch?
§43 · §51The production readiness levels and the master checklist, end to end.
Teaching an AI agent to build?
Part VIThe skills system: capability skills, provider skills, and the orchestrator contract.
Or read it top to bottom: the order is the engineering order. Requirements before architecture, architecture before AI, AI before scale.
The skills system
Part VI turns this reference into a repository of reusable AI-agent skills: capability skills that define engineering responsibilities, and provider skills that define concrete implementations. The agent selects capability first, then provider. Never the other way around.
Layer A · Capability skills
Engineering responsibilities. What must be done.
Layer B · Provider skills
Concrete implementations. How it gets done.
production-ai-engineering/
00-meta/
01-application/
02-ai/
03-saas/
04-production/
05-delivery/
06-providers/
Full contract and orchestrator rules in Part VI.
Part I · Foundations
5 sections · Executive Summary · Engineering Philosophy · Frontend · …
Section 1
A production AI application is more than:
A reliable system is a coordinated software platform containing:
User
Web / Mobile / API
Edge / CDN / WAF
Identity + Authorization
Application / Domain Logic
AI Orchestration
Data + External Systems
Observability + Evaluation
Billing / Usage / Operations
Production Infrastructure
The core principle of this document is:
AI is a capability inside the application, not the application architecture itself.
Production systems must also engineer identity, authorization, data, payments, usage, security, observability, reliability, testing, deployment, and operational governance alongside AI.
Orchestration, tools, state/memory, guardrails, evaluation, observability, security, and cost control belong in the design from the start, not added later.
Section 2
The system should first define what capability is required, then choose an implementation.
Bad:
Use Supabase because it is popular.
Better:
Requirement
Default implementation
Alternative implementations
This prevents unnecessary vendor lock-in.
A beautiful interface that cannot reliably process payments, protect tenant data, recover from failures, or explain AI behavior is not production-ready.
The engineering order should generally be:
Requirements
Architecture
Data + Security Model
Core Application
AI Capabilities
Billing / Usage
Observability
Testing
Deployment
Production Readiness
Do not deploy enterprise infrastructure before the product requires it.
MVP
Growth
Scale
Enterprise
Every layer should have a reason to exist.
Section 3
Section 4
The application layer contains business rules.
Typical responsibilities:
Recommended architecture:
UI
API / Server Action
Application Service
Domain Logic
Repository / Integration
Database / External Service
Avoid placing complex business logic directly inside UI components or API handlers.
Section 5
Default:
Responsibilities:
Every important record should have explicit ownership.
For multi-tenant applications:
organization
membership
user
organization-owned resources
Prefer:
on tenant-owned entities.
Part II · Identity & Data
3 sections · Authentication and Authorization · Multi-Tenancy · File Storage and Processing
Section 6
Authentication answers:
Who are you?
Authorization answers:
What are you allowed to do?
They must remain separate concepts.
Use layered controls:
Identity
Organization
Role
Permission
Resource ownership
Action-specific policy
Never rely exclusively on frontend authorization.
Section 7
For SaaS products, tenancy must be designed from the beginning.
Typical model:
User
Organization A
Projects
Documents
AI usage
Billing
Organization B
Projects
Documents
AI usage
Billing
Recommended controls:
The application must never allow cross-tenant data leakage.
Section 8
Use object storage for:
Pipeline:
Upload
Authentication
Authorization
Virus / file validation
Object storage
Metadata record
Background processing
Extraction
Chunking
Embedding / indexing
Available for retrieval
Treat uploaded files as untrusted input.
Part III · The AI Layer
6 sections · AI Model Layer · AI Orchestration · Tool Calling · …
Section 9
The application should not hard-code itself around a single model.
Create a model abstraction:
Application
AI Service
Model Router
The router can select models based on:
Track:
Section 10
A simple AI application:
Request
Prompt
Model
Response
An agentic application:
Request
Policy Check
Context Builder
Planner / Router
Agent Loop
Guardrails
Validation
Human Approval if required
Response / Action
Prefer deterministic workflows when the process is known.
Use agentic behavior when the system genuinely benefits from:
Do not use agents merely because they are fashionable.
Section 11
Tools allow AI systems to interact with real systems.
Examples:
Every tool requires:
High-risk actions should require stronger controls and, where appropriate, human approval.
Section 12
RAG is more than:
A production retrieval system needs:
Source
Ingestion
Validation
Parsing
Chunking
Metadata
Embedding
Index
Retrieval
Filtering / reranking
Context construction
Model
Citation / provenance
Use the simplest strategy that works:
Section 13
Memory must be intentionally designed.
Current task:
Potentially:
Long-term memory must have:
Never store everything because storage is cheap.
Section 14
AI security is an application-security discipline.
User Input
Input Validation
Policy / Security Check
Context Construction
Model
Tool Authorization
Tool Execution
Output Validation
Sensitive-data / policy checks
User
The model should never be the final authority for authorization.
The application must enforce permissions independently.
Part IV · Business Systems
4 sections · Payments and Billing · Subscriptions and Entitlements · Usage Metering · …
Section 15
Payments are a core application subsystem.
Capabilities:
Architecture:
User
Application
Payment Provider
Webhook
Webhook Verification
Billing Service
Database
Entitlements
Section 16
Subscription status is not the same thing as access.
Use:
Customer
Subscription
Plan
Entitlements
Example:
Free
Pro
The application should evaluate entitlements centrally.
Section 17
AI applications need usage accounting because AI has variable cost.
Track:
Example:
AI Request
Usage Event
Cost Calculation
Usage Ledger
Quota / Billing
Usage records should be append-oriented and auditable.
Section 18
Track:
Optimization techniques:
Never optimize cost by blindly reducing model quality.
Part V · Platform & Operations
15 sections · Background Jobs and Durable Workflows · Caching and Rate Limiting · Analytics · …
Section 19
Use background processing for:
Architecture:
Request
Create Job
Queue
Worker
Progress State
Completion / Retry / Failure
Required properties:
Section 20
Caching targets:
Do not cache sensitive information without a deliberate isolation strategy.
Rate limiting should exist at multiple levels:
IP
User
Organization
API Key
Endpoint
AI Feature
Tool
Section 21
Product analytics answers:
What are users doing?
Track:
Do not use analytics as a substitute for application logs.
Section 22
Application monitoring should capture:
AI monitoring additionally needs:
Section 23
Traditional monitoring is insufficient for AI.
A useful AI trace should show:
Request
Prompt version
Model
Retrieved documents
Tool calls
arguments
result
intermediate state
latency
token usage
cost
guardrails
evaluation
final output
Key metrics:
Prompts should be treated as versioned artifacts.
Section 24
AI systems require evaluations in addition to traditional software tests.
Evaluation categories:
Evaluation should exist:
Section 25
Use structured logs.
Example conceptual event:
{
"event": "ai.tool_call",
"request_id": "...",
"organization_id": "...",
"user_id": "...",
"tool": "create_invoice",
"status": "success",
"duration_ms": 842
}Never log:
Section 26
Audit logs answer:
Who did what, when, and through which mechanism?
Record important actions:
For agentic systems:
must be distinguishable as the actor.
Section 27
Support appropriate channels:
Use event-driven notification architecture:
Domain Event
Notification Service
Preference Check
Channel
Users should control non-critical notification preferences.
Section 28
Use an edge layer for:
Application security must still exist behind the edge.
A WAF is not a replacement for secure application code.
Section 29
Default progression:
GitHub
Managed hosting
Managed database
Managed AI providers
Add:
Potentially add:
Section 30
Pipeline:
Commit
Lint
Type Check
Unit Tests
Integration Tests
Security Checks
Build
Preview
Approval
Production
Smoke Test
Database migrations must be part of controlled deployment.
Section 31
Use multiple layers.
Unit
Integration
API
End-to-End
Security
AI Evaluation
Load / Performance
AI-specific tests:
Section 32
Define:
A backup that has never been restored is not a proven backup strategy.
Section 33
Production products need:
Internal admin tools should be treated as production software.
Part VI · The Skills System
8 sections · Production AI Engineering Skills System · Capability Skills vs Provider Skills · Skill Repository Structure · …
Section 34
The stack above becomes more useful as reusable AI-agent skills.
The skills system teaches an AI coding agent to engineer production systems, not only to generate code.
Section 35
The skill system has two layers.
These define engineering responsibilities.
Examples:
These define concrete implementations.
Examples:
The agent should select:
Capability
Requirements
Provider
Implementation
rather than:
Vendor
Force application to fit vendor
Section 36
production-ai-engineering/
00-meta/
architecture-design/
ai-app-builder/
code-review/
production-readiness/
01-application/
frontend-engineering/
backend-engineering/
database-engineering/
authentication-authorization/
file-storage-processing/
multi-tenancy/
02-ai/
ai-integration/
ai-agents/
ai-tool-engineering/
rag-engineering/
ai-security/
ai-cost-optimization/
ai-observability/
03-saas/
payments-billing/
subscriptions/
usage-metering/
notifications-email/
admin-operations/
audit-logging/
04-production/
security-engineering/
rate-limiting/
background-jobs/
caching/
error-monitoring/
logging/
analytics/
backup-disaster-recovery/
05-delivery/
testing/
ci-cd/
deployment/
performance-engineering/
cloudflare-edge/
incident-response/
06-providers/
supabase/
vercel/
openai/
anthropic/
google-ai/
stripe/
paymongo/
xendit/
cloudflare/
posthog/
sentry/
resend/
Section 37
Before implementation, determine:
Output:
This is the orchestrator.
It determines which skills are required for a given application.
Example:
User Request
architecture-design
Select required skills
Execute implementation
code-review
testing
production-readiness
Review:
Acts as the final gate.
It verifies:
Section 38
Every skill should follow the same structure:
SKILL.md
Skills should be:
Section 39
Example request:
Build a multi-tenant AI HR platform with subscriptions and an AI assistant.
The orchestrator should produce:
architecture-design
Application skills
AI skills
SaaS skills
Production skills
Delivery skills
code-review
production-readiness
The orchestrator must not blindly invoke every skill.
It should select skills based on actual requirements.
Section 40
The AI coding agent should:
The agent should avoid:
Section 41
Skills should be composable.
Example:
architecture-design
database-engineering
authentication
backend
frontend
ai-integration
RAG
Agents
Tools
ai-security
ai-observability
testing
production-readiness
Part VII · Reference
14 sections · Engineering Governance · Production Readiness Levels · Reference MVP Stack · …
Section 42
Every production application should have explicit decisions for:
Section 43
No production guarantees.
Section 44
A strong default stack for many modern AI SaaS applications:
This is a default, not a mandatory stack.
Section 45
User
Browser
Edge
Authentication
API
Authorization
Rate Limit
AI Service
Context Builder
Model Router
LLM
Tool Decision
Tool Authorization
Tool Execution
Result Validation
Guardrails
Response
Usage Metering
AI Trace
Analytics
User
Section 46
User selects plan
Checkout
Payment Provider
Payment Result
Signed Webhook
Webhook Verification
Billing Service
Subscription State
Entitlement Update
Audit Event
Analytics
The browser must never be the authoritative source of subscription state.
Section 47
Upload
Authorization
Object Storage
Metadata
Background Job
Parse
Validate
Chunk
Embed
Index
Retrieval
Permission Filter
Rerank
Context
LLM
Citation
Section 48
Task
Identity
Policy
Context
Planner
Tool Selection
Authorization
Tool
Observation
Evaluation
Audit
Trace
Result
Section 49
Some responsibilities should remain independent.
Keeping these boundaries clear makes systems easier to reason about and safer to operate.
Section 50
Section 51
Section 52
Users
Web / Mobile / API
Edge / CDN / WAF
Identity + Authorization
Application / Domain Layer
Business rules · APIs · Billing · Entitlements · Workflows
Data Platform
PostgreSQL · Object storage · Vector search · Cache · Audit logs
AI Platform
Model router · Orchestration · RAG · Memory · Tools · Guardrails · Evaluation
External Systems
AI providers · Payment providers · Email · Enterprise APIs · Biometric / hardware APIs
Production Control Plane
Observability · Security · Analytics · Cost · Audit
CI/CD · Testing · Backups · Alerts · Support
Section 53
The modern AI application should be understood as:
PRODUCT
EXPERIENCE
UX / Accessibility / Performance
BUSINESS
Billing
Entitlements
Usage
Operations
AI
Models
RAG
Agents
Tools
Memory
Evaluation
PRODUCTION PLATFORM
Security
IAM
RBAC
RLS
Secrets
Reliability
Jobs
Retries
Backups
DR
Observability
Logs
Metrics
Traces
Alerts
Build applications where AI is one replaceable, observable, cost-controlled subsystem among identity, data, payments, security, and operations.
Section 54
For a new AI SaaS product:
Do not start with agents because the product is labeled "AI."
Start with the business workflow.
Then determine where AI earns its place.
Section 55
The Production AI Application Stack is a reference architecture and engineering operating model, not a fixed list of vendors.
Its purpose is to provide a repeatable way to build:
The architecture should evolve with the product.
The skills system ensures that AI coding agents can participate in this process without reducing software engineering to code generation.
The target state is:
Human Intent
Architecture
Capability Skills
Provider Selection
Implementation
Verification
Evaluation
Production
Continuous Improvement
Production AI engineering is more than prompt + model. It is software engineering, data engineering, security, AI engineering, payments, observability, operations, and continuous verification.
Questions or want to go deeper? Read the notes or get in touch.