How kwhitley/itty-router works
Main Components
a) Core Router Components:
• IttyRouter (Base Router)
• AutoRouter (Enhanced Router)
• SharedRouter (Common Router Functionality)
• Router (Standard Router Implementation)
b) Middleware Layer:
• CORS Handler
• Error Handler
• Content Handlers (JSON, HTML, Text, Images)
• Cookie Handler
• Parameter Parser
c) Type System:
• Request/Response Types
• Router Types
• Handler Types
• Custom Route Types
┌─ Application Layer ─────────────────────┐
• Examples & Implementation │
• ┬─────────────────────────┘
• ↓
┌─ Router Layer ──────────────────────────┐
• ┌─────────────┐ ┌─────────────┐ │
• IttyRouter │ │ AutoRouter │ │
• ┬──────┘ └──────┬──────┘ │
• ┬────┘ │
• ↓ │
• ┌─────────────────────┐ │
• SharedRouter │ │
• ┘ │
• ┬─────────────────────────┘
• ↓
┌─ Middleware Layer ───────────────────────┐
• ┌─────────┐ ┌───────┐ ┌──────────────┐ │
• CORS │ │ Error │ │ Content │ │
• ┘ └───────┘ └──────────────┘ │
• ┌─────────┐ ┌───────────────────────┐ │
• Cookies │ │ Parameter Parser │ │
• ┘ └───────────────────────┘ │
• ┬─────────────────────────┘
• ↓
┌─ Type System Layer ─────────────────────┐
• Request/Response Types │
• Router Types │
• Handler Types │
• Custom Route Types │
• ┘
Important Elements to Highlight
a) Size Optimization:
• Minimal footprint (450-970 bytes) as a key feature
• Modular nature allowing for tree-shaking
b) Runtime Compatibility:
• Connections to different runtimes (Bun, Node.js, Cloudflare Workers)
• Serverless-first design
c) Type System Integration:
• How TypeScript types flow through the system
• Generic type constraints and customization points
Notes for Implementation
• Keep the core router implementation visually simple
• Middleware chain architecture
• How route matching flows through the system
• Where type checking occurs
Remember to maintain the balance between showing the technical sophistication of the system while emphasizing its minimal footprint and efficient design, as these are key selling points of the project.