Skip to content
DevToLead
Area 1.4 · 12 Lessons · ~83 min reading

Code Design & AI Review Drills

LRU cache, rate limiter, pub/sub bus & AI concurrency audits.

0 of 12 lessons completed
Start: Code: Rate Limiter
  1. 1In-Memory Rate Limiter With Per-Tenant Tier OverridesDesign a testable TypeScript rate limiter with an injected clock, O(1) token bucket state, per-tier overrides, and bounded memory cleanup for multi-tenant services.6 min read
  2. 2Thread-Safe and Async LRU Cache With TTL ExpiryBuild an O(1) LRU cache combining a HashMap and doubly-linked list with per-key TTL overrides, lazy expiry, async stampede protection, and hit-rate telemetry.7 min read
  3. 3File Collection Size and Top-K Tag AggregatorDesign an incremental storage aggregator supporting O(1) total byte reads, O(T log K) Top-K tag queries via a min-heap, nested folder rollups, and double-count-safe file updates.7 min read
  4. 4API Router With Wildcard Path Params and Middleware ChainImplement a segment-based Prefix Trie API router in TypeScript supporting static routes, named parameters, wildcards, HTTP method isolation, precedence rules, and composable middleware.7 min read
  5. 5In-Memory Key-Value Store With Nested TransactionsImplement an in-memory key-value engine using a stack of delta overlay maps for O(1) begin and rollback, plus an O(1) value-frequency index across nested commits.7 min read
  6. 6Dependency and Task Scheduler With Topological Sort and Cycle DetectionBuild a DAG task scheduler in TypeScript using Kahn's topological sort, descriptive cycle-path diagnostics, parallel execution waves, and bounded max-concurrency orchestration.7 min read
  7. 7Pub/Sub Event Bus With Filtered Subscribers and Retry BackoffDesign an async TypeScript pub/sub event bus with predicate filtering, exponential retry backoff, Dead Letter Queue routing, subscriber isolation, and bounded eventId deduplication.7 min read
  8. 8Circuit Breaker State Machine Wrapper for Flaky Downstream APIsImplement an explicit CLOSED-OPEN-HALF_OPEN circuit breaker in TypeScript with single-probe concurrency gating, 4xx vs 5xx error classification, fallback handlers, and state transition hooks.7 min read
  9. 9AI Code Review Audit: Spotting Concurrency and Check-Then-Act Race ConditionsTrain Tech Leads to spot AI-generated check-then-act race conditions, duplicate webhook inserts, shared mutable caches, and unbounded Promise.all fan-outs before they reach production.7 min readCase study
  10. 10AI Code Review Audit: Catching N+1 Queries and Unbounded Latency BottlenecksSpot AI-generated N+1 loops, unbounded SELECT queries, and missing composite indexes in 10 seconds during code review, and replace them with batched lookups and cursor pagination.7 min read
  11. 11AI Code Review Audit: Catching Missing Tenant Isolation (IDOR) and Authz GapsDetect AI-generated tenant isolation bugs (IDOR), untrusted body privilege escalation, PII/JWT log leaks, and missing outbound HTTP timeouts before they trigger security incidents.7 min read
  12. 12AI Code Review Audit: Cutting Over-Engineered AI Abstraction Bloat and Swallowed ErrorsEliminate speculative AI-generated AbstractFactory hierarchies, pass-through DTO mappers, and silent try/catch blocks to cut PR size by 50% and keep services debuggable at 2 AM.7 min read