How nabinav/deployhub works
Purpose and entry points
DeployHub is a Go backend for repository-driven container deployments: GitHub source is connected, built into Docker images, published to Google Artifact Registry, and run on Cloud Run. The process starts at main.go; HTTP-facing orchestration is concentrated in handler/, while background deployment execution is in worker/worker.go.
HTTP/API and user session boundary
Handlers expose authentication, repository selection, deployment initiation, project retrieval, logs, image versions, rollback, deletion, and proxy behavior. They translate dashboard/API requests into persistence records and queued deployment work.
• handler/auth.go
• handler/deployHandler.go
• handler/rollback.go
Authentication integrates OAuth and JWT cookies/tokens, separating external GitHub identity exchange from application session verification.
• auth/oauth.go
• jwt/create.go
• jwt/verify.go
Project and deployment persistence
The db package is the system of record for users, projects, deployment jobs/status, environment variables, image IDs, queues, and logs. Handlers and workers should cross this boundary rather than own state directly.
• db/init.go
• db/jobCreate.go
• db/updateProject.go
Deployment state supports lifecycle transitions and recovery-oriented operations such as rollback, project deletion, and image-version lookup.
• db/changeProjectStatus.go
• db/getDockerImageId.go
• db/log.go
Queue-driven deployment execution
A deploy request creates/updates persisted work, then Redis-backed queue operations feed the worker. worker/worker.go is the asynchronous control-plane stage that performs deployment work independently of the request lifecycle.
• redis/add.go
• db/updateQueue.go
• worker/worker.go
The worker’s input/output contract is represented by deployment and worker schemas.
• schema/deploySchema.go
• schema/workerSchema.go
Source-control integration
GitHub access covers OAuth, repository discovery/selection, and webhook registration for continuous deployment. Git operations are isolated from handler concerns.
• auth/oauth.go
• handler/repo.go
• cmd/git.go
Webhook support forms the inbound continuous-deployment boundary; source retrieval is handled separately before builds.
• webhook/addHook.go
• helper/getRepo.go
Build and cloud deployment pipeline
The deployment stage clones/prepares source, detects or uses project Docker configuration, executes Docker build/push operations, and deploys the resulting image to GCP Cloud Run. Cloud-specific deployment orchestration is centered in:
• deploy/deploy.go
• utils/docker.go
• helper/gcloudPublic.go
Shell/command execution is abstracted behind utilities, making Docker and gcloud invocation a material host-runtime dependency.
• utils/command.go
• utils/docker.go
Runtime configuration, observability, and operations
Per-project environment variables are persisted then serialized/injected into deployment execution, rather than requiring repository .env files.
• db/getProjectEnv.go
• utils/parse_env.go
• utils/env_string.go
Logs flow from deployment execution into persistent logging and are surfaced through handlers. Deployment management also includes public proxying, rollback, and deletion paths.
• log/logWriting.go
• handler/logHandler.go
• handler/proxy.go
Infrastructure envelope
The service runs as a Go container (Dockerfile) and is locally composed with dependent services (compose.yml). Its material external systems are GitHub, Docker, Google Artifact Registry/Cloud Run, Redis, and the database initialized through db/init.go.
Main entry points: worker.go Deployment worker · deployHandler.go API handlers · deploy.go Deployment orchestration · init.go Deployment database
Components 17
HTTP & Sessions
- Service entrypoint
main.go - API handlers · Handles deploys, projects, logs, rollback, deletion, and proxying.
handler/deployHandler.go - OAuth and JWT · Exchanges GitHub identity and verifies application sessions.
auth/oauth.go - Webhook registration
webhook/addHook.go
Deployment Control Plane
- Deployment contracts
schema/deploySchema.go - Deployment worker · Consumes queued deployment work independently of HTTP requests.
worker/worker.go - Deployment logging
log/logWriting.go
Persistence & Queue
- Deployment database · Stores users, projects, jobs, status, environments, images, queues, and logs.
db/init.go - Job and project state
db/jobCreate.go - Redis queue
redis/add.go
Build & Cloud Delivery
- Repository retrieval
helper/getRepo.go - Deployment orchestration · Builds, publishes, and deploys the selected project.
deploy/deploy.go - Host command runner · Executes Docker and gcloud commands.
utils/command.go - Docker build and push
utils/docker.go - Project environment injection · Serializes persisted project variables for deployment execution.
utils/parse_env.go
Other components
- GitHub
- Artifact Registry & Cloud Run
Connections 22
- Service entrypoint → API handlers: serves
- API handlers → OAuth and JWT: authenticates
- OAuth and JWT → GitHub: OAuth exchange
- API handlers → Webhook registration: registers
- Webhook registration → GitHub: creates hooks
- API handlers → Deployment database: reads and writes
- API handlers → Job and project state: creates deployment work
- Job and project state → Redis queue: enqueues work
- Redis queue → Deployment worker: delivers jobs
- Deployment worker → Deployment contracts: uses
- Deployment worker → Deployment database: updates lifecycle state
- Deployment worker → Repository retrieval: retrieves source
- Repository retrieval → GitHub: clones repository
- Deployment worker → Project environment injection: loads project variables
- Deployment worker → Deployment orchestration: executes deployment
- Deployment orchestration → Docker build and push: builds and pushes
- Deployment orchestration → Host command runner: runs through
- Docker build and push → Artifact Registry & Cloud Run: publishes image
- Deployment orchestration → Artifact Registry & Cloud Run: deploys service
- Deployment worker → Deployment logging: emits logs
- Deployment logging → Deployment database: persists
- API handlers → Deployment database: retrieves logs and versions