{
  "title": "Cache & Request Flow",
  "description": "Follow a cache-aside read from an authorized request to a fast hit or a fresh origin response.",
  "graph": {
    "direction": "LR",
    "nodes": [
      {
        "id": "request",
        "type": "io",
        "label": "Resource request",
        "description": "Request a resource by its stable identifier. Authentication and access checks still run even when the resource is present in the cache.",
        "group": "",
        "groupId": "client",
        "category": "frontend",
        "position": {
          "x": 80,
          "y": 230
        },
        "basis": "unknown",
        "sources": [
          {
            "repository": "",
            "path": "",
            "revision": "",
            "note": "Authored reference design for explaining system behavior. It describes a possible implementation, not production telemetry or an observed incident."
          }
        ]
      },
      {
        "id": "response",
        "type": "terminal",
        "label": "Resource delivered",
        "description": "Receive the same public response shape from either the cache-hit path or the origin path. A cache hit changes latency, not authorization.",
        "group": "",
        "groupId": "client",
        "category": "frontend",
        "position": {
          "x": 80,
          "y": 800
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "authorize",
        "type": "process",
        "label": "Authorize request",
        "description": "Verify the session and authorize this resource. Build a tenant-scoped, versioned cache key. Unauthorized calls are rejected before the path shown here continues.",
        "group": "",
        "groupId": "application",
        "category": "backend",
        "position": {
          "x": 480,
          "y": 230
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "cache_hit",
        "type": "decision",
        "label": "Cache hit?",
        "description": "A fresh, usable value takes the fast path. Missing, expired or invalid cache content falls back to the origin; a cache outage also uses the fallback policy.",
        "group": "",
        "groupId": "application",
        "category": "backend",
        "position": {
          "x": 850,
          "y": 458
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "serialize",
        "type": "process",
        "label": "Build response",
        "description": "Serialize the authorized data into one stable response schema. The hit and miss paths merge here before the response is returned.",
        "group": "",
        "groupId": "application",
        "category": "backend",
        "position": {
          "x": 850,
          "y": 800
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "cache_store",
        "type": "datastore",
        "label": "Resource cache",
        "description": "Read a key scoped to tenant, resource and schema version. Values expire after a bounded TTL; this store does not replace the authoritative database.",
        "group": "",
        "groupId": "storage",
        "category": "database",
        "position": {
          "x": 1270,
          "y": 230
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "load_origin",
        "type": "process",
        "label": "Load from origin",
        "description": "Load the authorized resource from the repository. Missing records and origin errors return their defined error response rather than being cached as a successful resource.",
        "group": "",
        "groupId": "storage",
        "category": "backend",
        "position": {
          "x": 1270,
          "y": 500
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "database",
        "type": "datastore",
        "label": "Primary database",
        "description": "Authoritative resource state. The lookup preserves tenant and authorization constraints, regardless of whether the cache is available.",
        "group": "",
        "groupId": "storage",
        "category": "database",
        "position": {
          "x": 1610,
          "y": 500
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "populate",
        "type": "process",
        "label": "Refresh cache",
        "description": "Attempt to store the fresh value with a bounded TTL, then pass the origin payload to response serialization. A cache write failure must not discard a valid origin response.",
        "group": "",
        "groupId": "storage",
        "category": "backend",
        "position": {
          "x": 1270,
          "y": 800
        },
        "basis": "unknown",
        "sources": []
      }
    ],
    "edges": [
      {
        "id": "incoming",
        "source": "request",
        "target": "authorize",
        "label": "Request",
        "description": "",
        "sourceHandle": "right",
        "targetHandle": "left",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "lookup_cache",
        "source": "authorize",
        "target": "cache_store",
        "label": "GET key",
        "description": "",
        "sourceHandle": "right",
        "targetHandle": "left",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "lookup_result",
        "source": "cache_store",
        "target": "cache_hit",
        "label": "Lookup result",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "top",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "hit_response",
        "source": "cache_hit",
        "target": "serialize",
        "label": "Hit",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "top",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "miss_origin",
        "source": "cache_hit",
        "target": "load_origin",
        "label": "Miss",
        "description": "",
        "sourceHandle": "right",
        "targetHandle": "left",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "query_origin",
        "source": "load_origin",
        "target": "database",
        "label": "Read",
        "description": "",
        "sourceHandle": "right",
        "targetHandle": "left",
        "labelOffset": {
          "x": 15,
          "y": -40
        },
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "origin_record",
        "source": "database",
        "target": "populate",
        "label": "Fresh record",
        "description": "",
        "sourceHandle": "bottom",
        "targetHandle": "right",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "store_value",
        "source": "populate",
        "target": "cache_store",
        "label": "SET + TTL",
        "description": "Refresh the cache as a best-effort side effect. The next request may use this value; this is not a second read in the current request.",
        "sourceHandle": "right",
        "targetHandle": "right",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "fresh_response",
        "source": "populate",
        "target": "serialize",
        "label": "Origin payload",
        "description": "",
        "sourceHandle": "left",
        "targetHandle": "right",
        "basis": "unknown",
        "sources": []
      },
      {
        "id": "return_response",
        "source": "serialize",
        "target": "response",
        "label": "Response",
        "description": "",
        "sourceHandle": "left",
        "targetHandle": "right",
        "basis": "unknown",
        "sources": []
      }
    ],
    "groups": [
      {
        "id": "client",
        "label": "Client",
        "description": "An authorized caller requests a resource and receives one response."
      },
      {
        "id": "application",
        "label": "Request handling",
        "description": "Access control, cache-result branching and consistent response serialization."
      },
      {
        "id": "storage",
        "label": "Cache & origin",
        "description": "Cache-aside storage: the database remains the source of truth; fresh values are stored with a bounded lifetime."
      }
    ]
  },
  "investigation": null
}
