# State Entity Relationship Diagram

## Schema

<!-- BEGIN_SQLALCHEMY_DOCS -->
```mermaid

---
    config:
        layout: elk
---
erDiagram
  context {
    INTEGER run_id FK "nullable"
    BLOB context "nullable"
  }

  logs {
    INTEGER run_id FK "nullable"
    VARCHAR log "nullable"
    INTEGER node_id "nullable"
    FLOAT timestamp "nullable"
  }

  message_ins {
    INTEGER run_id FK "nullable"
    BLOB content "nullable"
    FLOAT created_at "nullable"
    VARCHAR delivered_at "nullable"
    INTEGER dst_node_id "nullable"
    BLOB error "nullable"
    VARCHAR group_id "nullable"
    VARCHAR message_id UK "nullable"
    VARCHAR message_type "nullable"
    VARCHAR reply_to_message_id "nullable"
    INTEGER src_node_id "nullable"
    FLOAT ttl "nullable"
  }

  message_res {
    INTEGER run_id FK "nullable"
    BLOB content "nullable"
    FLOAT created_at "nullable"
    VARCHAR delivered_at "nullable"
    INTEGER dst_node_id "nullable"
    BLOB error "nullable"
    VARCHAR group_id "nullable"
    VARCHAR message_id UK "nullable"
    VARCHAR message_type "nullable"
    VARCHAR reply_to_message_id "nullable"
    INTEGER src_node_id "nullable"
    FLOAT ttl "nullable"
  }

  node {
    FLOAT heartbeat_interval "nullable"
    VARCHAR last_activated_at "nullable"
    VARCHAR last_deactivated_at "nullable"
    INTEGER node_id UK "nullable"
    TIMESTAMP online_until "nullable"
    VARCHAR owner_aid "nullable"
    VARCHAR owner_name "nullable"
    BLOB public_key UK "nullable"
    VARCHAR registered_at "nullable"
    VARCHAR status "nullable"
    VARCHAR unregistered_at "nullable"
  }

  object_children {
    VARCHAR child_id PK,FK
    VARCHAR parent_id PK,FK
  }

  objects {
    VARCHAR object_id PK "nullable"
    BLOB content "nullable"
    INTEGER is_available
    INTEGER ref_count
  }

  run {
    INTEGER bytes_recv "nullable"
    INTEGER bytes_sent "nullable"
    FLOAT clientapp_runtime "nullable"
    VARCHAR details "nullable"
    VARCHAR fab_hash "nullable"
    VARCHAR fab_id "nullable"
    VARCHAR fab_version "nullable"
    VARCHAR federation "nullable"
    BLOB federation_options "nullable"
    VARCHAR finished_at "nullable"
    VARCHAR flwr_aid "nullable"
    VARCHAR override_config "nullable"
    VARCHAR pending_at "nullable"
    INTEGER run_id UK "nullable"
    VARCHAR running_at "nullable"
    VARCHAR starting_at "nullable"
    VARCHAR sub_status "nullable"
  }

  run_objects {
    VARCHAR object_id PK,FK
    INTEGER run_id PK
  }

  token_store {
    INTEGER run_id PK "nullable"
    FLOAT active_until "nullable"
    VARCHAR token UK
  }

  run ||--o| context : run_id
  run ||--o{ logs : run_id
  run ||--o{ message_ins : run_id
  run ||--o{ message_res : run_id
  objects ||--o| object_children : parent_id
  objects ||--o| object_children : child_id
  objects ||--o| run_objects : object_id

```
<!-- END_SQLALCHEMY_DOCS -->
