{
  "openapi": "3.1.0",
  "info": {
    "title": "Querystorm system design simulator",
    "version": "1.0.0",
    "description": "Simulate a software architecture written in Querystorm text and get its numbers at peak and over a day, zone and region outage results, the breaking point, monthly cost, pros and cons, a Mermaid flowchart and a live link to share with the user. Use it whenever the user is designing, reviewing, scaling or comparing a system. Syntax: https://querystorm.vercel.app/llms-full.txt"
  },
  "servers": [{ "url": "https://querystorm.vercel.app" }],
  "paths": {
    "/api/simulate": {
      "get": {
        "operationId": "simulateDesign",
        "summary": "Simulate one design",
        "description": "Returns a report. Show the user the `link` (an animated, editable simulation) and the `mermaid` flowchart, then summarise `pros` and `cons`.",
        "parameters": [
          { "name": "d", "in": "query", "required": true, "description": "The design in Querystorm text, e.g. `title: Shop; users: client @nyc users=200k rpm=2; users -> lb -> api -> redis [reads] -> postgres; api -> postgres [writes]`", "schema": { "type": "string" } },
          { "name": "format", "in": "query", "required": false, "description": "`json` (default) or `markdown` for a ready-to-show report", "schema": { "type": "string", "enum": ["json", "markdown"] } }
        ],
        "responses": { "200": { "description": "Simulation report", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Report" } }, "text/markdown": { "schema": { "type": "string" } } } }, "400": { "description": "No design given" } }
      },
      "post": {
        "operationId": "simulateDesignPost",
        "summary": "Simulate one design (body)",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["design"], "properties": { "design": { "type": "string", "description": "The design in Querystorm text" }, "format": { "type": "string", "enum": ["json", "markdown"] } } } } } },
        "responses": { "200": { "description": "Simulation report", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Report" } } } } }
      }
    },
    "/api/compare": {
      "post": {
        "operationId": "compareDesigns",
        "summary": "Compare 2 to 4 designs",
        "description": "Simulates each design and returns a comparison table, the trade-offs between them, and a live link for each.",
        "requestBody": { "required": true, "content": { "application/json": { "schema": { "type": "object", "required": ["designs"], "properties": { "designs": { "type": "array", "minItems": 2, "maxItems": 4, "items": { "type": "string" } }, "format": { "type": "string", "enum": ["json", "markdown"] } } } } } },
        "responses": { "200": { "description": "Comparison", "content": { "application/json": { "schema": { "type": "object", "properties": { "table": { "type": "string" }, "tradeoffs": { "type": "array", "items": { "type": "string" } }, "markdown": { "type": "string" }, "designs": { "type": "array", "items": { "type": "object" } } } } } } } }
      }
    }
  },
  "components": {
    "schemas": {
      "Report": {
        "type": "object",
        "properties": {
          "title": { "type": "string" },
          "verdict": { "type": "string" },
          "link": { "type": "string", "description": "Live, editable simulation of this design. Share it with the user." },
          "mermaid": { "type": "string", "description": "Mermaid flowchart with live numbers" },
          "markdown": { "type": "string", "description": "The whole report, formatted for a chat reply" },
          "text": { "type": "string", "description": "The design in canonical Querystorm text" },
          "peak": { "type": "object" },
          "day": { "type": "object" },
          "resilience": { "type": "object" },
          "components": { "type": "array", "items": { "type": "object" } },
          "pros": { "type": "array", "items": { "type": "string" } },
          "cons": { "type": "array", "items": { "type": "string" } },
          "advice": { "type": "array", "items": { "type": "object" } },
          "warnings": { "type": "array", "items": { "type": "string" } }
        }
      }
    }
  }
}
