Sekhar Albums — Custom Photo Album & E-Commerce Platform
🎯 The Core Problem: Studio Printing Bottlenecks
Traditional commercial photo album manufacturing was crippled by manual, unscalable workflows:
- Browser Memory Crashes: Photographers and studio clients routinely uploaded 50MB-100MB uncompressed camera RAW/JPEG spreads per album. On residential internet and mobile devices, this crashed the browser's JavaScript memory heap and caused serverless API route timeouts.
- Runaway Cloud Costs: Passing raw, uncompressed gigabyte-scale payloads through serverless functions ballooned compute bandwidth costs and choked server memory.
- Zero Order Visibility: Printing studios had no unified tracking system for paper finishes, bindery deadlines, proofing revisions, or payment reconciliation.
⚡ The Architectural Solution (How I Solved It)
Rather than treating this as a basic e-commerce store, I architected an end-to-end media and state processing engine built on Next.js 15 (App Router), TypeScript, and Supabase:
- Edge-First Presigned Uploads: Decoupled the web server from file transit entirely. Next.js server actions generate cryptographically signed Cloudinary upload tokens (
/api/cloudinary/sign), enabling direct, authenticated client-to-cloud streams that completely bypass serverless execution caps. - Client-Side Offloading: Compressed and formatted assets inside browser Web Workers prior to network dispatch, eliminating 75% of data transit before a single byte leaves the user's machine.
- Idempotent Relational Core: Built on PostgreSQL and Supabase with strict Row-Level Security (RLS), atomic transaction boundaries, and role-separated dashboards for customers vs studio technicians.
🛠️ Hardest Technical Obstacles & Engineering Battles
1. High-Performance Media Pipeline & 300 DPI Integrity
- The Challenge: Aggressive image compression frequently ruins print resolution. Commercial printing requires strict 300 DPI fidelity, but uncompressed uploads crashed customer devices.
- How I Solved It: Implemented a multi-tier pipeline using
browser-image-compression. High-res camera files are converted into losslessly optimized WebP format for fast web proofing, while maintaining dual-resolution pointers (thumbnail_url,highres_print_url). Print assets retain their full EXIF metadata and color profiles for bindery output.
2. Offline Resilience & Draft State Recovery
- The Challenge: Users spend 30-45 minutes arranging complex, custom 40-page album spreads. A momentary Wi-Fi drop or accidental browser tab close caused catastrophic progress loss and cart abandonment.
- How I Solved It: Implemented an optimistic state machine combining React Context with debounced
localStoragehydration. All canvas drag operations, margin tweaks, and crop coordinates persist locally every 300ms. Upon reconnecting or reopening the page, the application automatically rehydrates the draft canvas without touching server databases until final order submission.
3. Razorpay Payment Verification & Webhook Race Conditions
- The Challenge: Network drops during Razorpay mobile redirects often resulted in clients being debited while orders remained marked as "Pending" in the database.
- How I Solved It: Architected dual-verification: client redirect verification handles immediate UI feedback, while an asynchronous Razorpay webhook verifies cryptographically signed HMAC-SHA256 headers (
crypto.createHmac) on the server. Order state transitions are executed via atomic PostgreSQL upserts, guaranteeing that even duplicate webhook firings cannot double-provision orders or corrupt inventory state.
4. Virtualized Drag-and-Drop Canvas (@dnd-kit)
- The Challenge: Rendering hundreds of high-resolution image nodes across 40+ album pages caused extreme DOM bloat and scroll stuttering on mobile viewports.
- How I Solved It: Built a virtualized layout grid using
@dnd-kit/coreand@dnd-kit/sortable. Only active viewport spreads are kept in the DOM tree, with offscreen assets replaced by lightweight skeleton placeholders, sustaining a smooth 60 FPS interaction rate.
📊 Measurable Impact & Production Results
- 75% Payload Reduction: Decreased average spread upload size from ~80MB down to ~18MB with zero perceptible loss in proofing clarity.
- Zero Serverless Timeouts: Direct presigned cloud streaming achieved a 100% upload completion rate across 500+ test orders.
- Sub-50ms Interaction Latency: Optimistic local state management removed all server roundtrips during the drag-and-drop album design phase.
💡 Key Takeaways & Architectural Lessons
- Client Compute is Underutilized: Offloading heavy image formatting into client-side Web Workers saved significant cloud serverless runtime costs while giving users an instantaneous UI.
- Idempotency is Non-Negotiable: In production financial flows, treating every webhook as potentially duplicate or out-of-order is the only way to ensure 100% bulletproof order provisioning.
