Commercial E-commerce Ecosystem
1. Executive Summary & Impact
Developed a production-ready, modular e-commerce ecosystem to automate retail operations for a bird nest product shop. The architecture utilizes a Monorepo to unify a high-performance customer storefront with a secure administrative command center, reducing deployment overhead and ensuring code consistency across the entire stack.
2. Technical Architecture & Design Patterns
I engineered this commercial ecosystem using a Decoupled Monorepo Architecture managed via TurboRepo and pnpm workspaces. The system is strategically split into specialized layers to ensure maximum developer velocity, strict type safety, and a secure, "stateless" backend.
1. The Monorepo Core (monorepo/packages)
2. The Client & Identity Layer (monorepo/web & monorepo/admin)
3. The Business API Layer (monorepo/api)
Functional Flow Analysis
The interactions in the system are categorized by their specific functional purpose:
A. Security & Verification (The Cryptographic Handshake)
B. Authorized Business Logic Flow
C. Infrastructure & Persistence Flow
3. Key Features & Implementation
- •Secure Authentication: Unified session strategy using better-auth (Next.js) and JWT verification (NestJS) with jose and jwks-rsa.
- •Role-Based Access Control (RBAC): Custom AuthGuards to protect sensitive administrative endpoints.
- •Scalable Media Handling: Integrated Vercel Blob for secure image storage with automated cleanup logic.
- •Automated Communications: Integrated Resend for transactional email triggers (order confirmations, status updates).
4. Challenges & Solutions
Challenge:
Secure Distributed Authentication: Maintaining a unified session across a decoupled Next.js storefront and a standalone NestJS API.
Solution:
Built a custom verification layer in NestJS using a jwks-rsa client to validate JWTs issued by the Next.js/Better-Auth server. By implementing caching and rate-limiting on the key-retrieval process, the system ensures secure, high-speed authorization without a shared session database.
Challenge:
Transactional Data Integrity: Ensuring consistency across multiple relational tables during complex business operations like order placement or inventory updates.
Solution:
Leveraged TypeORM’s QueryRunner for manual transaction control. This guarantees atomic operations, ensuring that if any step of a multi-table update fails, the entire database state is rolled back to prevent orphaned records or inventory mismatches.
Challenge:
Secure & Scalable Media Management: Handling large image uploads from the Admin Panel directly to Vercel Blob without exposing the API to heavy file buffering or unauthorized storage access.
Solution:
Implemented a Token-based Upload Flow. The NestJS API acts as a gatekeeper, generating secure, short-lived Client Upload Tokens. This allows the Admin Panel to upload directly to Vercel Blob from the browser—reducing API load—while the backend maintains strict control over file permissions and ensures transactional cleanup of orphaned files.
5. Tech Stack Summary
Frontend
Backend
Auth & Security
Infrastructure