Skip to content
DashboardWebsite

Platform / product composition

This page explains how opentremor-core adds the security-analysis product to opentremor-platform. It is for engineers who work on the application, its configuration, or its storage layer. For the platform on its own, see Platform Base.

The two packages have different responsibilities:

  • Platform provides multi-tenant identity and org management, authentication, teams, invitations, API keys, platform administration, billing and metering, background jobs, notifications, telemetry, and the audit log.
  • Product provides security analysis: packs, resources, changesets, findings, rules, reports, and the review workflow.

The boundary follows responsibility. Background jobs and outbound webhooks are platform capabilities. The product supplies analysis-specific job fields and finding data for notification payloads.

The packages expose separate application factories:

opentremor_platform.controllers.app
create_platform_app() # the multi-tenant base alone — no analysis surface
# opentremor_core.controllers.app
create_app() # = create_platform_app() + _install_product()

create_app() builds the composed application used by server.py and deployments. create_platform_app() builds the platform-only application. Its route surface is a strict subset of the composed app’s; product routes are absent.

Both modules expose an app attribute for uvicorn: opentremor_core.controllers.app:app or opentremor_platform.controllers.app:app for a deployment without the product. Each module builds that app lazily on first access through module-level __getattr__. Importing a factory does not build an app. Core imports create_platform_app from the platform module, so building an app at import time would create an unused platform app in each core process.

The type system follows the same split. Core’s AppConfig combines PlatformConfig and ProductConfig. Its StorageBackend combines PlatformStorageBackend and ProductStorageBackend (see Storage layer). Core’s JobStatus extends the platform’s JobRecord. These classes preserve flat attribute access for callers.

The platform provides registration points for product-specific settings sections, sweep steps, org purge steps, index declarations, bootstrap and startup hooks, storage configuration, capabilities, notification events, meters, permissions, mail templates, and job kinds. Platform Base — Mounting a product on top lists the registration points and their modules. This page explains why the split uses them.

Org purge shows why registration matters. The platform’s services/tenancy/org_offboarding.py runs registered product purge steps before deleting platform-owned collections, then deletes the organization document last. This lets the platform purge orgs without naming product collections directly. If a purge step fails, the org document remains, and pending_deletion_at remains set so a later sweep can retry.

Two capabilities are inherited rather than registered. The product subclasses or calls them without adding registration wiring:

Inherited capabilityWhat it providesWhere
Background jobsJobRecord, storage methods, the stuck-job sweep, and admin endpointsmodels/jobs.py, services/jobs/sweep.py
Outbound webhooksdeliver(), which signs the exact bytes sent with HMAC, checks egress, and does not raise; webhook notification channels use itservices/notifications/webhooks.py

The settings registry is a key registration point. Each section is declared with its Pydantic model. The registry generates the flat override key map, managed-section list, excluded-section list, and PATCH /v1/admin/settings body model. It reuses field bounds from the model. verify_complete() checks that each section in the deployment’s config model has a disposition: editable, managed, or excluded with a reason.

Two config sections have contributions from both packages: retention (platform TTLs and product purge windows) and server (public URLs and ingest limits). Each domain declares its part of the section. Keeping retention as one section also keeps it as one sweep, with one state document, endpoint, and task-scheduler entry.

The pack plugin system follows a similar pattern: core defines an interface, and installed packages register against it.