https://github.com/woolkingx/schema-driven-development
The Type System Revolution: Stop wasting 70% of your time on types, focus on business logic
https://github.com/woolkingx/schema-driven-development
api-contract contract-testing cross-language json-schema runtime-validation rust schema-driven tdd type-system typescript
Last synced: 15 days ago
JSON representation
The Type System Revolution: Stop wasting 70% of your time on types, focus on business logic
- Host: GitHub
- URL: https://github.com/woolkingx/schema-driven-development
- Owner: woolkingx
- License: mit
- Created: 2026-02-01T13:23:55.000Z (27 days ago)
- Default Branch: main
- Last Pushed: 2026-02-01T13:24:49.000Z (27 days ago)
- Last Synced: 2026-02-01T23:08:52.022Z (27 days ago)
- Topics: api-contract, contract-testing, cross-language, json-schema, runtime-validation, rust, schema-driven, tdd, type-system, typescript
- Size: 60.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Schema-Driven Development
> The Type System Revolution: Stop wasting 70% of your time on types, focus on business logic
[](https://opensource.org/licenses/MIT)
[](CONTRIBUTING.md)
[中文文档](./docs/zh-CN/README.md) | [日本語](./docs/ja/README.md)
## 🎯 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**:
```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**:
```rust
// Duplicate everything in Rust (1 hour)
struct User { /* ... */ }
fn validate_user() { /* ... */ }
```
### Schema-DD Way (40 minutes)
**One Schema** (10 min):
```json
{
"$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):
```typescript
// 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-studies/claude-tui-rs/)
### 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 →](./case-studies/ui-component-library/)
## 📚 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](./references/quick-start.md) (5 min)
2. Understand [Core Concept](./SKILL.md#core-concept) (10 min)
3. Try [First Example](./examples/user-api/) (15 min)
### Intermediate (2 hours)
1. Study [JSON-as-Object Pattern](./methodology/json-as-object.md)
2. Implement [Schema Registry](./examples/schema-registry.rs)
3. Setup [CI/CD Automation](./examples/ci-cd-workflow.yml)
### Advanced (1 day)
1. Analyze [Claude TUI RS](./case-studies/claude-tui-rs/) (how 40x achieved)
2. Study [Component Library](./case-studies/ui-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 →](./methodology/type-system-revolution.md)
## 🔧 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](./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](./references/quick-start.md)
**Deep Dive**: [Full Methodology (SKILL.md)](./SKILL.md)
**Real Examples**: [Case Studies](./case-studies/)
**Language References**: [References](./references/)
---
Made with ❤️ by Schema-DD Community
**Star ⭐ this repo if you believe in the Type System Revolution!**