under-the-hood Svelte Themes

Under The Hood

Interactive visualizer for JavaScript event loop and execution model with Kid Mode, Pro Mode, and 3D visualization. Built with Svelte, Vite, and Three.js.

Under the Hood: JavaScript Visualizer

An interactive, kid-friendly visualizer for the JavaScript event loop and execution model. Built with Svelte, Vite, Tailwind CSS, Three.js, and GSAP.

๐Ÿ“ธ Screenshots

Kid Mode - Simple and friendly visualization

Kid Mode
Simple and friendly visualization

Pro Mode - Technical view with logs

Pro Mode
Technical view with logs

3D Engine - Immersive 3D visualization

3D Engine
Immersive 3D visualization

โœจ Features

๐ŸŽฎ Three Visualization Modes

  • Kid Mode: Simple 2D SVG visuals with friendly metaphors (Task Robot, Magic Cloud, Speedy Lane, Waiting Line)
  • Pro Mode: Technical 2D view with detailed logs, tooltips, and engine pipeline visualization
  • 3D Engine: Immersive 3D visualization with realistic materials, smooth animations, and cinematic camera

๐Ÿ“š Interactive Scenarios

Basic Scenarios:

  • Two Logs: Demonstrates synchronous execution order
  • Timer vs Promise: Shows microtask priority (Promises run before setTimeout)
  • Fetch Robot: Illustrates Web API offloading and callback enqueueing

Advanced Scenarios:

  • Microtask Chain: Shows how multiple Promises can starve macrotasks
  • Nested Timeouts: Demonstrates FIFO macrotask queue ordering
  • Async/Await: Visualizes async/await desugaring to microtasks
  • DOM Click: Simulates event handler enqueueing

โ™ฟ Accessibility

  • Full keyboard navigation (Space/Enter to play/pause, Arrow keys to step)
  • High-contrast theme with visible focus indicators
  • Reduced motion support (respects prefers-reduced-motion)
  • ARIA labels and live regions for screen readers
  • Color + shape + icon encoding (not color-alone)

๐Ÿš€ Quick Start

Requirements

  • Node.js 20.19+ (or 22.12+)
  • npm 10+

Installation & Development

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

# Preview production build
npm run preview

Open the dev server URL (typically http://localhost:5173) in your browser. Use the mode selector and scenario dropdown to explore different visualizations.

๐Ÿงช Quality & Testing

# Linting
npm run lint              # Check for issues
npm run lint:fix          # Auto-fix issues

# Formatting
npm run format            # Check formatting
npm run format:write      # Auto-format code

# Testing
npm run test:unit         # Run Vitest unit tests
npm run test:e2e          # Run Playwright E2E tests
npm run test:all          # Run all tests

All tests include:

  • โœ… Unit tests for simulation engine logic (event ordering, micro vs macro tasks)
  • โœ… E2E tests for user flows (scenario selection, playback controls, mode switching)
  • โœ… CI integration via GitHub Actions

๐Ÿ“– Documentation

๐Ÿ—๏ธ Project Structure

src/
โ”œโ”€โ”€ App.svelte                    # Main app component with controls
โ”œโ”€โ”€ lib/
โ”‚   โ”œโ”€โ”€ Stage.svelte              # 2D SVG visualization stage
โ”‚   โ”œโ”€โ”€ NewJSEngine3D.svelte      # 3D visualization container
โ”‚   โ”œโ”€โ”€ Controls.svelte           # Playback controls
โ”‚   โ”œโ”€โ”€ Legend.svelte             # Visual legend
โ”‚   โ”œโ”€โ”€ Token.svelte              # Animated task tokens
โ”‚   โ”œโ”€โ”€ sim/
โ”‚   โ”‚   โ”œโ”€โ”€ engine.ts             # Deterministic simulation runner
โ”‚   โ”‚   โ”œโ”€โ”€ scenarios.ts          # Predefined scenario scripts
โ”‚   โ”‚   โ””โ”€โ”€ types.ts              # TypeScript types
โ”‚   โ””โ”€โ”€ jsengine3d/
โ”‚       โ”œโ”€โ”€ JSEngine3D.ts         # Core 3D engine
โ”‚       โ””โ”€โ”€ components/           # 3D component modules
โ”‚           โ”œโ”€โ”€ CallStack.ts
โ”‚           โ”œโ”€โ”€ WebAPIs.ts
โ”‚           โ”œโ”€โ”€ MicrotaskQueue.ts
โ”‚           โ”œโ”€โ”€ MacrotaskQueue.ts
โ”‚           โ”œโ”€โ”€ EventLoop.ts
โ”‚           โ””โ”€โ”€ ExecutionFlow.ts
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ e2e/                      # Playwright E2E tests
โ””โ”€โ”€ docs/                         # Comprehensive documentation

๐ŸŽฏ Current Status

MVP Complete โœ… All core features implemented:

  • โœ… T1: Simulation engine with deterministic event loop
  • โœ… T2: Visual layer integration (SVG + 3D)
  • โœ… T3: Controls and narration
  • โœ… T4: Kid Mode scenarios (basic + advanced)
  • โœ… T5: Accessibility and responsiveness
  • โœ… T6: Testing and quality assurance
  • โœ… T7: Pro Mode with technical details
  • โœ… T8: Tooling and CI/CD
  • โœ… T9: Content and documentation

In Progress:

  • T10: UI polish and enhancements

See docs/tasks.md for detailed status.

๐Ÿ› ๏ธ Technology Stack

  • Framework: Svelte 5
  • Build Tool: Vite 7
  • Styling: Tailwind CSS 4
  • 3D Graphics: Three.js + cannon-es (physics)
  • Animation: GSAP 3
  • State Management: XState 5
  • Testing: Vitest + Playwright
  • Linting: ESLint + Prettier
  • CI/CD: GitHub Actions

๐Ÿ“ License

MIT โ€” see LICENSE

๐Ÿค Contributing

Contributions are welcome! Please read the documentation in docs/ to understand the architecture and workflow. Always work in a feature branch (never directly in main).


Made with โค๏ธ to help everyone understand JavaScript's magic โœจ

Top categories

Loading Svelte Themes