# Model Extraction

## Context

Module: {{MODULE_NAME}}
Feature docs: {{FEATURE_DOCS}}

## Instructions

Read ALL feature docs and extract entity/model definitions.

1. Read ALL feature docs at the paths above
2. For each feature, identify entities that need database models
3. For each entity, extract:
   - Fields and their types
   - Relationships to other entities
   - State machines (if stateful)
   - Required constraints (unique, required, etc.)
4. Resolve cross-feature entity references (same entity mentioned in multiple features)

## Extraction Rules

### Entity Identification

- Look for nouns that represent persistent data
- Check for explicit "Entity" or "Model" mentions
- Identify implicit entities from relationship descriptions

### Field Extraction

- Map feature attributes to database field types
- Identify required vs optional fields
- Note any validation constraints

### State Machine Extraction

- Look for state diagrams or transition descriptions
- Extract all possible states
- Map transitions to operations (verbs → commands)

### Relationship Extraction

- Identify foreign key relationships (N-1, 1-1)
- Identify junction table needs (N-N)
- Note cross-module entity references

## Output Format

Return your extraction as a structured markdown report:

### Models

For each model:

#### <ModelName>

- **Source features:** list of feature files
- **Fields:**

| Field | Type | Required | Description |
| ----- | ---- | -------- | ----------- |

- **Relationships:**

| Type | Target | Field | Cross-module |
| ---- | ------ | ----- | ------------ |

- **States:** list of states (if stateful)
- **State Transitions:**

| From | To  | Trigger (command) |
| ---- | --- | ----------------- |
