Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

CodeUChain Examples

Comprehensive examples demonstrating CodeUChain v2.0 in both TypeScript and Python.

Structure

Each directory demonstrates a specific concept in isolation, with full test coverage:

examples/
├── 01-state/          # State: Immutable data container
├── 02-link/           # Link: Single unit of business logic
├── 03-chain/          # Chain: Orchestration layer
├── 04-hook/           # Hook: Cross-cutting concerns
├── 05-integration/    # All parts working together
└── BEST_PRACTICES.md  # Guidelines for building pipelines

Testing Philosophy

These examples follow a three-tier testing strategy:

  1. Unit Tests (Isolation): Each component tested independently
  2. Integration Tests: Components working together
  3. Trust but Verify: Runnable tests prove documentation accuracy

Running Tests

TypeScript

cd 01-state && node --test state.test.ts.js
cd 02-link && node --test link.test.ts.js
cd 03-chain && node --test chain.test.ts.js
cd 04-hook && node --test hook.test.ts.js
cd 05-integration && node --test integration.test.ts.js

Python

cd 01-state && python3 -m pytest test_state.py -v
cd 02-link && python3 -m pytest test_link.py -v
cd 03-chain && python3 -m pytest test_chain.py -v
cd 04-hook && python3 -m pytest test_hook.py -v
cd 05-integration && python3 -m pytest test_integration.py -v

All Tests

./verify-examples.sh

Concept Overview

Concept Purpose Analogy
State Immutable data container The "box" on the belt
Link Single transformation A "station"
Chain Orchestration The "conveyor belt"
Hook Cross-cutting concerns "Sensors" observing the belt

Learning Path

  1. 01-state: Understand immutability
  2. 02-link: Single-responsibility transformations
  3. 03-chain: Orchestration patterns
  4. 04-hook: Add observability
  5. 05-integration: Real-world registration flow
  6. BEST_PRACTICES.md: Production guidelines