{
  "repo": "tidbcloud/dataservices",
  "binary": "regioncentral",
  "binary_path": "cmd/regioncentral/main.go",
  "dependencies": {
    "RegionCentralLifecycle.LoadConfigAndLogger": {
      "infrastructure": {
        "filesystem": {
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "READ FILE",
              "trigger": "Load config before logger, metrics, and gRPC startup",
              "conditions": [
                "Always"
              ],
              "implementation": "config.InitConfig(configPath)"
            }
          ]
        }
      },
      "services": []
    },
    "RegionCentralLifecycle.StartMetricsServer": {
      "infrastructure": {
        "tcp": {
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "LISTEN",
              "trigger": "Expose Prometheus metrics on the dedicated metrics port",
              "conditions": [
                "Always"
              ],
              "implementation": "startupMetrics -> mEng.Run(\"0.0.0.0:\" + config.Global().ServerConf.MetricsPort)"
            }
          ]
        }
      },
      "services": []
    },
    "RegionCentralLifecycle.StartTracing": {
      "infrastructure": {},
      "services": []
    },
    "RegionCentralLifecycle.InitApikeyEncrypter": {
      "infrastructure": {},
      "services": []
    },
    "RegionCentralLifecycle.StartGrpcServer": {
      "infrastructure": {
        "tcp": {
          "conditions": [
            "Always at startup"
          ],
          "operations": [
            {
              "operation": "LISTEN",
              "trigger": "Expose RegionCentralService over gRPC",
              "conditions": [
                "Always"
              ],
              "implementation": "net.Listen(\"tcp\", \":\"+config.Global().ServerConf.GrpcPort); grpcServer.Serve(listen)"
            }
          ]
        }
      },
      "services": []
    },
    "HTTP GET /metrics": {
      "infrastructure": {},
      "services": []
    },
    "RegionCentralService.GetDataAPIAccess": {
      "infrastructure": {
        "mysql": {
          "conditions": [
            "Only after api key decryption succeeds"
          ],
          "operations": [
            {
              "operation": "SELECT",
              "trigger": "Look up the stored API key record by decrypted raw key",
              "conditions": [
                "apikeygenerator.Decrypt(apiKey) succeeded"
              ],
              "implementation": "repository.GetApiKeyByKey(decryptApiKey)"
            },
            {
              "operation": "SELECT",
              "trigger": "Load the owning DataApp after the API key row is found",
              "conditions": [
                "repository.GetApiKeyByKey(decryptApiKey) returned a DataAppId"
              ],
              "implementation": "repository.GetDataApp(apiKeyInfo.DataAppId)"
            }
          ]
        }
      },
      "services": []
    }
  }
}
