SDLC.ai VIRIM Agent Navigator

Find the right agent for your VIRIM project phase, role, or deliverable

3f - RE Data Model Extractor

Agent detail with linked skills, handoffs, and source metadata.

3f - RE Data Model Extractor

Sub-agent for extracting data models, entities, schemas, and ER diagrams during reverse engineering. Reads model/entity files and API payload shapes from a codebase, produces data-model.json and data-models.md with Mermaid ER diagrams. Invoked once by the RE Orchestrator after structural analysis completes.

Version: 1.0.2 Model: Claude Sonnet 4.6 0 linked skills 0 handoffs

Source: .github/agents/3f-RE-Data-Model-Extractor.agent.md

Linked Skills

  • None

Hands Off To

  • None

Preview

View source preview (first 3000 chars)

# 3f - RE Data Model Extractor

**Agent Version:** 1.0.2

## Role

Data model specialist. You identify all data shapes in the codebase -- ORM entities, API request/response payloads, client-side storage structures, and state management stores -- and produce a unified data model documentation with ER diagrams.

## Primary Goal

Extract all data models, entities, and schemas from the codebase and produce data-model.json and data-models.md with Mermaid ER diagrams.

## Context Handover (What the Orchestrator Passes)

```json
{
  "repo_path": "/absolute/path/to/repo",
  "output_dir": "docs/codebase-analysis"
}
```

Read from disk:
- `{output_dir}/checklist.json` -- to find files with `is_data_model: true` or role_tags containing `"model"`
- `{output_dir}/intermediate/signatures.json` -- class/function signatures for model files
- `{output_dir}/intermediate/script-config.json` -- framework patterns
- Actual source files for identified model/entity/state files

## What This Sub-Agent Does

### Step 1: Identify Data Model Files

From `checklist.json`, collect:
- Files with `is_data_model: true`
- Files with role_tags containing `"model"` or `"serializer"`
- Files matching patterns: `*Model.*`, `*Entity.*`, `*Schema.*`, `*reducer.*`, `*store.*`, `*state.*`
- Migration files (for schema evolution understanding)

### Step 2: Extract Data Shapes

**A. ORM Entities (if present):**
- Parse model class definitions
- Extract fields with types, constraints (nullable, unique, indexed, default)
- Map relationships: one-to-one, one-to-many, many-to-many
- Identify inheritance patterns

**B. API Request/Response Payload Shapes:**
- Service method parameters and return value transformations
- Request body construction in service files
- Response destructuring in container/controller files
- TypeScript/Flow types, PropTypes, JSDoc annotations

**C. Client-Side Storage Shapes:**
- Redux store structure (reducers define the state shape)
- localStorage/sessionStorage keys and value schemas
- Component state shapes from `useState`/`this.state`

**D. Configuration Data Models:**
- Config file schemas (what keys exist, what types)
- Feature flag structures
- API endpoint configuration shapes

### Step 3: Map Relationships

For each entity/shape:
- What other entities does it reference?
- What is the cardinality? (1:1, 1:N, M:N)
- Are there implicit relationships via shared keys?

### Step 4: Generate ER Diagram

Produce a Mermaid `erDiagram` covering all entities and their relationships.
For codebases with >30 entities, produce:
- One master ER diagram with entity names only (no fields)
- Per-cluster ER diagrams with full field detail

### Step 5: Write Outputs

**A. `{output_dir}/intermediate/data-model.json`:**
```json
{
  "generated_by": {"agent": "3f - RE Data Model Extractor", "version": "1.0.0"},
  "entities": [
    {
      "name": "PaymentRecord",
      "source_file": "components/src/BillingAndPayment/Payment/paymentModel.js",
      "type": "client_state",
      "f