{
  "repo": "tidbcloud/message-service",
  "binary": "central",
  "binary_path": "cmd/central/main.go",
  "dependencies": {
    "HTTP POST /api/v1/message/orgs/:org_id/projects/:project_id/bot": {
      "infrastructure": {
        "mysql": {
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Get existing session records by session_id and created_by",
              "conditions": ["req.SessionID != ''"],
              "implementation": "dao.GetBotInteractRecordBySessionIDCreatedBy(req.SessionID, createdBy)"
            },
            {
              "operation": "INSERT",
              "trigger": "Save chat interaction record",
              "conditions": ["Always"],
              "implementation": "dao.CreateBotInteractRecord(record)"
            }
          ]
        }
      },
      "services": [
        {
          "name": "account-provider-svc",
          "target_repo": "tidbcloud/account",
          "target_interface": "AccountAPIService.GetUserByToken",
          "operation_type": "grpc_unary",
          "conditions": ["!config.IsLocalMode()"],
          "operations": [
            {
              "operation": "gRPC GetUserByToken",
              "trigger": "Authenticate user from Authorization header",
              "conditions": ["Non-local mode"],
              "implementation": "grpc.GetUserByToken(ctx, &account.GetUserByTokenRequest{Token: rawToken})"
            }
          ]
        },
        {
          "name": "dataapi-svc",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIService.GetClusterMeta",
          "operation_type": "grpc_unary",
          "conditions": ["req.BotType in ['chat2sql', '']", "req.Database == ''"],
          "operations": [
            {
              "operation": "gRPC GetClusterMeta",
              "trigger": "Get cluster metadata for database guessing",
              "conditions": ["chat2sql or default (empty BotType) mode without database specified"],
              "implementation": "grpc.GetClusterMeta(ctx, &dataapi.GetClusterMetaReq{ProjectId: projectID, ClusterId: clusterID})"
            }
          ]
        },
        {
          "name": "dataapi-svc",
          "target_repo": "tidbcloud/dataservices",
          "target_interface": "DataAPIService.GetDatabaseMeta",
          "operation_type": "grpc_unary",
          "conditions": ["req.Database != ''", "req.BotType in ['chat2sql', 'chat2chart', '']"],
          "operations": [
            {
              "operation": "gRPC GetDatabaseMeta",
              "trigger": "Get database table metadata for SQL generation",
              "conditions": ["database specified"],
              "implementation": "grpc.GetDatabaseMeta(ctx, &dataapi.GetDatabaseMetaReq{ProjectId: projectID, ClusterId: clusterID, Database: database})"
            }
          ]
        },
        {
          "name": "openai-api",
          "target_interface": "POST /v1/completions",
          "operation_type": "http_post",
          "conditions": ["Always"],
          "operations": [
            {
              "operation": "HTTP POST /v1/completions",
              "trigger": "Generate SQL/Chart completion using OpenAI API",
              "conditions": ["Always"],
              "implementation": "httpclient.PostWithHeader(conf.OpenAIEndpoint + '/v1/completions', param, &headers)"
            }
          ]
        }
      ]
    },
    "HTTP GET /healthz": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /metrics": {
      "infrastructure": {},
      "services": []
    },
    "HTTP GET /swagger/*any": {
      "infrastructure": {},
      "services": []
    }
  }
}
