Library vs CLI
Riviere offers two paths for building architecture graphs. Choose based on your use case.
Schema version: v1.0
What you'll learn
- When the CLI is the best fit (AI-assisted extraction, deterministic validation)
- When the TypeScript library is the best fit (custom extraction, pipeline integration)
- Which docs to read next for each path
Quick Decision
| Use Case | Path |
|---|---|
| AI-assisted extraction from code | CLI |
| Custom extraction logic | Library |
| Shell-based automation | CLI |
| Programmatic control in code | Library |
| Validate AI-generated components | CLI |
| Embed in build pipeline | Library |
CLI Path
The CLI is designed for AI-assisted extraction workflows. AI analyzes code and calls CLI commands to build the graph.
Best for:
- Extracting architecture from existing codebases
- AI agents that need deterministic validation
- Interactive, step-by-step graph building
- Error recovery with near-match suggestions
How it works:
- AI analyzes codebase structure and patterns
- AI calls CLI commands to add components and links
- CLI validates each operation and provides feedback
- AI self-corrects based on CLI error messages
bash
riviere builder init --name "my-service"
riviere builder add-domain --name "orders" --type "domain" --description "Order management"
riviere builder add-component --type API --domain orders --module api \
--http-method POST --path /orders \
--repository my-repo --source-file src/api/orders.ts --source-line 10Start here: CLI Quick Start
Library Path
The Library provides programmatic control for building graphs in TypeScript code.
Best for:
- Custom extraction tools
- Build pipeline integration
- Automated graph generation
- Testing and validation tooling
How it works:
- Import the RiviereBuilder class
- Configure metadata (sources, domains)
- Add components programmatically
- Link components and enrich with metadata
- Validate and export the graph
typescript
import { RiviereBuilder } from '@living-architecture/riviere-builder'
const builder = new RiviereBuilder({
name: 'my-service',
domains: { orders: { description: 'Order management', systemType: 'domain' } },
sources: [{ repository: 'my-repo' }]
})
const api = builder.addApi({
domain: 'orders',
module: 'api',
httpMethod: 'POST',
path: '/orders',
sourceLocation: { repository: 'my-repo', filePath: 'src/api/orders.ts', lineNumber: 10 }
})
const graph = builder.build()Start here: Library Quick Start
Both Paths, Same Output
Library and CLI produce identical, schema-compliant Riviere graphs. Choose based on workflow, not output format.
Shared Concepts
Both paths use the same underlying concepts:
- Graph Structure — Components, links, domains
- ID Generation — Deterministic component IDs
- Validation Rules — What gets validated and when
- Error Messages — Understanding and fixing errors