#π€ LLM Rules β System Design Topic Generation
Purpose: This document defines the exact rules, structure, and checklist an LLM must follow when generating a new system design topic for this repository. Follow every section. Skip nothing.
#π Trigger
When a user provides a one-liner like "Design X" or "Design a Y system", the LLM must generate a complete, end-to-end system design document and update all cross-referenced files.
#π File & Folder Structure
system-design/
βββ README.md β Master index (UPDATE)
βββ LLMRules.md β You are here
βββ notes/
β βββ concept-map.md β Central concept hub (UPDATE)
β βββ *.md β Concept notes (CREATE if missing)
βββ topics/
β βββ {NN}-{topic-slug}.md β Design document (CREATE)
βββ building-blocks/
βββ reference.md β Building blocks index (UPDATE)
βββ *.md β Building block files (CREATE if missing)#Naming Conventions
- Topics:
topics/{NN}-{slug}.mdβ NN = next available number (check README index), slug = kebab-case (e.g.,25-pastebin.md) - Building Blocks:
building-blocks/{technology}.mdβ lowercase, kebab-case (e.g.,vector-db.md,cassandra.md) - Notes:
notes/{concept}.mdβ lowercase, kebab-case (e.g.,event-sourcing.md,circuit-breaker.md)
#π Topic Document Template
Every topic document in topics/ MUST follow this exact 12-section structure. No sections may be skipped.
# Design [System Name] ([Scale Reference] Scale)
## 1. Problem Statement & Clarifications
### Functional Requirements β 4-6 numbered, bolded requirements
### Non-Functional Requirements β Table format: Requirement | Target
### Out of Scope β 3-5 bullet points of what we're NOT designing
### Assumptions β 3-5 bullet points
## 2. Back-of-Envelope Estimation
### Traffic Estimates β Code block with calculations
### Storage Estimates β Code block with calculations
### Bandwidth β Code block with calculations
### Cache Estimates β Code block with calculations
## 3. API Design
### [Core API 1] β Full request/response JSON examples
### [Core API 2] β Include HTTP method, path, headers
### [Internal API if needed] β Mark internal APIs explicitly
## 4. Data Model
### [Store 1] ([Technology](link) β sharding/partitioning strategy)
### [Store 2] β SQL CREATE TABLE or NoSQL schema
### Access Patterns β Table: Query | Store | Index/Key
## 5. High-Level Design (HLD) & Scale Evolution
### Stage 1: MVP / Startup Scale β Simple architecture + bottlenecks
### Stage 2: Growth Scale β Key architectural changes + bottlenecks
### Stage 3: [Target] Scale β Full architecture
#### Architecture Diagram β ASCII art diagram
#### Component Breakdown β Table: Component | Responsibility | Tech Choice
#### Data Flow β Write Path + Read Path (code block arrows)
## 6. Deep Dive β Core Components
### [Component 1] β Detailed Design
### [Component 2] β Detailed Design
### Scaling Strategy β Table: Component | Strategy
### Caching Strategy β ASCII art multi-layer diagram
### Consistency Models β Table: Data | Model | Rationale (LINK to notes)
## 7. Low-Level Design β Core Functionality
### Key Algorithms β 2-4 algorithms with pseudocode (Python preferred)
### Design Patterns Used β Table: Pattern | Where | Why (LINK to notes)
## 8. Failure Handling & Edge Cases
### What Happens When X Fails? β Table: Failure | Impact | Mitigation
### [Domain-Specific Edge Cases] β Bullet points with β mitigation
## 9. Monitoring & Observability
### Key Metrics β Table: Metric | Target | Alert Threshold
### Alerting Strategy β P0 / P1 / P2 tiers
### SLAs / SLOs β Code block with targets
## 10. Trade-off Summary
β Table: Decision | Chose | Over | Because (6-10 rows)
## 11. Extensions & Follow-ups
### What Would You Add With More Time? β 4-6 numbered items
### How Would This Change at 100x Scale? β 3-4 bullet points
## 12. Cross-References
### Related Topics in This Repo β Table: Topic | Connection
### Building Blocks Used β Bullet list with LINKS to building-blocks/
### Concepts Used β Bullet list with LINKS to notes/#π Deep Linking Protocol (MANDATORY)
This is the most critical rule. Every mention of a technology or concept MUST be hyperlinked to its corresponding file.
#Rules
Technologies β Link to
building-blocks/{tech}.mdβ [Redis](../building-blocks/redis.md) β [PostgreSQL](../building-blocks/postgresql.md) β [sharded](../notes/sharding.md) β [Kafka](../building-blocks/kafka.md) β Redis β **Redis** β Redis (no link)Concepts/Patterns β Link to
notes/{concept}.mdβ [CQRS](../notes/cqrs.md) β [Consistency Models](../notes/consistency-models.md) β [Event Sourcing](../notes/event-sourcing.md) β CQRS pattern β Event Sourcing (mentioned without link)First mention in each major section should be linked. Subsequent mentions in the same paragraph need not be.
Section 4 (Data Model) headers must include technology links:
β ### Transaction Store ([Cassandra](../building-blocks/cassandra.md) β high write throughput) β ### User Profiles ([PostgreSQL](../building-blocks/postgresql.md) β [sharded](../notes/sharding.md) by user_id)Section 12 (Cross-References) must link ALL building blocks and concepts used.
#π§± Building Block File Rules
#When to Create
Create a new building-blocks/{tech}.md if the topic uses a technology that does not already have a file in the building-blocks/ directory.
#Check Existing First
Before creating, check for these existing files:
building-blocks/
βββ cassandra.md βββ kafka.md
βββ cdn.md βββ load-balancer.md
βββ dynamodb.md βββ postgresql.md
βββ elasticsearch.md βββ redis.md
βββ flink.md βββ s3.md
βββ vector-db.md βββ reference.md#Template
# π§± Building Block: [Full Technology Name]
## Overview
[1-2 sentence description of what it is]
## Key Concepts
- **[Concept 1]**: [Explanation]
- **[Concept 2]**: [Explanation]
- **[Concept 3]**: [Explanation]
(4-8 concepts)
## When to Use
- **[Use Case 1]**: [When and why]
- **[Use Case 2]**: [When and why]
(3-5 use cases)
## When NOT to Use β Optional but preferred
- [Anti-pattern 1]
- [Anti-pattern 2]
## Trade-offs
- **Pros**: [List strengths]
- **Cons**: [List weaknesses]
## Used In This Repo
- [Topic Name (#NN)](../topics/NN-slug.md) β [How it's used]
- [Topic Name (#NN)](../topics/NN-slug.md) β [How it's used]#π Concept Note File Rules
#When to Create
Create a new notes/{concept}.md if the topic uses a design pattern or concept that does not already have a file in the notes/ directory.
#Check Existing First
notes/
βββ bloom-filters.md βββ cqrs.md
βββ circuit-breaker.md βββ event-sourcing.md
βββ concept-map.md βββ sharding.md
βββ consistency-models.md#Template
# π Note: [Concept Name]
## Overview
[1-2 sentence definition]
## Core Idea
- **[Aspect 1]**: [Explanation]
- **[Aspect 2]**: [Explanation]
## [Comparison Table if applicable]
| Aspect | Option A | Option B |
(optional but encouraged)
## When to Use
- [Scenario 1]
- [Scenario 2]
## When NOT to Use
- [Anti-pattern 1]
## Trade-offs
- **Pros**: [List]
- **Cons**: [List]
## Used In This Repo
- [Topic Name (#NN)](../topics/NN-slug.md) β [How it's used]#πΊοΈ Concept Map Update Rules
After creating a topic, you MUST update notes/concept-map.md:
- Add new rows for any new technology or concept introduced.
- Update existing rows by appending the new topic to the "Related Topics" column.
- Link to deep-dive files in the "Deep Dive / Notes" column. Use
βif no deep-dive file exists.
#Format
| Concept | Related Topics | Deep Dive / Notes |
|---------|---------------|-------------------|
| **Redis** | [E-Commerce (#11)](../topics/11-ecommerce.md), [NEW TOPIC (#NN)](../topics/NN-slug.md) | [building-blocks/redis.md](../building-blocks/redis.md) |#π Reference Index Update Rules
After creating a topic, you MUST update building-blocks/reference.md:
- Add new building blocks to the appropriate category table (Data Storage / Compute & Networking / Messaging & Streaming).
- Add new concept notes to the Cross-Cutting Concepts table.
- Update the "Used In" column of existing entries if the new topic uses them.
#π README Update Rules
After creating a topic, you MUST update README.md:
- Find the topic index table in the appropriate section (π’ Fundamentals / π‘ Product Systems / π΄ Advanced / β« Expert-Level).
- Add a new row:
| NN | Design [System Name] | `topics/NN-slug.md` | β Done | - If the topic doesn't fit an existing section, add it to β« Expert-Level.
#β Pre-Submission Checklist
Before considering the task complete, verify ALL of the following:
#Topic Document
- All 12 sections present and non-empty
- Problem statement has FR, NFR (table), Out of Scope, Assumptions
- Back-of-envelope has Traffic, Storage, Bandwidth, Cache estimates
- API design has full JSON request/response examples
- Data model has SQL/NoSQL schemas with access patterns table
- HLD has 3-stage evolution with ASCII architecture diagram
- Deep dive covers 2+ components with scaling, caching, consistency tables
- LLD has 2+ algorithms with Python pseudocode
- Failure handling has failure table + edge cases
- Monitoring has metrics table + P0/P1/P2 alerting + SLAs
- Trade-off summary has 6+ rows in decision table
- Extensions has future work + 100x scale discussion
- Cross-references links to related topics, building blocks, and concepts
#Deep Linking
- Every technology mention links to
building-blocks/*.md - Every concept/pattern mention links to
notes/*.md - Data model headers include technology + strategy links
- Design patterns table has links to notes
#Supporting Files
- New
building-blocks/*.mdcreated for any unlinked technology - New
notes/*.mdcreated for any unlinked concept/pattern -
notes/concept-map.mdupdated with ALL new and existing concepts -
building-blocks/reference.mdupdated with new entries -
README.mdtopic index updated with new topic row + β Done
#π¨ Style Guide
#Tone
- Senior/Lead engineer explaining to a peer β confident, opinionated, with trade-off awareness.
- Use "we" language: "We chose X because..."
- Justify every decision: "X over Y because Z"
#Formatting
- Tables for all comparisons, trade-offs, metrics, and access patterns.
- ASCII art for architecture diagrams (not Mermaid, unless the topic benefits from it).
- Code blocks for all calculations, schemas, pseudocode, and data flows.
- Bold for emphasis on key terms within bullet points.
- Use
---horizontal rules between major sections.
#Scale References
- Always include a recognizable company at target scale: "(Netflix Scale)", "(Amazon Scale)", "(PayPal Scale)".
- Stage 1 names should include realistic thresholds: "MVP / Startup Scale (10K DAU, 1M items)".
#Pseudocode
- Use Python for all pseudocode examples.
- Include comments explaining non-obvious logic.
- Keep functions focused and under 30 lines.
#Numbers
- Always show your math:
2B / 86400 β 23K QPS - Use consistent units: QPS, MB/s, GB, TB
- Include peak multipliers: "avg Γ 3 for peak"