Skip to Content
Kido Bag

Kido Bag Overview

Shadcn for Distributed Systems — White-box, zero-dependency distributed systems library and architecture recipes.

Kido Bag (bag.khanhdp.com)

"Shadcn for Distributed Systems"
White-box ownership, zero black-box npm locking, and 0 bytes of unused runtime bloat.

Welcome to Kido Bag, an enterprise-grade collection of 39 Domain Combo Suites (125+ Headless Slices) and 12 Battle-Tested Architecture Blueprints built for high-concurrency Node.js, Bun, TypeScript, and distributed cloud applications.


🎯 Core Philosophy: White-Box Ownership

Modern software development often suffers from dependency sprawl: pulling in heavy npm packages with dozens of transitive dependencies for simple algorithms, lock primitives, or math utilities. When production incidents occur at 3:00 AM, debugging third-party black-box node_modules is painful and slow.

Kido Bag inverts this paradigm:

White-Box Code Ownership

You own the source code. Every slice is plain, readable TypeScript that lives directly in your repository.

0 Unused Bytes

Cherry-pick only the exact functions you need into src/lib/. Zero transitive dependency explosion.

Zero-Lock Standard

Engineered for high concurrency: non-blocking event loops, atomic Lua scripts, and single-flight coalescing.

Battle-Tested Proof

Every blueprint is verified under production loads (up to 100k req/s) with deterministic benchmarks.


⚡ The 3-Tier Taxonomy

Kido Bag is organized into three distinct, composable architectural layers:

┌────────────────────────────────────────────────────────────────────────┐
│  LAYER 3: COMPOSITE SYSTEM BLUEPRINTS (Architecture Blocks & Recipes)  │
│  e.g., YouTube View Counter · 5-Stage RAG Pipeline · Flash-Sale Engine │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │ composes
┌───────────────────────────────────▼────────────────────────────────────┐
│  LAYER 2: DOMAIN COMBO SUITES (39 Cohesive Packages in @kido/*)        │
│  e.g., @kido/hot-counter · @kido/resilient-cache · @kido/async-sync    │
└───────────────────────────────────┬────────────────────────────────────┘
                                    │ contains
┌───────────────────────────────────▼────────────────────────────────────┐
│  LAYER 1: HEADLESS FUNCTIONAL SLICES (125+ Zero-Coupling Modules)     │
│  e.g., src/murmurhash · src/single-flight · src/token-bucket · src/hll │
└────────────────────────────────────────────────────────────────────────┘
  1. Layer 1: Headless Functional Slices: Pure, zero-coupling primitives (e.g., murmurhash3_32, SingleFlight, TokenBucketLimiter, HyperLogLogCounter). Each module lives in its own src/<slice>/ directory with zero cross-slice dependencies.
  2. Layer 2: Domain Combo Suites: 39 cohesive packages in @kido/* grouping related capabilities into high-level domain toolkits (e.g., @kido/hot-counter, @kido/resilient-cache, @kido/wallet-ledger).
  3. Layer 3: Composite System Blueprints: 12 complete architecture recipes solving real-world scale challenges (e.g., Twitter Hybrid Feed, YouTube View Counter, Zero-Downtime Blue-Green Deployment).

🚀 The 2 Consumption Modes

You can consume Kido Bag in two ways depending on your project topology:

Mode A: Surgical Cherry-Pick into src/lib/ (The Shadcn Pattern)

For external projects (commerce-api, fintech-core, next-web), copy only the specific slice file or folder into your project.

# Example: Copying the YouTube View Counter slice into your backend
mkdir -p src/lib/hot-counter
cp packages/hot-counter/src/youtube-view-engine.ts src/lib/hot-counter/
cp packages/hot-counter/src/valkey-write-behind.ts src/lib/hot-counter/

Benefits:

  • Zero npm registry dependencies.
  • Full customizability: adapt types, error handlers, and loggers directly in your repo.
  • Zero risk of supply-chain attacks or unexpected breaking semver bumps.

🗺️ The 12 Architecture Blueprints

Explore the 12 battle-tested architecture blueprints:


🏛️ The 6 Domain Combo Pillars (39 Packages)

The 39 domain suites are organized across 6 functional pillars:

On this page