Step 3: Extract Components
Objective
Find all component instances using patterns from Step 2 and add them to the graph via CLI.
Prerequisites
- Do not use plan mode. Execute directly.
- Read
.riviere/config/metadata.mdfor domains and conventions - Read
.riviere/config/component-definitions.mdfor extraction rules - CLI installed:
npm install @living-architecture/riviere-cli
Initialize Graph
Create graph with sources and domains:
npx riviere builder init \
--source "https://github.com/your-org/your-repo" \
--domain '{"name":"[name]","description":"[desc]","systemType":"domain"}'Add additional sources if needed:
npx riviere builder add-source --repository "https://github.com/your-org/your-repo"Add additional domains if needed:
npx riviere builder add-domain --name "[name]" --system-type "[domain|bff|ui|other]" --description "[desc]"Define custom types (for accepted proposals in component-definitions.md):
npx riviere builder define-custom-type \
--name "[CustomTypeName]" \
--description "[description]" \
--required-property "propertyName:type:description" \
--optional-property "propertyName:type:description"Example (BackgroundJob with schedule property):
npx riviere builder define-custom-type \
--name "BackgroundJob" \
--description "Scheduled background task running on an interval" \
--required-property "schedule:string:Cron expression or interval"Extract Components
No planning or counting. Extract directly using patterns from Step 2.
1. Find All Instances
For each component type, grep for its code signature:
# Examples - actual patterns come from Step 2
grep -rn "@Controller" src/
grep -rn "extends BaseUseCase" src/
grep -rn "@EventHandler" src/This gives file paths and line numbers for ALL occurrences.
2. Process Each Match
For each grep result:
- Read the file at that location
- Extract component details (name, domain, HTTP method, etc.)
- Add via CLI
npx riviere builder add-component \
--type "[API|UseCase|DomainOp|Event|EventHandler|UI|Custom]" \
--domain "[domain]" \
--module "[module]" \
--name "[name]" \
--repository "[repo]" \
--file-path "[path]" \
--line-number "[line]"Type-specific options:
- API:
--api-type(required),--http-method,--http-path - DomainOp:
--entity,--operation-name - Event:
--event-name,--event-schema - EventHandler:
--subscribed-events - UI:
--route - Custom:
--custom-type,--custom-property(repeatable, format:key:value)
3. Complete Each Type
Finish ALL matches for one component type before starting the next:
APIs (@Controller): 12 matches → 18 endpoints extracted
UseCases (extends BaseUseCase): 8 matches → 8 use cases extractedIf grep pattern doesn't work (e.g., complex dynamic patterns), note it and ask user if a script is needed.
Verify Extraction
Generate summary:
npx riviere builder component-summary > ".riviere/step-3-summary.json"Check for:
- Domains with zero components
- Component types with zero instances
- Unexpected counts suggesting missed patterns
Offer to run a sub-agent to scan for components that may have been missed.
Feedback
If user reports missing components, update .riviere/config/component-definitions.md with corrected patterns and re-extract.
Output
Graph: .riviere/[project-name]-[commit].json
Completion
Present extraction summary showing component counts by domain and type.
Step 3 complete. Wait for user feedback before proceeding.