Haude Tea — Full-Stack E-Commerce Platform

Featured Project
A purpose-built e-commerce platform for a Taiwan artisan tea brand, unifying a Traditional Chinese storefront (Next.js 15), admin dashboard (Vite 7), and REST API (NestJS 11) in a Turborepo monorepo. Features an ECPay integration for credit card, ATM virtual account, and convenience store code payments (built and unit-tested on the API, not yet enabled in the live store, where orders use phone confirmation), 4-tier membership loyalty with automatic progression, farm tour booking, and admin analytics dashboard — backed by 29 Prisma data models across 5 business domains and 160 API endpoints across 19 specialized modules. The live demo is in Traditional Chinese; the screenshots below have English captions.
4 months (actively maintained)
Status: In active development
0
Data Models
Prisma models across 6 business domains (customers, products, orders, payments, farm tours, administration)
0
API Endpoints
REST endpoints across 19 specialized modules with Swagger auto-documentation
0/5
Security Score
12 security practices verified across 3 independent audit rounds, including token rotation and rate limiting
0
Automated Tests
test files across 3 testing frameworks (Vitest + Jest + Playwright)

Tech Stack Versions

Precise technology versions used in this project

Next.js15.x
React19.x
NestJS11.x
TypeScript5.x
Prisma7.x
Turborepo2.x
Vite7.x
PostgreSQL15.x
Zustand5.x
Dockerlatest
GitHub Actionslatest
Playwrightlatest

Screenshots

Main feature screens of the project

Homepage Hero — Brand identity & call-to-action

Full Homepage — Farm features, news, responsive design

Login Page — JWT + Google OAuth dual authentication

Farm Experience — Tour booking & seasonal events

Product Catalog — Search, category filter, sorting, sale badges

Admin Dashboard — 14-module management panel, KPI overview, revenue trends

Admin Login — Google OAuth admin-only authentication

System Architecture

3-tier caching strategy and data flow architecture

Haude Monorepo Architecture@haude/typesShared Types — 8 files, 652 linesWeb (Next.js 15)SSR Storefront — 262 filesAPI (NestJS 11)REST Backend — 192 filesAdmin (Vite 7)SPA Dashboard — 102 filesArchitecture: pnpm Workspaces + Turborepo unified build pipelineType Safety: 45 error codes + DTOs synced across 3 apps at compile time

Performance Metrics

Lighthouse scores and Core Web Vitals measurements

Lighthouse Scores

0
SEO

Core Web Vitals

CLS
0
Cumulative Layout Shift

Capabilities Demonstrated

Technical and business capabilities demonstrated through this project

  • ECPay Taiwan-Native Payments — Credit card, ATM virtual account, and convenience store code payments with SHA256 MAC signature verification (built on the API, not yet enabled in the live store)
  • 4-Tier Membership Loyalty — NORMAL → BRONZE → SILVER → GOLD auto-progression with purchase-based points and tier multipliers
  • JWT Token Rotation Security — Auth0-inspired refresh token rotation with reuse detection, crypto-random tokens stored in database

Challenges Faced

Main technical challenges encountered during development

  • Taiwan ECPay has no official TypeScript SDK — community packages are unmaintained with opaque MAC verification logic
  • Complex order lifecycle management (7 states × multiple actors × inventory / discount / points coordination)
  • JWT token security: refresh token rotation with reuse detection mechanism design
  • Monorepo build orchestration across 3 heterogeneous apps (Next.js + Vite + NestJS) with type synchronization
  • Passing 3 independent security audit rounds covering TOCTOU, console leaks, plaintext passwords, and 12 security practices

Solutions

Technical solutions and implementation strategies adopted

  • Built custom Payment Module split into 5 sub-services (checkout / callback / virtual-account / cvs / webatm) with fully auditable SHA256 MAC verification
  • Applied Facade Pattern to split orders into 7 single-responsibility sub-services (each < 200 lines), independently testable and extensible
  • Implemented Auth0-inspired token rotation: crypto-random refresh tokens in database with reuse detection that revokes all user tokens on compromise
  • Built @haude/types shared package with Turborepo smart cache, 33 error codes catch inconsistencies at compile time
  • Pattern-first security approach: grep entire codebase → fix pattern-wide → verify with round-by-round matrix

Code Snippets

Key implementation code from the project

// modules/payments/services/payment-callback.service.ts
private verifyCheckMacValue(
  data: Record<string, string>,
  receivedMac: string,
): boolean {
  // 1. Sort params by key per ECPay spec
  const sorted = Object.keys(data)
    .sort()
    .map((key) => `${key}=${data[key]}`)
    .join('&');

  // 2. Prepend HashKey / append HashIV
  const raw = `HashKey=${this.hashKey}&${sorted}&HashIV=${this.hashIV}`;

  // 3. URL encode → lowercase → SHA256
  const encoded = encodeURIComponent(raw).toLowerCase();
  const hash = createHash('sha256')
    .update(encoded)
    .digest('hex')
    .toUpperCase();

  return hash === receivedMac;
}

Architecture Decisions

Key architectural and technical decisions made during development

Context

Need to maintain storefront (Next.js), admin dashboard (Vite SPA), and backend API (NestJS) simultaneously, with shared type definitions and error codes.

Options Compared
Polyrepo (3 repos)
Pros
  • Independent team deployment
  • CI pipelines don't affect each other
Cons
  • Type synchronization is difficult
  • Requires additional private npm package management
  • Cross-project refactoring is costly
pnpm + Turborepo Monorepo
Pros
  • Shared types sync instantly
  • Unified build and CI pipeline
  • Turborepo smart cache accelerates builds
Cons
  • More complex initial setup
  • Monorepo feels heavy for solo development
Decision

Chose Monorepo: @haude/types shared package propagates type changes instantly across 3 apps, 33 error codes catch inconsistencies at compile time

Outcome

Zero missed type changes, unified pnpm dev starts all 3 services, CI validates in dependency order

Technical Highlights

In-depth technical implementation details and architecture design

pnpm + Turborepo Unified 3-App Management

Monorepo Architecture
  • @haude/types shared package — tsup dual output (ESM+CJS)
  • 33 standardized error codes shared across apps, compile-time inconsistency detection
  • Turborepo smart build cache with dependency-ordered validation

Next.js 15 App Router + Server Components

Frontend Architecture
  • 63% Server Components — SSR optimized initial load
  • 4-page Suspense Streaming — Progressive loading experience
  • 94 React components + 21 custom Hooks + 4 Zustand Stores

NestJS 11 Modular Enterprise Backend

Backend Architecture
  • 20 business modules, 39 Services — Facade Pattern for complex logic
  • 5 Guards (JWT / OAuth / Roles / CSRF / Throttler) security pipeline
  • Swagger auto-generates docs for 160 REST API endpoints

Prisma 7 + PostgreSQL Relational Models

Database Design
  • 29 Prisma Models — Full relations with cascade deletes
  • Order 7-state flow (pending → delivered / cancelled → refunded)
  • Membership level history tracking + points transaction records

Key Takeaways

Important lessons and reflections from this project

Technical

NestJS Decorator + Interceptor pattern adds cross-cutting concerns (audit, caching, performance monitoring) declaratively, keeping controllers focused on business logic

Real Impact: Adding @AuditLog or @Cacheable requires just one decorator line without modifying business code, drastically reducing maintenance cost

Architecture

Monorepo's real value isn't code sharing but type sharing — @haude/types keeps 33 error codes and DTOs consistent across 3 apps at compile time, with type changes auto-propagating

Real Impact: Zero missed type changes across 3 apps, greatly boosted refactoring confidence, cross-app inconsistencies caught before deployment

Process

Security audit success depends on Pattern-First fixes — when finding one vulnerability, immediately grep the entire codebase for all instances of that pattern and fix them all at once

Real Impact: Completed all security fixes within 3 rounds achieving 5/5 security score, avoiding the inefficiency of repeated audit cycles

Interested in this project?

Feel free to reach out to discuss similar technical solutions or how I can help with your project.

Contact Me
Contact Me
Haude Tea — Full-Stack E-Commerce Platform | Chih-Cheng Tien - Full Stack Developer