-
Notifications
You must be signed in to change notification settings - Fork 1
Architecture Overview
Coding Drills is a client-heavy SPA with static generation where possible. There is no database β all content is static TypeScript data, all user state lives in localStorage, and AI features run locally via WebGPU.
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Presentation Layer β
β Next.js App Router β React 19 β Tailwind CSS 4 β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Data Layer β
β Static TypeScript modules (problems, exercises, β
β quizzes, methods, cheatsheets, UI patterns) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β State Layer β
β React Context (Theme, Progress) β Custom Hooks β
β localStorage persistence β useSyncExternalStore β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Execution Layer β
β In-browser JS/TS runner β Pattern validation β
β API route for TS transpilation β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β AI Layer β
β WebLLM (Llama-3.1-8B local) β OpenAI (cloud opt.) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
All state is client-side localStorage. This means:
- Zero server costs
- Complete user privacy
- Instant data access
- No cross-device sync (tradeoff)
All problems, exercises, quizzes, and reference content are defined as typed TypeScript constants in /lib/. Benefits:
- Full type safety at compile time
- Zero-latency data access
- Easy to validate with TypeScript compiler
- Tradeoff: content changes require code changes and redeploy
WebLLM runs Llama-3.1-8B-Instruct locally via WebGPU (~3GB first download, cached after). No API keys needed. OpenAI is an optional cloud fallback.
100+ visualization components are individually lazy-loaded via next/dynamic. Monaco Editor is also dynamically imported. Initial bundle stays small.
generateStaticParams() pre-renders all 25 language pages and 4 framework pages at build time for fast initial loads.
coding-drills/
βββ app/ # Next.js App Router pages
β βββ [language]/ # Per-language routes (25 languages)
β βββ frontend-drills/ # Frontend framework routes (4 frameworks)
β βββ interview/ # AI mock interview
β βββ regex/ # Regex trainer
β βββ pattern-quiz/ # Algorithm pattern quiz
β βββ links/ # External links
β βββ api/transpile/ # TypeScript transpilation endpoint
βββ components/ # React components
β βββ visualizations/ # 100+ algorithm visualizations
β βββ navigation/ # Nav components
βββ hooks/ # Custom React hooks
βββ lib/ # Business logic & data
β βββ problems/ # 25 language problem sets
β βββ exercises/ # Building Blocks exercises
β βββ methods/ # Method reference data
β βββ cheatsheets/ # 25 language cheatsheets
β βββ frontend-drills/ # Frontend drill system
β βββ regexTrainer/ # Regex trainer engine
β βββ interview/ # AI interview system
β βββ core/ # Shared types & constants
β βββ services/ # Storage adapters
βββ e2e/ # Playwright E2E tests
βββ stories/ # Storybook stories
βββ scripts/ # Build & generation scripts
app/ pages βββ components/ (UI rendering)
β
ββββ lib/ (data + business logic)
β
ββββ hooks/ (state management)
β
ββββ lib/storage (localStorage persistence)
components/ProgressProvider βββ localStorage
components/ThemeProvider βββ localStorage
lib/codeValidator βββ lib/codeRunner (JS/TS execution)
components/visualizations/ βββ next/dynamic (lazy loading)
| Component Type | Rendering | Examples |
|---|---|---|
| Layouts | Server Component |
[language]/layout.tsx, [framework]/layout.tsx
|
| Metadata | Server |
generateMetadata() in layouts |
| Static params | Build time |
generateStaticParams() for languages/frameworks |
| Interactive pages | Client ('use client') |
Drill, Quiz, Exercise, UI Pattern detail pages |
| Monaco Editor | Client (dynamic import) | { ssr: false } |
| Visualizations | Client (dynamic import) |
{ ssr: false } via registry |