# Models and relationships

The proposed domain graph connects source evidence to measurable outcomes:

```txt
SourceSystem
   ↓
SourceAsset
   ↓
Evidence
   ↓
StormEvent
   ↓
StormEventRevision
   ↓
HailSwath
   ↓
ImpactAssessment
   ↓
Property
   ↓
ActionPlan
   ↓
Assignment or Campaign
   ↓
Activity
   ↓
Outcome
   ↓
Attribution
```

Model status

The data service implements source assets, storm events, storm revisions, revision products, an outbox, backfills, dataset versions, administrative-area catalog entries, parcel-partition catalog entries, exposure runs, and evaluation cases. The remaining models define the target domain contract.

## Weather models

### SourceSystem

```txt
id
slug
name
provider
status
dataClassification
licenseReference
createdAt
updatedAt
```

### SourceAsset

```txt
id
sourceSystemId
externalId
product
region
observedAt
acquiredAt
contentHash
rawObjectKey
status
metadata
```

Implemented source-asset identity is `(source, sourceKey, sourceVersion)`. ` sourceVersion` uses available source modification metadata so a provider correction does not overwrite an earlier input. Event processing also keys the materialization by ` eventId`, which permits deliberate promotion from the live feed to a benchmark.

### Evidence

```txt
id
sourceAssetId
type
classification
geometry
value
unit
confidence
observedAt
metadata
```

## Storm models

### StormEvent

```txt
id
type
status
startedAt
endedAt
currentRevisionId
createdAt
updatedAt
```

### StormEventRevision

```txt
id
eventId
revision
geometry
severity
confidence
maxEstimatedHail
labels
algorithmReleaseId
createdAt
```

### HailSwath

```txt
id
eventRevisionId
product
windowMinutes
geometry
maximum
unit
sourceMetadata
```

### GroundReport

```txt
id
eventId
source
sourceId
reportedAt
geometry
hailSize
unit
status
classification
```

## Property models

### Property

```txt
id
tenantId?
normalizedAddress
latitude
longitude
parcelId
structureId
sourceMetadata
```

The architecture carefully separates public or shared property identity from tenant-owned enrichment.

### Parcel

```txt
id
provider
providerId
geometry
landUse
metadata
```

The current D1 schema catalogs parcel partitions rather than one nationwide row per geometry. R2 holds bulk, immutable partition artifacts. No production parcel release is ingested.

### Structure

```txt
id
propertyId
geometry
buildingArea
useType
metadata
```

### Roof

```txt
id
structureId
material
estimatedAge
area
pitch
source
confidence
```

### ImpactAssessment

```txt
id
eventId
eventRevisionId
propertyId
meshMax
poshMax
exposure
damageLikelihood
confidence
opportunityScore
eligibilityState
algorithmReleaseId
```

## Action models

### ActionPlan

```txt
id
tenantId
eventId
eventRevisionId
version
status
strategy
createdBy
approvedBy
```

### DeploymentZone

```txt
id
actionPlanId
geometry
priority
candidateCount
capacity
```

### Assignment

```txt
id
tenantId
assigneeId
propertyId?
territoryId?
actionPlanId
status
dueAt
```

### Outcome

```txt
id
tenantId
sourceType
sourceId
type
value
occurredAt
metadata
```

## CRM and campaign models

CRM models include Lead, Contact, Opportunity, and Activity. They support external integration IDs without letting one provider schema define the internal domain.

Campaign models include Audience, AudienceMember, Campaign, CampaignRevision, CampaignMember, and Attribution.

## Evidence models

Evidence models include EvidenceItem, Attachment, ProvenanceManifest, Report, and Review.

## Relationships

Representative relationships include:

```txt
StormEvent
   ├── hasMany → StormEventRevision
   ├── hasMany → GroundReport
   ├── hasMany → ImpactAssessment
   └── hasMany → ActionPlan

StormEventRevision
   ├── belongsTo → StormEvent
   ├── hasMany → Evidence
   └── hasMany → HailSwath

Property
   ├── belongsTo → Parcel
   ├── hasOneOrMany → Structure
   ├── hasMany → ImpactAssessment
   ├── hasMany → Monitor
   └── hasMany → FieldVisit

ImpactAssessment
   ├── belongsTo → Property
   ├── belongsTo → StormEvent
   └── mayProduce → Assignment or AudienceCandidate

Campaign
   ├── belongsTo → StormEvent?
   ├── hasMany → CampaignMember
   └── hasMany → Attribution
```
