{
  "schemaVersion": "0.1",
  "diagramFamily": "architecture",
  "scene": {
    "id": "public-interfaces-for-security-review",
    "title": "Public-facing interfaces",
    "brief": "What the store's code opens to the internet, for a security review.\nDrawn from infra/*.tf, gateway/routes.yaml, services/*/openapi.yaml and k8s/ingress/*.yaml. Frames: internet (who calls in), open (everything a request from the internet reaches, through the edge or straight past it) and private (what only the cluster or the VPN reaches). Edges run from caller to callee; an edge into the open frame is labeled with how the internet reaches it: the port at the edge, the host an ingress matches, each gateway route with its auth. A public grant, which skips the WAF and the load balancer and needs no credentials, is dashed and labeled with its path. The open frame and a public grant's edge are red. IDs are short and stable; reuse them.",
    "units": "px",
    "canvas": {
      "background": "#1a1a22"
    }
  },
  "elements": [
    {
      "id": "internet",
      "kind": "frame",
      "title": "Internet",
      "containerType": "generic",
      "style": {
        "dash": [
          4,
          4
        ],
        "cornerRadius": 8
      },
      "children": [
        "customers",
        "partners",
        "payments_provider",
        "staff"
      ]
    },
    {
      "id": "customers",
      "kind": "node",
      "nodeType": "externalSystem",
      "label": "Customers",
      "icon": "lucide:users"
    },
    {
      "id": "partners",
      "kind": "node",
      "nodeType": "externalSystem",
      "label": "Partner apps",
      "icon": "lucide:external-link"
    },
    {
      "id": "payments_provider",
      "kind": "node",
      "nodeType": "externalSystem",
      "label": "Payment provider",
      "icon": "lucide:credit-card"
    },
    {
      "id": "staff",
      "kind": "node",
      "nodeType": "externalSystem",
      "label": "Staff on the VPN",
      "icon": "lucide:user-check"
    },
    {
      "id": "open",
      "kind": "frame",
      "title": "Open to the internet",
      "containerType": "generic",
      "style": {
        "dash": [
          4,
          4
        ],
        "cornerRadius": 8,
        "stroke": "#c0544e"
      },
      "children": [
        "waf",
        "lb",
        "gateway",
        "web",
        "public_api",
        "auth",
        "webhooks",
        "uploads"
      ]
    },
    {
      "id": "waf",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "WAF",
      "icon": "lucide:shield"
    },
    {
      "id": "lb",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "Public load balancer",
      "icon": "lucide:network"
    },
    {
      "id": "gateway",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "API gateway",
      "icon": "lucide:layers"
    },
    {
      "id": "web",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "Web app",
      "icon": "lucide:monitor"
    },
    {
      "id": "public_api",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "Public API",
      "icon": "lucide:code"
    },
    {
      "id": "auth",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "Auth service",
      "icon": "lucide:key"
    },
    {
      "id": "webhooks",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "Webhook receiver",
      "icon": "lucide:zap"
    },
    {
      "id": "private",
      "kind": "frame",
      "title": "Private",
      "containerType": "generic",
      "style": {
        "dash": [
          4,
          4
        ],
        "cornerRadius": 8
      },
      "children": [
        "admin",
        "billing",
        "postgres"
      ]
    },
    {
      "id": "admin",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "Admin console",
      "icon": "lucide:lock"
    },
    {
      "id": "billing",
      "kind": "node",
      "nodeType": "service",
      "shape": "roundedRect",
      "label": "Billing worker",
      "icon": "lucide:server"
    },
    {
      "id": "postgres",
      "kind": "node",
      "nodeType": "database",
      "label": "Postgres"
    },
    {
      "id": "uploads",
      "kind": "node",
      "nodeType": "database",
      "label": "Uploads bucket",
      "icon": "lucide:hard-drive"
    },
    {
      "id": "e_cust_waf",
      "kind": "edge",
      "from": {
        "elementId": "customers"
      },
      "to": {
        "elementId": "waf"
      },
      "label": "HTTPS 443"
    },
    {
      "id": "e_part_waf",
      "kind": "edge",
      "from": {
        "elementId": "partners"
      },
      "to": {
        "elementId": "waf"
      },
      "label": "HTTPS 443"
    },
    {
      "id": "e_pay_waf",
      "kind": "edge",
      "from": {
        "elementId": "payments_provider"
      },
      "to": {
        "elementId": "waf"
      },
      "label": "HTTPS 443"
    },
    {
      "id": "e_waf_lb",
      "kind": "edge",
      "from": {
        "elementId": "waf"
      },
      "to": {
        "elementId": "lb"
      }
    },
    {
      "id": "e_lb_web",
      "kind": "edge",
      "from": {
        "elementId": "lb"
      },
      "to": {
        "elementId": "web"
      },
      "label": "app.* · session"
    },
    {
      "id": "e_lb_gw",
      "kind": "edge",
      "from": {
        "elementId": "lb"
      },
      "to": {
        "elementId": "gateway"
      },
      "label": "api.*"
    },
    {
      "id": "e_gw_api",
      "kind": "edge",
      "from": {
        "elementId": "gateway"
      },
      "to": {
        "elementId": "public_api"
      },
      "label": "/v1/* · API key"
    },
    {
      "id": "e_gw_auth",
      "kind": "edge",
      "from": {
        "elementId": "gateway"
      },
      "to": {
        "elementId": "auth"
      },
      "label": "/oauth/* · none"
    },
    {
      "id": "e_gw_hooks",
      "kind": "edge",
      "from": {
        "elementId": "gateway"
      },
      "to": {
        "elementId": "webhooks"
      },
      "label": "/hooks/payments · signed"
    },
    {
      "id": "e_hooks_billing",
      "kind": "edge",
      "from": {
        "elementId": "webhooks"
      },
      "to": {
        "elementId": "billing"
      },
      "label": "queue"
    },
    {
      "id": "e_api_pg",
      "kind": "edge",
      "from": {
        "elementId": "public_api"
      },
      "to": {
        "elementId": "postgres"
      }
    },
    {
      "id": "e_billing_pg",
      "kind": "edge",
      "from": {
        "elementId": "billing"
      },
      "to": {
        "elementId": "postgres"
      }
    },
    {
      "id": "e_staff_admin",
      "kind": "edge",
      "from": {
        "elementId": "staff"
      },
      "to": {
        "elementId": "admin"
      },
      "label": "VPN only"
    },
    {
      "id": "e_admin_pg",
      "kind": "edge",
      "from": {
        "elementId": "admin"
      },
      "to": {
        "elementId": "postgres"
      }
    },
    {
      "id": "e_web_uploads",
      "kind": "edge",
      "from": {
        "elementId": "web"
      },
      "to": {
        "elementId": "uploads"
      },
      "label": "signed URLs"
    }
  ]
}
