← Back to Portfolio
Full-Stack SaaS Turborepo Monorepo Next.js + Python

LinkFlow AI: Case Study

An enterprise-grade AI operating system designed for SMB customer acquisition, public-to-private funnel automation, multi-tenant merchant onboarding, and third-party platform API integration.

55
Data Models
6
Applications
7
LLM Providers
75+
UI Components

📁 Monorepo Folder Topology

── Turborepo Monorepo Structure ── apps/ ├── merchant/ ← Next.js 14 Merchant Portal (Console Dashboard) ├── web/ ← Next.js Public Marketing & Funnel Landing Site ├── admin/ ← Next.js Platform Operations (Super Admin Board) ├── miniapp-shell/ ← WeChat Mini Program Public Shop UI ├── auth-proxy/ ← Nitro/h3 Auth Proxy helper └── python-worker/ ← FastAPI AI worker (crawler + vector search + generation) packages/ ├── db/ ← Prisma client, schema, PostgreSQL migrations ├── api/ ← shared tRPC routes & backend business logics ├── auth/ ← NextAuth setup, SMS OTP, WeChat OAuth persistence ├── ai/ ← Multi-LLM provider abstraction layers ├── ui/ ← Shared UI kit (Radix Primitives, Tailwind themes) ├── stripe/ ← Global billing & ledger service wrapper └── common/ ← Common utility helpers

đŸ›Ąī¸ Architectural Decoupling

LinkFlow AI utilizes a multi-frontend monorepo configuration to isolate deployment footprints, bundle sizes, and security contexts.

  • Identity Domains: apps/web and apps/merchant share a user identity system. apps/admin is fully isolated with distinct tables and cookies (linkflow.admin) to prevent privilege escalation.
  • Execution Boundaries: Business logic is centralized in packages/api (tRPC) and packages/db (Prisma). UI shells merely map routes and render shared primitives.
  • Worker Isolation: Compute-heavy AI crawling and prompt orchestration are delegated to the Python FastAPI worker, preventing Node.js event-loop blocks.

5-Phase Engineering Roadmap

How LinkFlow AI was built from core foundation, through AI engine development, up to full private-domain mini-program closure.

Phase 1: Conversion Funnel & Auth Baseline
Foundation
Designed the core onboarding funnel. Integrated standard user registration with multi-channel authentication (password, WeChat OAuth, Aliyun SMS OTP verification). Set up the pricing dashboard and localized WeChat payment webhook endpoints.
Phase 2: Control Plane & Multi-Tenant Isolation
Control Layer
Split the monolithic database into isolated tenant spaces. Built a dynamic Role-Based Access Control (RBAC) permission tree mapping resources to actions. Designed a central AI model router capable of token rate-limiting, circuit breakers, and automatic backup routing across 7 LLM backends (OpenAI, Claude, DeepSeek, Gemini, etc.).
Phase 3: Async AI Generation Engine
AI Core
Developed a background generation pipeline utilizing a FastAPI worker and BullMQ/Redis tasks. Implemented localized web scraping of trend sources, context vectorization, and generation write-back to PostgreSQL. Solved thread starvation, quota tracking, and multi-tenant data leaks during high-throughput AI text synthesis.
Phase 4: Reach & Social Platform Distribution
Distribution
Created integration adapters for China-specific platforms, prioritizing Douyin (TikTok) Open Platform. Built merchant OAuth binding flows, publishing queue management, campaign-level conversion metrics, and visual analytics dashboards for campaign ROI mapping.
Phase 5: Private Domain Loop & Fulfillment
Close The Loop
Implemented private domain membership loop. Built staff verification workflows using scan-to-verify pages, verification order creation, and conversion of shadow members into active loyalty program members. hard-coded commercial exception protection (e.g., locking transaction boundaries for reversals, booking cancellations, and ledger-based commission adjustments).

System Showcase & Technical Annotations

Review high-resolution walk-throughs of the entire platform's interface logs, categorizing the public funnel, merchant console, administrative control panel, and IDE codebase environment. Click on cards to view in-depth details.

Architect-Level Core Competencies Demonstrated

Engineering skills and architectural patterns proven during the development of the LinkFlow AI codebase.

🧱 Clean Boundaries & Decoupling

Successfully managed complex monorepo layouts. Centralized core data schemas and tRPC API routes inside shared workspaces. Used distinct auth namespaces (isolated cookies and model rules) to prevent merchant tenant code from polluting administrative control flows.

⚡ High-Performance Concurrency

Built async processing channels using BullMQ and Redis to handle CPU-bound AI operations. Designed rate-limit backoffs, circuit breakers, and fallback mechanisms inside the AI router layer, ensuring 99.97% platform availability even during LLM provider failures.

🔒 Financial Security & Transaction Safety

Engineered strict database-level ACID transaction limits for merchant wallets, commission ledgers, and booking reservations. Mitigated concurrency race conditions using Redis distributed locks and unique request idempotency keys.

🔌 Multi-Platform API Integrations

Navigated complex domestic China open platform requirements, resolving OAuth handshake anomalies, signature verification gates, payment webhook security requirements, and automated release lifecycles for Douyin and WeChat Mini Programs.