{
  "repo": "tidbcloud/dataapps",
  "binary": "chat2queryapi",
  "binary_path": "cmd/chat2queryapi/main.go",
  "surface_kind": "mixed_service",
  "type": "mixed_service",
  "services": [
    {
      "name": "Chat2QueryLifecycle",
      "package": "main",
      "methods": [
        {
          "name": "LoadConfig",
          "name_key": "Runtime Chat2QueryLifecycle.LoadConfig",
          "input": "--config-path",
          "output": "global config loaded into config.Global()",
          "type": "local"
        },
        {
          "name": "SetupObservability",
          "name_key": "Runtime Chat2QueryLifecycle.SetupObservability",
          "input": "sentry + log + tracing config",
          "output": "logger, sentry, and jaeger initialized",
          "type": "local"
        },
        {
          "name": "ConnectDatabase",
          "name_key": "Runtime Chat2QueryLifecycle.ConnectDatabase",
          "input": "mysql config",
          "output": "shared GORM connection initialized",
          "type": "local"
        },
        {
          "name": "RegisterPublicRoutes",
          "name_key": "Runtime Chat2QueryLifecycle.RegisterPublicRoutes",
          "input": "gin.Engine",
          "output": "healthz plus chat2query API routes registered with middleware",
          "type": "local"
        },
        {
          "name": "RegisterInternalRoutes",
          "name_key": "Runtime Chat2QueryLifecycle.RegisterInternalRoutes",
          "input": "gin.Engine",
          "output": "internal /api/v1/chat2data route registered",
          "type": "local"
        },
        {
          "name": "StartMetricsServer",
          "name_key": "Runtime Chat2QueryLifecycle.StartMetricsServer",
          "input": "fixed address 0.0.0.0:9091",
          "output": "metrics listener serving /metrics",
          "type": "local"
        },
        {
          "name": "StartInternalHTTPServer",
          "name_key": "Runtime Chat2QueryLifecycle.StartInternalHTTPServer",
          "input": "server.chat2queryInternalAddr",
          "output": "internal Gin listener serving /api/v1/chat2data",
          "type": "local"
        },
        {
          "name": "StartPublicHTTPServer",
          "name_key": "Runtime Chat2QueryLifecycle.StartPublicHTTPServer",
          "input": "server.chat2queryapiHttpListenAddr",
          "output": "public HTTP listener serving healthz and chat2query routes",
          "type": "local"
        }
      ]
    },
    {
      "name": "Chat2QueryPublicHTTP",
      "package": "api + internal/controller/sqleditor",
      "type": "http",
      "methods": [
        {
          "name": "GET /healthz",
          "name_key": "HTTP GET /healthz",
          "path": "/healthz",
          "http_method": "GET",
          "input": "none",
          "output": "HTTP 200",
          "type": "http"
        },
        {
          "name": "POST /api/:api_ver/apps/:app_id/:app_ver/chat2data",
          "name_key": "HTTP POST /api/:api_ver/apps/:app_id/:app_ver/chat2data",
          "path": "/api/:api_ver/apps/:app_id/:app_ver/chat2data",
          "http_method": "POST",
          "input": "Chat2QueryReq JSON body",
          "output": "generated SQL plus query result payload",
          "type": "http"
        },
        {
          "name": "POST /api/:api_ver/apps/:app_id/:app_ver/chat2question",
          "name_key": "HTTP POST /api/:api_ver/apps/:app_id/:app_ver/chat2question",
          "path": "/api/:api_ver/apps/:app_id/:app_ver/chat2question",
          "http_method": "POST",
          "input": "Chat2QueryReq JSON body",
          "output": "generated follow-up question suggestions",
          "type": "http"
        },
        {
          "name": "POST /api/:api_ver/apps/:app_id/:app_ver/chat2chart",
          "name_key": "HTTP POST /api/:api_ver/apps/:app_id/:app_ver/chat2chart",
          "path": "/api/:api_ver/apps/:app_id/:app_ver/chat2chart",
          "http_method": "POST",
          "input": "Chat2QueryReq JSON body",
          "output": "generated chart config plus query result payload",
          "type": "http"
        },
        {
          "name": "POST /api/:api_ver/apps/:app_id/:app_ver/data2column-match",
          "name_key": "HTTP POST /api/:api_ver/apps/:app_id/:app_ver/data2column-match",
          "path": "/api/:api_ver/apps/:app_id/:app_ver/data2column-match",
          "http_method": "POST",
          "input": "Chat2QueryReq JSON body",
          "output": "AI-generated column descriptions",
          "type": "http"
        },
        {
          "name": "GET /api/:api_ver/apps/:app_id/:app_ver/streaming",
          "name_key": "HTTP GET /api/:api_ver/apps/:app_id/:app_ver/streaming",
          "path": "/api/:api_ver/apps/:app_id/:app_ver/streaming",
          "http_method": "GET",
          "input": "QueryStreamResultReq query string",
          "output": "streaming completion status plus parsed result payload",
          "type": "http"
        }
      ]
    },
    {
      "name": "Chat2QueryInternalHTTP",
      "package": "internal/controller/sqleditor",
      "type": "http",
      "methods": [
        {
          "name": "POST /api/v1/chat2data",
          "name_key": "HTTP POST /api/v1/chat2data",
          "path": "/api/v1/chat2data",
          "http_method": "POST",
          "input": "InternalChat2DataReq JSON body",
          "output": "generated SQL plus query result payload for trusted internal callers",
          "type": "http"
        }
      ]
    },
    {
      "name": "Chat2QueryMetricsHTTP",
      "package": "main",
      "type": "http",
      "methods": [
        {
          "name": "GET /metrics",
          "name_key": "HTTP GET /metrics",
          "path": "/metrics",
          "http_method": "GET",
          "input": "Prometheus scrape request",
          "output": "Prometheus metrics payload",
          "type": "http"
        }
      ]
    }
  ],
  "extensions": {
    "notes": [
      "The public HTTP listener applies global middleware in this order: Metric, API error reporter, CORS, CheckPathVersion, AuthApiKey, and CheckRequestBodySize before any chat2query handler runs.",
      "The internal /api/v1/chat2data route is served on a separate listener and does not pass through AuthApiKey or CheckPathVersion.",
      "The binary also exposes a dedicated metrics listener on 0.0.0.0:9091 rather than mounting /metrics on the public API router.",
      "The old scan mixed a middleware helper key AuthApiKey into service-mapping even though it was not part of the interface surface; the fresh scan keeps middleware as route conditions instead of fake standalone methods."
    ]
  }
}
