Streaming chat
SSE stream from the OpenAI orchestrator with client retry and AbortController cancel.
NeedUsers judge AI products on responsiveness and recoverability.
ValueProduction chat UX out of the box.
ProjectsCase Study

ZNPak.ai exists so the next LinkedIn AI, Resume AI, or Instagram AI app is mostly config and prompts—not a rewrite of auth, chat persistence, uploads, and RAG.
apps/web demonstrates the generic assistant: streamed SSE responses, conversation CRUD, multimodal attachments with magic-byte validation, and workspace-scoped knowledge retrieval.
Security is treated as platform law: service role stays server-only, workspace membership gates every AI and file route, retrieved chunks are untrusted data—not prompt overrides.
Billing and Stripe webhooks are wired in packages with provider flags; the example product can run free-tier while the same core sells paid plans later.
Teams spin a new Next.js app per AI idea, copy-paste Supabase auth, then diverge on upload safety, idempotent chat, and RAG isolation until merges become impossible.
A shared AI core only pays off if every vertical inherits the same trust model—RLS, rate limits, and orchestration boundaries included.
Platform layers vertical apps plug into:
Supabase Auth, workspace_members, requireWorkspaceAccess, and RLS on user-owned tables.
POST /api/ai/chat → orchestrator with SSE, conversation persistence, retry/cancel, and chat idempotency keys.
Workspace-scoped documents in Storage, pgvector chunks, retrieval wrapped as untrusted content; 3-step attachment upload with MIME validation.
@znpak/ai, database, auth, storage, billing, validation—apps import orchestration instead of forking it.
New AI products start from a hardened base: same authz, same upload rules, same streaming contract—only product config changes.
SSE stream from the OpenAI orchestrator with client retry and AbortController cancel.
NeedUsers judge AI products on responsiveness and recoverability.
ValueProduction chat UX out of the box.
Intent → signed upload → magic-byte check before multimodal prompts.
NeedArbitrary files are untrusted input to the model.
ValueSafer multimodal assistant without public buckets.
Upload, chunk, embed into pgvector; retrieve inside orchestrator stream with source events.
NeedVertical SaaS needs private corpora per customer workspace.
ValueGrounded answers without a second RAG stack per product.
Retrieved text wrapped in explicit untrusted markers in system rules.
NeedUploaded content must not rewrite platform safety instructions.
ValueRAG that survives security review.
Provider abstraction, prompt registry, context engine, tools—database injected from the app.
Needpackages/ai must not import apps/web.
ValueClean dependency direction for many future apps.
Stripe checkout + webhook verification hooks; provider flag for free mode during foundation phase.
NeedMonetization should not require a rewrite when a vertical launches.
ValueSame core sells free example and paid verticals.
Authenticate and pass workspace membership checks.
Upload attachment through intent + validated bytes; wait until ready.
Send chat with idempotency key; stream assistant reply with usage tracking.
assistant service checks chat_idempotency before persisting duplicate user sends when clients retry after network blips.
Business valueFewer duplicate charges and confusing twin messages.
Production RateLimiter uses rate_limit_events via service role—not in-memory maps on serverless.
Business valueConsistent throttling across AI and knowledge upload routes.
apps/web → server services → @znpak packages → Supabase/OpenAI; core packages never import application code.
Business valueFuture apps/<product> folders stay thin.
| Challenge | Solution |
|---|---|
| Flaky mobile networks replayed POST /api/ai/chat and created duplicate assistant rows for one user gesture. | Client-generated idempotency keys with chat_idempotency upsert—skipped on explicit user retry. |
| Workspace RAG needed pgvector and Storage without letting retrieved PDF text override system safety rules. | Retriever output wrapped in <untrusted-retrieved-content> with documented injection policy in docs/security.md. |
| Letting each vertical fork auth or upload validation would rot the foundation within one product launch. | Single packages/auth, storage, and validation surfaces; verticals only supply config/product.ts and prompts. |
Recommended capture order for the case-study gallery.
The generic assistant in apps/web is the contract test—if a feature is not good enough for the example app, verticals should not inherit it.
RAG is a data channel, not a second system prompt—mark retrieved content untrusted or audits fail.
Keep packages/ai free of database imports; inject usage and retrieval from the app so orchestration stays portable.
| Priority | Improvement | Business value |
|---|---|---|
| High | First vertical app (e.g. Resume AI) on apps/<product> config only | Proves the foundation story with a market-facing SKU. |
| Medium | Enable Stripe provider in production billing config | Turns limits and plans from schema into revenue without new core code. |
ZNPak.ai is a case study in a reusable AI core—not a demo chat page. If you want the same platform discipline for your product line, start a conversation.
Start a conversationFull Stack Product Engineer
Personal platform / AI SaaS foundation
2026
Solo build
Next Project
Ask about projects, skills, or how to hire.