{
  "repo": "tidbcloud/aitestsuit",
  "binary": "api",
  "binary_path": "cmd/api/main.go",
  "surface_kind": "mixed_service",
  "type": "service",
  "services": [
    {
      "name": "AITestSuitLifecycle",
      "package": "main",
      "methods": [
        {
          "name": "Startup",
          "name_key": "AITestSuitLifecycle.Startup",
          "input": "flags + process environment",
          "output": "loaded config, initialized storage and downstream clients, started background worker, registered HTTP routes, and served on 0.0.0.0:11000",
          "type": "local"
        },
        {
          "name": "LoadConfig",
          "name_key": "AITestSuitLifecycle.LoadConfig",
          "input": "-config flag path",
          "output": "*configs.Config",
          "type": "local"
        },
        {
          "name": "InitializeDatabase",
          "name_key": "AITestSuitLifecycle.InitializeDatabase",
          "input": "cfg.DBDSN + migrate=true",
          "output": "shared GORM handle with schema auto-migration applied",
          "type": "local"
        },
        {
          "name": "InitializeDAO",
          "name_key": "AITestSuitLifecycle.InitializeDAO",
          "input": "*gorm.DB",
          "output": "package-level DAO handle",
          "type": "local"
        },
        {
          "name": "InitializeOpenAIClient",
          "name_key": "AITestSuitLifecycle.InitializeOpenAIClient",
          "input": "cfg.ChatGPTToken",
          "output": "in-process OpenAI client handle only",
          "type": "local"
        },
        {
          "name": "InitializeDataAPIClient",
          "name_key": "AITestSuitLifecycle.InitializeDataAPIClient",
          "input": "cfg.DataAPIAddr",
          "output": "DataAPIService gRPC client connection",
          "type": "local"
        },
        {
          "name": "InitializeAIPowerClient",
          "name_key": "AITestSuitLifecycle.InitializeAIPowerClient",
          "input": "cfg.AIPowerAddr",
          "output": "ChatBotService gRPC client connection",
          "type": "local"
        },
        {
          "name": "StartWorker",
          "name_key": "AITestSuitLifecycle.StartWorker",
          "input": "context.TODO()",
          "output": "background queue consumer goroutine",
          "type": "local"
        },
        {
          "name": "StartHTTPServer",
          "name_key": "AITestSuitLifecycle.StartHTTPServer",
          "input": "registered Gin engine",
          "output": "HTTP server listening on 0.0.0.0:11000",
          "type": "local"
        }
      ]
    },
    {
      "name": "AITestSuitWorker",
      "package": "internal/tasks",
      "methods": [
        {
          "name": "ConsumeQueue",
          "name_key": "AITestSuitWorker.ConsumeQueue",
          "input": "buffered msgCh task stream",
          "output": "spawns one goroutine per dequeued task",
          "type": "local"
        },
        {
          "name": "RunTask",
          "name_key": "AITestSuitWorker.RunTask",
          "input": "tasks.Task with report metadata and test case results",
          "output": "updated report statistics and per-case execution results",
          "type": "local"
        }
      ]
    },
    {
      "name": "AITestSuitBuiltinHTTP",
      "type": "http",
      "methods": [
        {
          "name": "GET /healthz",
          "name_key": "HTTP GET /healthz",
          "input": "none",
          "output": "ping response from tigin.Ping",
          "path": "/healthz",
          "type": "http"
        },
        {
          "name": "GET /ping",
          "name_key": "HTTP GET /ping",
          "input": "none",
          "output": "ping response from tigin.Ping",
          "path": "/ping",
          "type": "http"
        },
        {
          "name": "GET /*filepath",
          "name_key": "HTTP GET /*filepath",
          "input": "non-API frontend asset path",
          "output": "static file from ./ui/dist when present",
          "path": "/*filepath",
          "type": "http"
        }
      ]
    },
    {
      "name": "AITestSuitAPI",
      "type": "http",
      "methods": [
        {
          "name": "GET /api/v1/plans",
          "name_key": "HTTP GET /api/v1/plans",
          "input": "page + per_page query",
          "output": "paginated test plan summaries with counts, last run, and AI model",
          "path": "/api/v1/plans",
          "type": "http"
        },
        {
          "name": "GET /api/v1/plan/:plan_id/cases",
          "name_key": "HTTP GET /api/v1/plan/:plan_id/cases",
          "input": "plan_id URI + page + per_page query",
          "output": "paginated test cases with pass rate",
          "path": "/api/v1/plan/:plan_id/cases",
          "type": "http"
        },
        {
          "name": "GET /api/v1/case/:id",
          "name_key": "HTTP GET /api/v1/case/:id",
          "input": "case id",
          "output": "single test case payload",
          "path": "/api/v1/case/:id",
          "type": "http"
        },
        {
          "name": "GET /api/v1/prompt_templates",
          "name_key": "HTTP GET /api/v1/prompt_templates",
          "input": "page + per_page query",
          "output": "prompt template list",
          "path": "/api/v1/prompt_templates",
          "type": "http"
        },
        {
          "name": "POST /api/v1/prompt_template",
          "name_key": "HTTP POST /api/v1/prompt_template",
          "input": "prompt template version + content",
          "output": "created prompt template row",
          "path": "/api/v1/prompt_template",
          "type": "http"
        },
        {
          "name": "PUT /api/v1/prompt_template/:id",
          "name_key": "HTTP PUT /api/v1/prompt_template/:id",
          "input": "template id + updated version/content",
          "output": "updated prompt template row",
          "path": "/api/v1/prompt_template/:id",
          "type": "http"
        },
        {
          "name": "GET /api/v1/reports",
          "name_key": "HTTP GET /api/v1/reports",
          "input": "plan_id/run_id filters + page + per_page query",
          "output": "report list enriched with plan, run, prompt template, and derived rates",
          "path": "/api/v1/reports",
          "type": "http"
        },
        {
          "name": "GET /api/v1/report/:id",
          "name_key": "HTTP GET /api/v1/report/:id",
          "input": "report id + resulta_status + pagination query",
          "output": "report detail with paginated case results",
          "path": "/api/v1/report/:id",
          "type": "http"
        },
        {
          "name": "GET /api/v1/runs",
          "name_key": "HTTP GET /api/v1/runs",
          "input": "page + per_page query",
          "output": "test run list",
          "path": "/api/v1/runs",
          "type": "http"
        },
        {
          "name": "GET /api/v1/run/:id",
          "name_key": "HTTP GET /api/v1/run/:id",
          "input": "run id",
          "output": "empty 200 response because the handler body is unimplemented",
          "path": "/api/v1/run/:id",
          "type": "http"
        },
        {
          "name": "GET /api/v1/stats",
          "name_key": "HTTP GET /api/v1/stats",
          "input": "plan_ids query + page + per_page query",
          "output": "per-run latest completed reports for the requested plans",
          "path": "/api/v1/stats",
          "type": "http"
        },
        {
          "name": "POST /api/v1/run",
          "name_key": "HTTP POST /api/v1/run",
          "input": "test run name + params",
          "output": "created test run row",
          "path": "/api/v1/run",
          "type": "http"
        },
        {
          "name": "POST /api/v1/task",
          "name_key": "HTTP POST /api/v1/task",
          "input": "test plan id + test run id + prompt template id",
          "output": "created report and case-result rows, then enqueued background execution",
          "path": "/api/v1/task",
          "type": "http"
        },
        {
          "name": "POST /api/v1/dataset",
          "name_key": "HTTP POST /api/v1/dataset",
          "input": "dataset name",
          "output": "generated embedded question set into a new test plan and test cases when the dataset name is recognized",
          "path": "/api/v1/dataset",
          "type": "http"
        },
        {
          "name": "POST /api/v1/plan",
          "name_key": "HTTP POST /api/v1/plan",
          "input": "test plan payload",
          "output": "created test plan row",
          "path": "/api/v1/plan",
          "type": "http"
        },
        {
          "name": "POST /api/v1/case",
          "name_key": "HTTP POST /api/v1/case",
          "input": "test case payload",
          "output": "created test case row",
          "path": "/api/v1/case",
          "type": "http"
        },
        {
          "name": "PUT /api/v1/case",
          "name_key": "HTTP PUT /api/v1/case",
          "input": "test case id + updated fields",
          "output": "updated test case row",
          "path": "/api/v1/case",
          "type": "http"
        },
        {
          "name": "DELETE /api/v1/case/:id",
          "name_key": "HTTP DELETE /api/v1/case/:id",
          "input": "case id",
          "output": "deleted test case row",
          "path": "/api/v1/case/:id",
          "type": "http"
        },
        {
          "name": "POST /api/v1/ai_model",
          "name_key": "HTTP POST /api/v1/ai_model",
          "input": "AI model payload",
          "output": "created AI model row",
          "path": "/api/v1/ai_model",
          "type": "http"
        },
        {
          "name": "PUT /api/v1/ai_model",
          "name_key": "HTTP PUT /api/v1/ai_model",
          "input": "AI model id + updated fields",
          "output": "updated AI model row",
          "path": "/api/v1/ai_model",
          "type": "http"
        },
        {
          "name": "GET /api/v1/ai_models",
          "name_key": "HTTP GET /api/v1/ai_models",
          "input": "page + per_page query",
          "output": "AI model list",
          "path": "/api/v1/ai_models",
          "type": "http"
        },
        {
          "name": "GET /api/v1/aipower/latest_prompt",
          "name_key": "HTTP GET /api/v1/aipower/latest_prompt",
          "input": "ai_model + deployment query",
          "output": "latest prompt template from aipower",
          "path": "/api/v1/aipower/latest_prompt",
          "type": "http"
        },
        {
          "name": "GET /api/v1/aipower/prompts",
          "name_key": "HTTP GET /api/v1/aipower/prompts",
          "input": "ai_model + deployment query",
          "output": "prompt template list from aipower",
          "path": "/api/v1/aipower/prompts",
          "type": "http"
        },
        {
          "name": "POST /api/v1/aipower/prompts/release",
          "name_key": "HTTP POST /api/v1/aipower/prompts/release",
          "input": "prompt template id + ai_model + deployment",
          "output": "released prompt template to aipower",
          "path": "/api/v1/aipower/prompts/release",
          "type": "http"
        }
      ]
    }
  ],
  "extensions": {
    "notes": [
      "The binary exposes one Gin HTTP server and one always-on background worker goroutine fed by an in-memory channel.",
      "GET /api/v1/run/:id is intentionally kept as an empty handler because controller.GetTestRun has no implementation body.",
      "openai.InitGPT is startup-only client initialization. No runtime path in this repo calls openai.GetReplyFromAI or CreateCompletion.",
      "The root static middleware serves ./ui/dist for non-API paths, but the business API surface remains under /api/v1."
    ]
  }
}
