{
  "schemaVersion": "0.1",
  "diagramFamily": "architecture",
  "scene": {
    "id": "gcp-architecture-from-terraform",
    "title": "Listings platform on Google Cloud (production)",
    "brief": "Production Google Cloud architecture of the listings platform, drawn from the Terraform in infra/production.\nDrawn as Google Cloud reference diagrams are: gcp.* groups nested Google Cloud > Region > subnet > tiers, a gcp.vpc spanning both subnets and a gcp.zone spanning each zone's cards. Each resource that runs or stores something is a card with its gcp: icon, in the innermost group it runs in. Each subnet lists its web tier, internal load balancer, app tier, Memorystore instance and database tier, in that order. The NAM4 buckets share one card, stacked (style.multiple: true). A standby is gray (#DADCE0); no other card has a fill. A new VM also joins its zone's spans. Edges run from caller to callee. Web and app tier edges name the tier's frame, and database and cache edges name the instance. Leave layout off new nodes and frames. Each infrastructure pull request is a revision before terraform apply, its message starting with the PR number (PR 587: ...).",
    "units": "px",
    "canvas": {
      "width": 1600,
      "height": 1200,
      "background": "#ffffff"
    }
  },
  "elements": [
    { "id": "users", "kind": "node", "nodeType": "service", "icon": "gcp:users", "label": "Mobile and web users" },
    { "id": "cloud", "kind": "frame", "containerType": "gcp.cloud", "title": "Google Cloud", "children": ["armor", "glb", "cdn", "region_c1", "region_e1", "storage", "observability"] },
    { "id": "region_c1", "kind": "frame", "containerType": "gcp.region", "title": "Region: us-central1", "children": ["subnet_c1", "photos_topic", "thumbnailer"] },
    { "id": "subnet_c1", "kind": "frame", "containerType": "gcp.subnet", "title": "Subnet 10.10.0.0/20", "children": ["web_c1", "ilb_c1", "app_c1", "cache_c1", "db_c1"] },
    { "id": "web_c1", "kind": "frame", "containerType": "gcp.instanceGroup", "title": "Web tier", "children": ["web1_c1", "web2_c1", "web3_c1"] },
    { "id": "web1_c1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "Web server 1" },
    { "id": "web2_c1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "Web server 2" },
    { "id": "web3_c1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "Web server 3" },
    { "id": "ilb_c1", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-load-balancing", "label": "Internal load balancer" },
    { "id": "app_c1", "kind": "frame", "containerType": "gcp.instanceGroup", "title": "App tier", "children": ["app1_c1", "app2_c1", "app3_c1"] },
    { "id": "app1_c1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "App server 1" },
    { "id": "app2_c1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "App server 2" },
    { "id": "app3_c1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "App server 3" },
    { "id": "cache_c1", "kind": "node", "nodeType": "database", "icon": "gcp:memorystore", "label": "Listings cache" },
    { "id": "db_c1", "kind": "frame", "containerType": "gcp.tier", "title": "Database tier", "children": ["standby_c1", "primary_c1"] },
    { "id": "standby_c1", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-sql", "label": "Standby database", "style": { "fill": "#DADCE0" } },
    { "id": "primary_c1", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-sql", "label": "Primary database" },
    { "id": "region_e1", "kind": "frame", "containerType": "gcp.region", "title": "Region: us-east1", "children": ["subnet_e1"] },
    { "id": "subnet_e1", "kind": "frame", "containerType": "gcp.subnet", "title": "Subnet 10.20.0.0/20", "children": ["web_e1", "ilb_e1", "app_e1", "cache_e1", "db_e1"] },
    { "id": "web_e1", "kind": "frame", "containerType": "gcp.instanceGroup", "title": "Web tier", "children": ["web1_e1", "web2_e1", "web3_e1"] },
    { "id": "web1_e1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "Web server 1" },
    { "id": "web2_e1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "Web server 2" },
    { "id": "web3_e1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "Web server 3" },
    { "id": "ilb_e1", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-load-balancing", "label": "Internal load balancer" },
    { "id": "app_e1", "kind": "frame", "containerType": "gcp.instanceGroup", "title": "App tier", "children": ["app1_e1", "app2_e1", "app3_e1"] },
    { "id": "app1_e1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "App server 1" },
    { "id": "app2_e1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "App server 2" },
    { "id": "app3_e1", "kind": "node", "nodeType": "service", "icon": "gcp:compute-engine", "label": "App server 3" },
    { "id": "cache_e1", "kind": "node", "nodeType": "database", "icon": "gcp:memorystore", "label": "Listings cache" },
    { "id": "db_e1", "kind": "frame", "containerType": "gcp.tier", "title": "Database tier", "children": ["replica_e1"] },
    { "id": "replica_e1", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-sql", "label": "Read replica" },
    { "id": "armor", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-armor", "label": "Edge security policy" },
    { "id": "glb", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-load-balancing", "label": "Global external load balancer" },
    { "id": "cdn", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-cdn", "label": "Edge cache" },
    { "id": "storage", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-storage", "label": "Dual-region buckets", "style": { "multiple": true } },
    { "id": "observability", "kind": "node", "nodeType": "service", "icon": "gcp:observability", "label": "Logs, metrics and alerts" },
    { "id": "photos_topic", "kind": "node", "nodeType": "queue", "icon": "gcp:pubsub", "label": "Listing photos" },
    { "id": "thumbnailer", "kind": "node", "nodeType": "service", "icon": "gcp:cloud-run-functions", "label": "Thumbnail worker" },
    { "id": "vpc", "kind": "frame", "containerType": "gcp.vpc", "title": "VPC", "spans": ["subnet_c1", "subnet_e1"] },
    { "id": "zone_c1_a", "kind": "frame", "containerType": "gcp.zone", "title": "us-central1-a", "spans": ["web1_c1", "app1_c1", "standby_c1"] },
    { "id": "zone_c1_b", "kind": "frame", "containerType": "gcp.zone", "title": "us-central1-b", "spans": ["web2_c1", "app2_c1", "primary_c1"] },
    { "id": "zone_c1_c", "kind": "frame", "containerType": "gcp.zone", "title": "us-central1-c", "spans": ["web3_c1", "app3_c1"] },
    { "id": "zone_e1_b", "kind": "frame", "containerType": "gcp.zone", "title": "us-east1-b", "spans": ["web1_e1", "app1_e1"] },
    { "id": "zone_e1_c", "kind": "frame", "containerType": "gcp.zone", "title": "us-east1-c", "spans": ["web2_e1", "app2_e1", "replica_e1"] },
    { "id": "zone_e1_d", "kind": "frame", "containerType": "gcp.zone", "title": "us-east1-d", "spans": ["web3_e1", "app3_e1"] },
    { "id": "e_users", "kind": "edge", "from": { "elementId": "users" }, "to": { "elementId": "glb" } },
    { "id": "e_armor", "kind": "edge", "from": { "elementId": "armor" }, "to": { "elementId": "glb" }, "endpoints": { "startArrow": "none", "endArrow": "none" } },
    { "id": "e_cdn", "kind": "edge", "from": { "elementId": "cdn" }, "to": { "elementId": "glb" }, "endpoints": { "startArrow": "none", "endArrow": "none" } },
    { "id": "e_glb_c1", "kind": "edge", "from": { "elementId": "glb" }, "to": { "elementId": "web_c1" } },
    { "id": "e_glb_e1", "kind": "edge", "from": { "elementId": "glb" }, "to": { "elementId": "web_e1" } },
    { "id": "e_web_c1", "kind": "edge", "from": { "elementId": "web_c1" }, "to": { "elementId": "ilb_c1" } },
    { "id": "e_ilb_c1", "kind": "edge", "from": { "elementId": "ilb_c1" }, "to": { "elementId": "app_c1" } },
    { "id": "e_app_c1", "kind": "edge", "from": { "elementId": "app_c1" }, "to": { "elementId": "primary_c1" } },
    { "id": "e_cache_c1", "kind": "edge", "from": { "elementId": "app_c1" }, "to": { "elementId": "cache_c1" } },
    { "id": "e_web_e1", "kind": "edge", "from": { "elementId": "web_e1" }, "to": { "elementId": "ilb_e1" } },
    { "id": "e_ilb_e1", "kind": "edge", "from": { "elementId": "ilb_e1" }, "to": { "elementId": "app_e1" } },
    { "id": "e_app_e1", "kind": "edge", "from": { "elementId": "app_e1" }, "to": { "elementId": "replica_e1" } },
    { "id": "e_cache_e1", "kind": "edge", "from": { "elementId": "app_e1" }, "to": { "elementId": "cache_e1" } },
    { "id": "e_failover", "kind": "edge", "from": { "elementId": "primary_c1" }, "to": { "elementId": "standby_c1" }, "label": "Replication and failover", "style": { "dash": [8, 8] } },
    { "id": "e_replication", "kind": "edge", "from": { "elementId": "primary_c1" }, "to": { "elementId": "replica_e1" }, "label": "Cross-region replication" },
    { "id": "e_backups", "kind": "edge", "from": { "elementId": "primary_c1" }, "to": { "elementId": "storage" }, "label": "Backups" },
    { "id": "e_replica_backups", "kind": "edge", "from": { "elementId": "replica_e1" }, "to": { "elementId": "storage" } },
    { "id": "e_publish", "kind": "edge", "from": { "elementId": "app_c1" }, "to": { "elementId": "photos_topic" }, "label": "Photo URLs" },
    { "id": "e_trigger", "kind": "edge", "from": { "elementId": "photos_topic" }, "to": { "elementId": "thumbnailer" }, "label": "Triggers" },
    { "id": "e_thumbs", "kind": "edge", "from": { "elementId": "thumbnailer" }, "to": { "elementId": "storage" }, "label": "Thumbnails" }
  ]
}
