Thanks to visit codestin.com
Credit goes to github.com

Skip to content

woolkingx/schema-driven-development

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Schema-Driven Development

The Type System Revolution: Stop wasting 70% of your time on types, focus on business logic

License: MIT PRs Welcome

δΈ­ζ–‡ζ–‡ζ‘£ | ζ—₯本θͺž

🎯 The Problem

Programming has only two essentials: Data Types (50%) + Business Logic (50%)

Reality: We spend 70%+ time on types, only 30% on actual business logic.

Why? Because we define types in code (language-specific, scattered everywhere).

Solution: Define types in data (JSON Schema - language-agnostic, single source of truth).

πŸ’‘ Core Philosophy

Schema = Contract = Test = Doc = Object

One JSON Schema file serves as:

  • βœ… API Contract: Frontend/backend agreement
  • βœ… Automated Tests: Modify schema = modify all tests
  • βœ… Type Definitions: Auto-generate TypeScript/Rust/Python types
  • βœ… Documentation: Always-correct API docs
  • βœ… Dynamic Objects: JSON-as-Object pattern, natural field alignment

πŸš€ Quick Example

Traditional Way (2.5 hours)

TypeScript:

// Define types (30 min)
interface User {
  id: string;
  email: string;
  name: string;
}

// Write validation (30 min)
function validateUser(data: any): data is User {
  if (typeof data.id !== 'string') return false;
  if (typeof data.email !== 'string') return false;
  // ... 50 more lines
}

// Write docs (20 min)
// Write tests (40 min)
// Sync with backend (20 min)
// Business logic (30 min)

Rust:

// Duplicate everything in Rust (1 hour)
struct User { /* ... */ }
fn validate_user() { /* ... */ }

Schema-DD Way (40 minutes)

One Schema (10 min):

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "User",
  "type": "object",
  "properties": {
    "id": {"type": "string"},
    "email": {"type": "string", "format": "email"},
    "name": {"type": "string", "minLength": 1}
  },
  "required": ["id", "email", "name"]
}

Auto-Generated (0 min):

  • βœ… TypeScript types
  • βœ… Rust validation
  • βœ… Python Pydantic models
  • βœ… Documentation
  • βœ… Storybook stories
  • βœ… Test cases

Business Logic (30 min):

// Just focus on business logic!
function createUser(data: User) {
  // Your actual value-adding code here
}

Result: 4-5x faster, focus on what matters!

🌟 Real-World Success Stories

Case 1: Claude TUI RS (Streaming Events)

Challenge: Terminal UI with 14 streaming event types

Solution: JSON-as-Object Pattern + DynamicEvent API

Results:

  • βœ… 40x faster development (3 min vs 2 hours per event type)
  • βœ… 100% doc accuracy (schema auto-generates docs)
  • βœ… Zero type errors (runtime validation + dynamic property access)
  • βœ… 9 passing tests (schema = tests)

Details β†’

Case 2: UI Component Library ⭐ Killer App

Challenge: Cross-platform UI library, 50+ components, perfect frontend/backend alignment

Solution: Schema Registry + Component Library Pattern

Results:

  • βœ… 4-6x faster development (30 min vs 2-3 hours per component)
  • βœ… 88% maintenance cost reduction (5h vs 40h per month)
  • βœ… 100% design system consistency (enforced, can't violate)
  • βœ… Perfect cross-platform sync (Web/Mobile/Backend same schema)

Killer Features:

  • One Schema = Props + Validation + Docs + Storybook
  • Add component: Write 10 lines JSON β†’ auto-generate everything
  • Design system enforcement: $ref: colors.schema.json β†’ impossible to violate
  • Frontend/backend alignment: Same schema, all platforms

Details β†’

πŸ“š Documentation Structure

schema-driven-development/
β”œβ”€β”€ README.md                          # You are here
β”œβ”€β”€ SKILL.md                           # Core methodology (879 lines)
β”‚
β”œβ”€β”€ methodology/                       # Design patterns
β”‚   β”œβ”€β”€ type-system-revolution.md     # ⭐ Why 70% time on types?
β”‚   β”œβ”€β”€ json-as-object.md             # JSON = Object pattern
β”‚   └── component-library-pattern.md  # Component killer app
β”‚
β”œβ”€β”€ references/                        # Language implementations
β”‚   β”œβ”€β”€ quick-start.md                # 5-minute tutorial
β”‚   β”œβ”€β”€ rust/
β”‚   β”‚   └── jsonschema-runtime.md     # Runtime validation
β”‚   β”œβ”€β”€ typescript/
β”‚   β”‚   └── ajv-validation.md         # Frontend validation
β”‚   β”œβ”€β”€ python/
β”‚   └── swift/
β”‚
β”œβ”€β”€ examples/                          # Runnable examples
β”‚   β”œβ”€β”€ schema-registry.rs            # Rust Registry (260 lines)
β”‚   └── ci-cd-workflow.yml            # GitHub Actions (360 lines)
β”‚
β”œβ”€β”€ case-studies/                      # Real projects
β”‚   β”œβ”€β”€ claude-tui-rs/                # Streaming events (40x)
β”‚   └── ui-component-library/         # Components (4-6x)
β”‚
└── docs/
    └── zh-CN/                         # Chinese documentation

πŸŽ“ Learning Path

Beginner (30 minutes)

  1. Read Quick Start (5 min)
  2. Understand Core Concept (10 min)
  3. Try First Example (15 min)

Intermediate (2 hours)

  1. Study JSON-as-Object Pattern
  2. Implement Schema Registry
  3. Setup CI/CD Automation

Advanced (1 day)

  1. Analyze Claude TUI RS (how 40x achieved)
  2. Study Component Library
  3. Design team collaboration workflow

πŸ’‘ The Type System Revolution

Why 70% Time on Types?

Traditional Programming:

Time Breakdown:
  - Define types: 30-40%
  - Write validation: 20-30%
  - Sync types (frontend/backend): 10-15%
  - Type-related total: 60-85%
  - Business logic: 15-40% ← Real value!

Schema-DD:

Time Breakdown:
  - Define schema: 10 min
  - Auto-generate types: 0 min
  - Auto-validation: 0 min
  - Business logic: 30 min ← 75% of time!

Revolutionary Change:

From "types in code"     β†’ "types in data"
From "70% on types"      β†’ "25% on types, 75% on logic"
From "frontend/backend   β†’ "single source of truth,
      out of sync"           perfect sync"

Read full analysis β†’

πŸ”§ Tech Stack

Backend (Rust)

  • jsonschema - JSON Schema validation (10-100x faster than Python)
  • serde_json - JSON processing
  • axum - Web framework
  • lazy_static - Global variables

Frontend (TypeScript)

  • ajv - JSON Schema validation
  • json-schema-to-typescript - Type generation

CI/CD

  • GitHub Actions
  • ajv-cli - Schema validation
  • spectral - Schema linting
  • specmatic - Contract testing

Documentation

  • json-schema-to-markdown
  • Swagger UI / ReDoc
  • OpenAPI Generator

🎯 Use Cases

Perfect For

  • βœ… REST API development
  • βœ… Microservices architecture
  • βœ… Frontend/backend separation
  • βœ… Multi-team collaboration
  • βœ… UI component libraries
  • βœ… Low-code platforms
  • βœ… Enterprise applications

Not For

  • ❌ Monolithic apps (too heavy)
  • ❌ Quick prototypes (initial overhead)
  • ❌ Non-API projects
  • ❌ Fully dynamic APIs

🀝 Contributing

We welcome contributions!

  • Report bugs
  • Suggest improvements
  • Share your success stories
  • Contribute language examples (Go, Java, C#, etc.)
  • Add real-world case studies

See CONTRIBUTING.md

πŸ“„ License

MIT License

πŸŽ‰ Why Schema-DD?

Traditional Pain Points

  • ❌ Frontend/backend API contracts out of sync
  • ❌ Manually writing repetitive validation tests
  • ❌ Outdated API documentation
  • ❌ Type definitions scattered everywhere
  • ❌ Difficult version evolution

Schema-DD Solutions

  • βœ… Single Source of Truth: One schema rules them all
  • βœ… TDD 2.0: Modify schema = modify all tests
  • βœ… Runtime Validation: Rust 10-100x faster than Python
  • βœ… Full Automation: CI/CD handles everything
  • βœ… Cross-Language: Perfect frontend/backend sync

Efficiency Gains

  • Development Speed: 4-10x improvement
  • Documentation Accuracy: 100% (auto-generated)
  • Error Rate: 100x reduction
  • Maintenance Cost: 80-90% reduction

Get Started: Quick Start Guide

Deep Dive: Full Methodology (SKILL.md)

Real Examples: Case Studies

Language References: References


Made with ❀️ by Schema-DD Community

Star ⭐ this repo if you believe in the Type System Revolution!

About

The Type System Revolution: Stop wasting 70% of your time on types, focus on business logic

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors