Skip to main content
System Architecture
9 min read

Fullstack AI Lab Architecture Deep-Dive: Compiling 1,135+ MDX Lessons in 90 Seconds with Next.js 16 & Rust MDX-RS

Complete executive and technical breakdown of the Fullstack AI Lab interactive engineering platform: how we cut SSG build times by 14x (from 21.6m to 1.5m), engineered an in-browser WebAssembly WordPress sandbox, an AI Technical Interview Engine, interactive runtime simulators, and a zero-metaphor NotebookLM audio engine.

AY
Artur Yusupov
Fullstack Web Engineer & AI Developer
Production Proof:Fullstack AI Lab
Fullstack AI Lab Architecture Deep-Dive: Compiling 1,135+ MDX Lessons in 90 Seconds with Next.js 16 & Rust MDX-RS

1. Executive Summary & The Engineering Problem

Modern engineering education platforms suffer from two fundamental flaws:

1
Passive Content Delivery: Reading static Markdown blocks or watching hour-long videos without interacting with the underlying runtime architecture leads to low retention and high cognitive fatigue.
2
Build & Runtime Bottlenecks at Scale: When an educational platform scales past 1,135+ interactive lessons across 4 languages (1,700+ localized routes), naive Static Site Generation (SSG) hits severe filesystem I/O bottlenecks, pushing CI/CD build times over 21.6 minutes and risking Vercel deployment timeouts.

Fullstack AI Lab (https://www.fullstackailab.com) was architected from first principles to solve both challenges. Built with Next.js 16 App Router, React 19 Server Components, Tailwind CSS v4, and native Rust MDX-RS, it compiles 1,700+ interactive pages in under 90 seconds, achieves 98+ PageSpeed, passes 225/225 automated tests, and provides interactive architectural simulators alongside in-browser WebAssembly sandboxes with zero server runtime overhead.

Quick Architecture Decision Matrix: EdTech Platform Architectures

Architecture Dimension
SSG Build Duration (1,700+ routes)
Traditional Video / CMS Platform
21.6 minutes (Heavy filesystem I/O)
Fullstack AI Lab Engine (Next.js 16 + Rust MDX)
1.5 minutes / 90 seconds (14x faster with Rust MDX-RS)
Architecture Dimension
Pedagogical Interactivity
Traditional Video / CMS Platform
Passive video streams and static text
Fullstack AI Lab Engine (Next.js 16 + Rust MDX)
Interactive simulators (<ArchitectureFlow>, Live WASM)
Architecture Dimension
Code Execution Sandboxing
Traditional Video / CMS Platform
Cloud Docker containers ($0.08/session)
Fullstack AI Lab Engine (Next.js 16 + Rust MDX)
Client-side WebAssembly PHP 8.4 ($0.00 cloud compute)
Architecture Dimension
User State & Progress Sync
Traditional Video / CMS Platform
Mandatory login gate before first lesson
Fullstack AI Lab Engine (Next.js 16 + Rust MDX)
Local-First Zustand v5 + optional Supabase RLS cloud sync
Architecture Dimension
Mobile & Offline Performance
Traditional Video / CMS Platform
Heavy database round-trips & latency
Fullstack AI Lab Engine (Next.js 16 + Rust MDX)
Sub-second Edge CDN + Service Worker PWA caching

2. Architecture Decision Records (ADR - Why We Chose This Stack)

Every architectural choice in Fullstack AI Lab was evaluated against strict performance, maintainability, and pedagogical criteria:

Architectural Decision
Git-Backed MDX + Native Rust `mdxRs`
Rejected Alternative
Dynamic CMS Database (WordPress / Strapi)
Engineering & Business Rationale
Lessons embed live React 19 interactive components (<ArchitectureFlow>, <StepFlow>). Storing MDX in Git allows pre-build AST syntax validation in CI/CD and zero-latency Vercel Edge CDN delivery without database round-trips.
Architectural Decision
Singleton In-Memory Build Cache (`lib/content.ts`)
Rejected Alternative
Per-Route Filesystem fs.readFile Parsing
Engineering & Business Rationale
Eliminates redundant disk reads when generateStaticParams and generateMetadata iterate across 1,700+ routes. Cut build time from 21.6 min to 1.5 min (14x faster).
Architectural Decision
In-Browser WebAssembly WP 7.0 / PHP 8.4 (SQLite VFS)
Rejected Alternative
Ephemeral Docker Containers on AWS/Fly.io
Engineering & Business Rationale
Docker clusters cost thousands in monthly server infrastructure and require strict sandboxing against malicious PHP code. Running WordPress 7.0 inside client WebAssembly with SQLite VFS runs entirely client-side, zero cloud bill, instant sub-second spin-up.
Architectural Decision
AI Technical Interview Simulator with Senior Rubrics
Rejected Alternative
Generic Chatbot Prompts
Engineering & Business Rationale
Generic LLM chats praise syntactically correct code while ignoring system design trade-offs. The custom engine evaluates candidates against strict Senior rubrics (time complexity, concurrency safety, edge failures, memory overhead).
Architectural Decision
Local-First Zustand v5 + Personal Supabase Sync
Rejected Alternative
Mandatory Auth Gate & Public Multi-User Leaderboard
Engineering & Business Rationale
Zero barrier to entry: state updates (XP, streaks, Leitner flashcards) execute in <1ms in localStorage, while authenticated personal sessions sync progress and dual-tier PRO entitlements to a private Supabase PostgreSQL store protected by Row Level Security (RLS).
Architectural Decision
Zero-Metaphor NotebookLM Prompt Engine
Rejected Alternative
Generic AI Summary Wrappers
Engineering & Business Rationale
Novice analogies ("an API is like a restaurant waiter") create flawed mental models for senior interviews. Our prompt engine enforces strict technical terminology for deep-dive audio generation.

3. Core Mechanisms: How Fullstack AI Lab Works Under the Hood

Mechanism 1: The 14x Build Speedup via Singleton In-Memory Content Cache

In Next.js App Router, rendering 1,700+ localized routes requires resolving navigation trees, breadcrumbs, sibling links (Previous/Next lesson), and SEO metadata for every page. Initially, each route invoked fs.readFileSync across the curriculum directory, resulting in over 1.8 million redundant filesystem calls during a single build.

We engineered a Singleton In-Memory Content Cache:

  • On the first build worker request, the engine scans the MDX tree once, parses frontmatter and AST metadata, and freezes the structured index inside a process-level Map.
  • All subsequent 1,700+ route renders and metadata generators read directly from RAM in O(1) time.
TS
// Conceptual blueprint of the Singleton In-Memory Content Cache
const lessonIndexCache = new Map<string, ParsedCurriculumTree>()

export function getCurriculumTree(locale: Locale): ParsedCurriculumTree {
  const cached = lessonIndexCache.get(locale)
  if (cached) return cached

  const tree = scanAndValidateMdxDirectory(locale)
  lessonIndexCache.set(locale, Object.freeze(tree))
  return tree
}

Mechanism 2: Interactive Explorable Explanations (<ArchitectureFlow> & Simulators)

Grounded in John Sweller's Cognitive Load Theory and Jerome Bruner's Spiral Curriculum, Fullstack AI Lab minimizes extraneous cognitive load by presenting system mechanics visually before showing syntax:

  • `<ArchitectureFlow>` Dual-Mode Visualizer: Operates in Pipeline Mode (showing continuous end-to-end data flow across client, edge, server, and database) and Inspector Mode (allowing the reader to step through individual execution nodes and inspect memory safety, runtime environment badges, and payload transformations).
  • WordPress Hook Lifecycle & Outage Simulators: Deterministic state machines running in the browser that trace exact hook execution order (muplugins_loaded -> plugins_loaded -> init -> wp_loaded -> template_redirect) and simulate production failures (such as object cache stampedes or REST API permission leaks).
  • Formative Checkpoints (+15 XP): Interactive micro-quizzes embedded directly into lesson sections that validate conceptual understanding before users proceed to complex implementations.

Mechanism 3: WebAssembly WordPress Playground & AI Technical Interview Engine

  • In-Browser WebAssembly Playground: Compiles PHP 8.4 and WordPress 7.0 core into WebAssembly via SQLite VFS. Users execute real PHP code, test custom hooks, and experiment with database queries directly inside the browser with zero remote server infrastructure.
  • AI Technical Interview Simulator: Simulates real-world Senior technical interviews. Candidates answer architectural questions under timed conditions and receive structured rubric evaluations scoring performance, memory efficiency, fault tolerance, and security considerations.

Mechanism 4: Zero-Metaphor Audio Prompt Engine for Google NotebookLM

To enable high-density mobile and commute learning, Fullstack AI Lab includes an automated NotebookLM Audio Overview Generator:

1
The extractor strips JSX presentation wrappers from the raw MDX lesson while preserving code blocks, architectural tables, and edge cases.
2
It wraps the technical corpus into a specialized Zero-Metaphor System Prompt that instructs Google Gemini / NotebookLM hosts to conduct a rigorous architectural dialogue between a Staff Engineer and a Mid-level Developer, explicitly forbidding household metaphors.

Mechanism 5: Two-Pass SSR Hydration Guard & Dual-Tier Supabase Sync

Because lesson pages are statically pre-rendered on the server (SSG), reading user-specific XP, daily streaks, or completed checkpoints directly from localStorage during the initial render would cause a React 19 Hydration Mismatch error.

  • We implemented a strict two-pass useIsMounted() guard: the server and initial client pass render a deterministic, layout-stable skeleton; immediately after mount, the Zustand v5 store hydrates from localStorage and asynchronously synchronizes personal progress and dual-tier PRO entitlements with Supabase PostgreSQL.

4. Engineering Glossary: Every Key Term Explained

To make this case study accessible to both technical executives and software engineers, here is a clear breakdown of every key mechanism used in Fullstack AI Lab:

  • Rust MDX-RS (`@next/mdx`):
  • *What it is*: A native Rust compiler that transforms Markdown files containing embedded React/JSX components into executable JavaScript modules.
  • *Why it matters*: Compiles orders of magnitude faster than legacy JavaScript-based unified/remark pipelines and enforces strict HTML/JSX syntax safety at build time.
  • Static Site Generation (SSG) & React Server Components (RSC):
  • *What it is*: Pre-rendering pages into static HTML and serialized component payloads at build time rather than computing them on every user request.
  • *Why it matters*: Delivers instant Time to First Byte (TTFB < 50ms) from Vercel's global Edge CDN and reduces server compute costs to near zero.
  • WebAssembly WordPress Playground (PHP 8.4 / SQLite VFS):
  • *What it is*: A full WordPress 7.0 and PHP 8.4 execution stack compiled to WebAssembly running completely inside client browser memory using a virtual SQLite file system.
  • *Why it matters*: Provides an isolated sandbox for testing code without requiring container infrastructure or backend server hosting.
  • AI Technical Interview Simulator & Senior Rubrics:
  • *What it is*: An AI-driven assessment engine that scores candidate responses against standardized Senior architectural competencies.
  • *Why it matters*: Delivers actionable, objective technical feedback without human reviewer bottlenecks.
  • Cognitive Load Theory (Sweller):
  • *What it is*: A cognitive science framework stating that human working memory has a strict capacity limit; poorly structured UI or walls of text overload the brain and block learning.
  • *Why it matters*: By splitting complex topics into visual flows (<StepFlow>), inline glossary tooltips (<Term>), and micro-checkpoints (+15 XP), learners master senior-level architecture faster.
  • Leitner 5-Box Spaced Repetition:
  • *What it is*: An algorithmic memory retention system where flashcards answered correctly move to longer review intervals, while missed cards reset to immediate review.
  • *Why it matters*: Ensures long-term retention of complex APIs, hooks, and system design patterns.
  • Supabase Row Level Security (RLS) & Dual-Tier PRO Entitlements:
  • *What it is*: PostgreSQL database security policies that restrict which rows a user can read or write based on their cryptographic JWT session token, with entitlement gates distinguishing Free and PRO access.
  • *Why it matters*: Guarantees that personal learning telemetry and progress snapshots in Supabase can only be accessed and modified by the authenticated owner.

5. Defense-in-Depth Security Posture

Even for an educational platform, Fullstack AI Lab enforces strict DevSecOps boundaries:

1
Pre-Build Rust AST Compiler Gate (`scripts/validate-content.mjs`): Scans all 1,135+ MDX files before deployment to prevent malformed JSX tags or injection vectors from reaching production.
2
Client-Side WebAssembly Isolation: The WebAssembly PHP runtime operates inside a dedicated Web Worker sandbox with SQLite VFS in browser memory, isolated from DOM cookies and sensitive storage.
3
Zero-`eval()` Interactive Sandboxes: All lifecycle and outage simulators run on pre-defined, type-safe finite state machines rather than executing arbitrary user strings via eval() or new Function(), completely eliminating client-side Cross-Site Scripting (XSS) risks.
4
Database Isolation via RLS: Personal progress synchronization with Supabase PostgREST is strictly scoped by PostgreSQL RLS policies and validated against schema constraints.
5
Edge Security Headers: Protected behind Cloudflare WAF and Vercel Edge with strict Content-Security-Policy, HSTS, and X-Content-Type-Options: nosniff.
Battle-Tested Production Proof

Where This Architecture is Deployed in Production

These architectural patterns are not abstract theory - they are fully deployed and benchmarked in these live production builds:

Artificial Intelligence / B2B RAG & Automation

Custom RAG AI Assistants & 24/7 Automation Engines for Businesses

Deploy an intelligent AI consultant that answers complex customer questions strictly using your verified documents and price sheets. Zero hallucinations, 24/7 availability, and lead capture.

Explore B2B Service
Architecture Consulting

Planning a tech stack migration or new build?

Discuss architectural requirements with my interactive RAG AI assistant or connect directly for an engineering assessment.

Contact Directly