The Certimate backend is a Go application built on top of PocketBase, which provides the underlying SQLite database, authentication, and a real-time REST API. The architecture follows a modular design where PocketBase serves as the persistence and identity foundation, while custom Go services handle specialized tasks like workflow orchestration, ACME certificate issuance, and scheduled tasks.
The backend is compiled into a single binary that embeds the frontend UI assets. It utilizes a repository pattern to interact with the database and a service-oriented approach for the workflow engine and scheduler.
The following diagram illustrates how the major backend components interact with the PocketBase core and the external environment.
Sources: main.go52-82 main.go27-28 internal/rest/routes/routes.go23-42
Certimate extends the PocketBase lifecycle using hooks. The main.go file initializes the application singleton and binds custom logic to the OnServe, OnBootstrap, and OnTerminate events.
app.GetApp().(*pocketbase.PocketBase) main.go28pb.OnServe() is used to initialize the scheduler, workflow engine, and bind the router main.go71-82 pb.OnBootstrap() handles early setup such as loading settings main.go52-59apis.Static(ui.DistDirFS, false) main.go61-69cmd.NewWinscCommand(pb) main.go41intercmd certapply via the mproc package to ensure stability and log capture cmd/intercmd.go64-125 cmd/intercmd.go20-29For details, see Application Bootstrap & PocketBase Integration.
The system's state is defined by a set of domain entities stored in PocketBase collections. The repository layer provides a structured way to query and persist these entities.
| Entity | Collection Name | Purpose |
|---|---|---|
Workflow | workflow | Defines the graph of nodes for cert automation internal/rest/routes/routes.go25 |
WorkflowRun | workflow_run | Tracks the execution state and history internal/rest/routes/routes.go26 |
Certificate | certificate | Stores issued certificates and metadata internal/rest/routes/routes.go28 |
Access | access | Stores credentials for providers internal/rest/routes/routes.go24 |
Settings | settings | Global application configuration internal/settings/settings.go1-20 |
ACMEAccount | acme_account | Stores ACME registration details internal/rest/routes/routes.go27 |
Sources: internal/rest/routes/routes.go24-30 internal/scheduler/scheduler.go13-17 internal/certificate/service_deps.go11-19
For details, see Domain Model & Repository Layer.
While PocketBase provides automatic CRUD APIs, Certimate implements custom handlers for complex operations that require server-side logic.
internal/rest/routes via routes.BindRouter(e.Router) main.go74CertificatesHandler, WorkflowsHandler, StatisticsHandler, and NotificationsHandler internal/rest/routes/routes.go38-41/api require superuser authentication via apis.RequireSuperuserAuth() internal/rest/routes/routes.go36-37For details, see REST API & HTTP Handlers.
The scheduler manages cron-based triggers and certificate expiration monitoring.
workflow.Setup() which prepares the dispatcher and hooks main.go73 The scheduler is initialized via scheduler.Setup() main.go72WorkflowService handles the lifecycle of runs, including StartRun and CancelRun internal/workflow/service_deps.go11-23pb.OnTerminate() to call workflow.Teardown() main.go84-90For details, see Workflow Engine.
Certimate uses a versioned migration system to manage the SQLite schema within PocketBase.
migrations side-effect import in main.go main.go24For details, see Database Migrations.
This diagram maps specific Go code entities to their architectural roles, illustrating how the main entry point wires together services and repositories.
Sources: main.go27-82 internal/rest/routes/routes.go23-42 internal/certificate/service_deps.go11-20 internal/workflow/service_deps.go11-23 internal/app/app.go3-7
The backend is built for multiple platforms and supports being run as a standard process or a system service.
AppVersion = "0.4.28" in internal/app/app.go internal/app/app.go5Certimate/0.4.28 internal/app/app.go6cmd.NewVersionCommand(pb) main.go40Sources: internal/app/app.go3-7 cmd/version.go13-24 main.go39-41
Refresh this wiki