How tokamak-network/trh-backend works
TRH Backend is an HTTP API for administering Thanos-based chains and their integrations, with PostgreSQL-backed configuration and background operations. The principal workflow is a client request routed to an API handler, then through service logic to deployment or integration operations and persisted state. Authentication, RPC/API-key configuration, task progress, and restart recovery are supporting capabilities. Some major handlers and service modules are indexed but not excerpted, so those components are included while uncertain internal call links are omitted.
Main entry points: route.go Route Setup · main.go Application Startup · thanos Thanos API · service.go Thanos Service
Components 22
HTTP API
- Application Startup
main.go - Route Setup
pkg/api/routes/route.go - Authentication
pkg/api/handlers/auth.go - RPC/API Key Config
pkg/api/handlers/configuration/rpc_url.go - Thanos API
pkg/api/handlers/thanos - Deployment API
pkg/api/handlers/thanos/deployment.go - Integration API
pkg/api/handlers/thanos/integrations.go - Task Status API
pkg/api/handlers/task/handler.go
Thanos Operations
- Thanos Service
pkg/services/thanos/service.go - Deployment Operations
pkg/services/thanos/deployment.go - Stack Lifecycle
pkg/services/thanos/stack_lifecycle.go - Chain Integrations
pkg/services/thanos/integrations - Backup Management
pkg/services/thanos/integrations/backup_manager.go - Uptime Integration
pkg/services/thanos/integrations/uptime_service.go - Deployment Presets
pkg/services/thanos/presets/service.go - Thanos Stack SDK
pkg/stacks/thanos/thanos_stack.go
Persistence and Tasks
- Postgres Repositories
pkg/infrastructure/postgres/repositories - Integration Repository
pkg/infrastructure/postgres/repositories/integration.go - PostgreSQL
- Background Tasks
pkg/taskmanager/task_manager.go
Recovery
- Restart Recovery
pkg/workers/recovery.go
Other components
- API Client
Connections 22
- Application Startup → Route Setup: sets up
main.go - Application Startup → PostgreSQL: connects
main.go - Application Startup → Restart Recovery: runs recovery
main.go - API Client → Route Setup: sends requests
- Route Setup → Authentication: routes to
pkg/api/routes/route.go - Route Setup → RPC/API Key Config: routes to
pkg/api/routes/route.go - Route Setup → Thanos API: routes to
pkg/api/routes/route.go - Route Setup → Task Status API: routes to
pkg/api/routes/route.go - Route Setup → Thanos Service: configures
pkg/api/routes/route.go - Thanos API → Deployment API: includes
- Thanos API → Integration API: includes
- Thanos Service → Deployment Operations: delegates
pkg/services/thanos/service.go - Thanos Service → Chain Integrations: delegates
pkg/services/thanos/service.go - Deployment Operations → Thanos Stack SDK: uses
pkg/services/thanos/deployment.go - Deployment Operations → Deployment Presets: uses
pkg/services/thanos/deployment.go - Backup Management → Thanos Stack SDK: creates clients
pkg/services/thanos/integrations/backup_manager.go - Backup Management → Background Tasks: schedules tasks
pkg/services/thanos/integrations/backup_manager.go - Uptime Integration → Background Tasks: schedules tasks
pkg/services/thanos/integrations/uptime_service.go - Task Status API → Background Tasks: queries progress
pkg/api/handlers/task/handler.go - Integration Repository → PostgreSQL: reads and writes
pkg/infrastructure/postgres/repositories/integration.go - Restart Recovery → Thanos Stack SDK: uses cleanup client
pkg/workers/recovery.go - Restart Recovery → PostgreSQL: cleans interrupted records
pkg/workers/recovery.go