PORTFOLIO/SYSTEMS/ChromaShift

ChromaShift

-68% payload size, -42% P95 inference latency

Edge AI image SaaS with serverless inference

00 / TECHNOLOGY
Frontend
Next.js 16ReactTypeScriptTailwind CSS v4GSAP
AI/Edge
Cloudflare Workers AIsharp (WebP)
Data
Neon PostgreSQLDrizzle ORM
Auth & Payments
ClerkStripe (idempotent webhooks, signature verification)
Media
ImageKit
01 / FORMULATION

Problem formulation

Edge AI image transformation services face dual bottlenecks: heavy neural model inference latency when routed to centralized data centers, and massive payload delivery overhead from uncompressed image streams. Furthermore, concurrent Stripe subscription webhooks risk double-crediting user accounts during transient network retries without strict cryptographic idempotency guarantees.

02 / ARCHITECTURE

Subsystem topology

EDGE INFERENCE PIPELINE|DISTRIBUTED AI RESTYLING & COMPRESSION
PAYLOAD: -68% // LATENCY P95: -42%
CLIENT INGRESSNext.js 16 AppClerk MiddlewareJWT AUTH / AUDITEDGECLOUDFLARE WORKERS AI // DISTRIBUTED EDGEEDGE INFERENCENeural Model Run-42% P95 LATENCYDistributed ColocatedSHARP COMPRESSWebP Stream Pipe-68% PAYLOAD100% → 32% sizeOPTIMIZEDHIGH-SPEED DELIVERYEdge Cached Binary AssetsInteractive Drag Handle ReadyZero Hydration BottleneckSTRIPE WEBHOOK STATE RECONCILIATIONIdempotent Webhook Event ConsumerCryptographic Signature Verification (HMAC-SHA256)Idempotency Key Hash: SHA256(event.id)Guaranteed Zero Duplicate Credit ProvisioningNEON POSTGRESQL + DRIZZLE ORMServerless Connection PoolerType-Safe Schema Migrations & RelationsREAL-TIME CREDIT LEDGER AUDITINGUser tier management & generation event history
FIG. 01ARCHITECTURAL TOPOLOGY & SUBSYSTEM DATAFLOW

ChromaShift leverages Cloudflare Workers AI for distributed neural inference executed at edge points-of-presence, reducing P95 inference latency by 42%. Server-side WebP streaming via sharp compresses payloads by 68% before delivery.

Persistence is managed through Neon serverless PostgreSQL with Drizzle ORM and Clerk authentication. Stripe billing webhooks use cryptographic HMAC-SHA256 signature verification and idempotency hashing on event IDs, preventing duplicate credit allocations under high-frequency webhook retries.

03 / TRADE-OFFS

Architectural decisions

DECISION 01

Cloudflare Workers AI edge inference and sharp WebP compression

Reduces payload sizes by 68% and P95 inference latency by 42%.

DECISION 02

Neon PostgreSQL with Drizzle ORM and Clerk middleware

Enforces type-safe serverless persistence, session validation, and real-time credit ledger auditing.

DECISION 03

Idempotent Stripe webhook consumers with cryptographic signature verification

Automates subscription upgrades and prevents duplicate credit provisioning across concurrent requests.