Pattern Learning & Scaffolding — Architecture

Pattern Library Service (Approach B) — how patterns flow from extraction to generation

System Architecture
┌─────────────────────────────────────────────────────────────────┐ │ Existing Projects │ │ Fastblocks / Splashstand / Future Apps │ └──────────────────────┬──────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ Pattern Extractor (Mahavishnu module) │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ 1. Scan project structure (dirs, config, entry points) │ │ │ │ 2. Detect recurring conventions (template blocks, │ │ │ │ adapter wiring, HTMX patterns) │ │ │ │ 3. Suggest new patterns to human curator │ │ │ └─────────────────────────────────────────────────────────┘ │ └──────────────────────┬──────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ Pattern Library (YAML files + query module) │ │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ scaffolding/ │ │ components/ │ │ deployment/ │ │ │ │ project.yaml │ │ table.yaml │ │ cloudrun.yml│ │ │ │ auth.yaml │ │ form.yaml │ │ docker.yml │ │ │ │ dashboard.yl │ │ nav.yaml │ │ │ │ │ └──────────────┘ └──────────────┘ └──────────────┘ │ └──────────────────────┬──────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ Scaffolding Engine (Mahavishnu module) │ │ ┌─────────────────────────────────────────────────────────┐ │ │ │ 1. Compose project from selected patterns │ │ │ │ 2. Generate skeleton (dirs, config, entry point) │ │ │ │ │ → Pattern-driven, not hardcoded │ │ │ │ 3. Chat-driven refinement for custom parts │ │ │ │ → Business logic, specific pages, custom components │ │ │ │ 4. Validate output (structure matches pattern spec) │ │ │ └─────────────────────────────────────────────────────────┘ │ └──────────────────────┬──────────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ New Fastblocks App (on disk, ready to run) │ │ my-new-app/ │ │ ├── main.py ← from project.yaml │ │ ├── settings/ ← from project.yaml │ │ ├── templates/ ← from component patterns │ │ │ ├── base/ │ │ │ │ └── blocks/ ← nav.yaml, table.yaml, form.yaml │ │ │ └── pages/ ← chat-generated custom pages │ │ ├── adapters/ ← from auth.yaml, etc. │ │ └── pyproject.toml ← from project.yaml │ └─────────────────────────────────────────────────────────────────┘

Three modules, one pipeline:

Green = new code in this spec. Blue = builds on existing specs (1, 2, 3).