Data Schema (ER)¶
Ниже полный набор схем Phase 1, разбитый по доменам.
1) Reference + Ingest¶
erDiagram
REF_CHAINS {
uuid chain_id PK
string slug
string display_name
datetime created_at
datetime updated_at
}
REF_NETWORKS {
uuid network_id PK
uuid chain_id FK
string slug
string display_name
string rpc_url
int finality_depth
bool is_active
datetime created_at
datetime updated_at
}
REF_TOKEN_STANDARDS {
uuid standard_id PK
uuid chain_id FK
string slug
string display_name
}
REF_MARKETPLACES {
uuid marketplace_id PK
uuid network_id FK
string slug
string display_name
datetime created_at
datetime updated_at
}
INGEST_RAW_EVENTS {
uuid raw_event_id PK
uuid network_id FK
bigint block_number
string tx_hash
int log_index
string source_event_id
string finality_status
datetime received_at
}
REF_CHAINS ||--o{ REF_NETWORKS : has
REF_CHAINS ||--o{ REF_TOKEN_STANDARDS : has
REF_NETWORKS ||--o{ REF_MARKETPLACES : has
REF_NETWORKS ||--o{ INGEST_RAW_EVENTS : ingests
2) Ledger¶
erDiagram
REF_NETWORKS {
uuid network_id PK
}
LEDGER_NORMALIZED_EVENTS {
uuid normalized_event_id PK
uuid network_id FK
uuid asset_id
uuid collection_id
string event_kind
string contract_address
bigint block_number
string tx_hash
bigint timestamp
string finality_status
datetime created_at
}
LEDGER_NORMALIZED_EVENT_KEYS {
bigint id PK
string source_event_id
int sub_index
uuid normalized_event_id FK
bool is_reverted
}
LEDGER_NORMALIZED_EVENT_DELTAS {
bigint id PK
uuid normalized_event_id FK
string account_address
int qty_delta
}
LEDGER_APPLIED_EVENTS {
string consumer_id PK
uuid normalized_event_id FK
datetime applied_at
}
REF_NETWORKS ||--o{ LEDGER_NORMALIZED_EVENTS : network
LEDGER_NORMALIZED_EVENTS ||--o{ LEDGER_NORMALIZED_EVENT_KEYS : dedupe_keys
LEDGER_NORMALIZED_EVENTS ||--o{ LEDGER_NORMALIZED_EVENT_DELTAS : deltas
LEDGER_NORMALIZED_EVENTS ||--o{ LEDGER_APPLIED_EVENTS : idempotency
3) Catalog + Market¶
erDiagram
REF_NETWORKS {
uuid network_id PK
}
CATALOG_COLLECTIONS {
uuid collection_id PK
uuid network_id FK
string contract_address
string name
bool is_stub
datetime created_at
datetime updated_at
}
CATALOG_ASSETS {
uuid asset_id PK
uuid collection_id FK
string token_id
string name
string image_url
bool is_stub
datetime created_at
datetime updated_at
}
MARKET_OWNERSHIP_CURRENT {
bigint id PK
uuid asset_id
string account_address
int qty
string finality_status
datetime updated_at
}
MARKET_LISTINGS_CURRENT {
uuid listing_id PK
uuid asset_id
string marketplace_slug
string seller
numeric price
string currency
datetime listed_at
}
MARKET_SALES_HISTORY {
uuid sale_id PK
uuid asset_id
string seller
string buyer
numeric price
string currency
datetime sold_at
}
REF_NETWORKS ||--o{ CATALOG_COLLECTIONS : has
CATALOG_COLLECTIONS ||--o{ CATALOG_ASSETS : contains
CATALOG_ASSETS ||--o{ MARKET_OWNERSHIP_CURRENT : owned_state
CATALOG_ASSETS ||--o{ MARKET_LISTINGS_CURRENT : active_listings
CATALOG_ASSETS ||--o{ MARKET_SALES_HISTORY : sale_history
4) Projection Read Models¶
erDiagram
CATALOG_COLLECTIONS {
uuid collection_id PK
}
CATALOG_ASSETS {
uuid asset_id PK
uuid collection_id FK
}
MARKET_OWNERSHIP_CURRENT {
bigint id PK
uuid asset_id
string account_address
}
MARKET_LISTINGS_CURRENT {
uuid listing_id PK
uuid asset_id
uuid collection_id
}
PROJECTION_OWNERSHIP_VIEW {
bigint id PK
uuid asset_id
string owner_address
int qty
string finality_status
datetime updated_at
}
PROJECTION_ASSET_CARDS {
uuid asset_id PK
uuid collection_id
string name
string image_url
bool is_stub
numeric floor_price
numeric last_sale_price
string finality_status
datetime updated_at
}
PROJECTION_COLLECTION_STATS {
uuid collection_id PK
numeric floor_price
numeric total_volume
int owner_count
int asset_count
int listed_count
datetime updated_at
}
PROJECTION_PORTFOLIO_ASSETS {
bigint id PK
string owner_address
uuid asset_id
int qty
numeric estimated_value_usd
datetime updated_at
}
PROJECTION_LISTING_CARDS {
uuid listing_id PK
uuid asset_id
uuid collection_id
string seller
numeric price
string currency
string asset_name
string asset_image_url
datetime listed_at
}
CATALOG_ASSETS ||--o{ PROJECTION_ASSET_CARDS : project_asset
CATALOG_COLLECTIONS ||--o{ PROJECTION_COLLECTION_STATS : aggregate_collection
MARKET_OWNERSHIP_CURRENT ||--o{ PROJECTION_OWNERSHIP_VIEW : project_ownership
MARKET_OWNERSHIP_CURRENT ||--o{ PROJECTION_PORTFOLIO_ASSETS : aggregate_portfolio
MARKET_LISTINGS_CURRENT ||--o{ PROJECTION_LISTING_CARDS : project_listings
5) System / Operations¶
erDiagram
REF_NETWORKS {
uuid network_id PK
string slug
}
SYSTEM_SYNC_CURSORS {
uuid network_id PK
bigint last_block
string last_block_hash
datetime last_updated_at
}
SYSTEM_OUTBOX_EVENTS {
uuid event_id PK
string topic
json payload
datetime created_at
datetime published_at
}
SYSTEM_DLQ {
uuid dlq_id PK
uuid event_id FK
string error
int attempts
datetime last_attempt_at
}
SYSTEM_API_KEYS {
uuid key_id PK
string key_hash
string label
bool is_active
datetime created_at
}
REF_NETWORKS ||--|| SYSTEM_SYNC_CURSORS : cursor
SYSTEM_OUTBOX_EVENTS ||--o{ SYSTEM_DLQ : failed_delivery
Source of truth¶
- SQL DDL:
migrations/001_baseline.sql - Seed data:
migrations/002_seed_ref_data.sql - ORM models:
src/ft/core/models/*.py