How webdevsimplified/feature-flags-sample-code works
This is a small Next.js feature-flag demo: a browser requests the home page, which renders product-management and flag-gated cards. Each gate checks a static flag rule against a user, optionally using a MurmurHash percentage bucket. A separate product-query helper demonstrates a flag-controlled alternate-query comparison. SQL and user lookup are local stubs; no external database or identity service is evidenced. The map follows the sampled files and README; unsampled application behavior is not inferred.
Main entry points: products.ts Product Query · page.tsx Home Page · FeatureEnabled.tsx Feature Gate · featureFlags.ts Flag Rules
Components 10
Web UI
- Home Page
src/app/page.tsx - Feature Gate
src/components/FeatureEnabled.tsx - Card Components
src/components/ui/card.tsx - Class Utilities
src/lib/utils.ts
Flag Evaluation
- Flag Rules
src/lib/featureFlags.ts - User Lookup
src/lib/getUser.ts - MurmurHash
src/lib/murmurhash.ts
Product Query
- Product Query
src/db/products.ts - SQL Stub
src/lib/sql.ts
Other components
- Browser
Connections 10
- Browser → Home Page: requests
README.md - Home Page → Feature Gate: renders
src/app/page.tsx - Home Page → Card Components: renders
src/app/page.tsx - Feature Gate → Flag Rules: checks flags
src/components/FeatureEnabled.tsx - Feature Gate → User Lookup: gets user
src/components/FeatureEnabled.tsx - Card Components → Class Utilities: merges classes
src/components/ui/card.tsx - Flag Rules → MurmurHash: hashes bucket
src/lib/featureFlags.ts - Product Query → Flag Rules: checks flag
src/db/products.ts - Product Query → User Lookup: gets user
src/db/products.ts - Product Query → SQL Stub: queries products
src/db/products.ts