Intake
integrations/vendors.py · alertmanager.py Five vendor formats, Alertmanager v4 and a signed generic webhook become one signal shape. Constant-time secret checks, HMAC with a 5-minute replay window, dedupe on (source, fingerprint).
Four containers and PostgreSQL. No message broker, no cloud services. Watch one outage move through the system, from alert to recovery; pause it or jump to any chapter.
FlagMesh polls about 70 public sources: vendor status pages, AWS, Google Cloud and Azure health, internet outage monitors and news.
When a vendor you registered as a service posts an incident, the status watch turns it into a signal, deduplicated by the vendor's incident id.
Your own alerts arrive the same way: Datadog, PagerDuty, Grafana, Prometheus, Airflow, DataHub or any HMAC-signed webhook (5-minute replay window).
An open incident for the same service absorbs the signal; otherwise a new one opens. An engineer can also raise one by hand.
Blast radius: a reverse walk of the dependency map (depth ≤ 6) lists every feature at risk, its backup, and anything with no backup.
An engineer proposes the backups in one click. FlagMesh reads each flag's live state from Flagsmith and records it; a dry run shows the exact change.
The incident commander gets it in FlagMesh and in Slack at the same moment, previews before and after, and approves from either. Self-approval is refused.
Approval queues one job in the same database transaction, keyed on the request so it can never run twice.
A worker claims the job (SELECT … FOR UPDATE SKIP LOCKED), checks nothing drifted, and writes each flag through Flagsmith's Management API.
Each flag is read back and marked verified only on a match; the first failure stops the run. Flagsmith's Feature Health shows why the flag changed.
Every step is appended to the hash-chained activity log: who, how, when.
When the vendor posts resolved, recovery unlocks: it targets the recorded prior states and needs its own second approval.
Drift check: a flag changed in Flagsmith since the backup stops for a human decision. The rest are restored and verified.
Sign in with Microsoft Entra ID, Google or any OIDC provider (PKCE, state, nonce, JWKS-checked ID token). Sessions stay on the server.
People and groups sync from Entra ID, Okta, Google Workspace or SCIM 2.0, each group mapped to admin, incident commander, engineer or leadership.
An outage starts · step 1 of 5
A vendor's bad day opens your incident, by itself.
FlagMesh polls about 70 public sources: vendor status pages, AWS, Google Cloud and Azure health, internet outage monitors and news.
Flagsmith stays the source of truth for flags. FlagMesh talks to it only through the Management API and Feature Health, never its database.
Thin routers, services hold the logic, repositories hold the queries, adapters live in integrations/.
integrations/vendors.py · alertmanager.py Five vendor formats, Alertmanager v4 and a signed generic webhook become one signal shape. Constant-time secret checks, HMAC with a 5-minute replay window, dedupe on (source, fingerprint).
services/incidents.py An open incident for the same resource absorbs new signals. Resolved incidents are never reopened silently, and a resolved signal never closes an incident on its own.
services/blast_radius.py Reverse breadth-first walk over dependency edges up to depth 6. Path confidence is the weakest edge on the path. Coverage gaps (unmapped, ownerless, stale, no fallback) always come back too.
services/actions.py · slack_approvals.py Proposals are checked against live Flagsmith state and capture each prior state. Approval needs the approve permission, never the requester, from the UI or Slack.
services/execution.py · workers/ Ordered writes through the Management API, a drift check before and a read-back after each one, stop on first failure, at most 25 items per request.
integrations/oidc.py · security/rbac.py OIDC with PKCE, state and nonce; scrypt passwords with lockout; hashed API tokens for break-glass. Seven roles, every query scoped by workspace from the session, never from input.
Promotions are human decisions, each one audited.
Mitigation and recovery share this lifecycle; recovery needs its own approval.
Backoff 2ⁿ seconds, capped at 300 s, then dead letter. Stale running jobs are reclaimed.
When a resource fails, FlagMesh asks “who depends on this?” and follows edges outward, ring by ring.
SELECT * FROM jobs
WHERE status = 'queued'
AND run_after <= now()
ORDER BY run_after
LIMIT 1
FOR UPDATE SKIP LOCKED;
-- on failure
run_after = now() + min(2^attempts, 300) s
status = attempts >= max ? 'dead' : 'queued' Approval and enqueue commit in one transaction, so an approved change is never lost and never queued twice.
dead for a human to look at.Each event's hash covers the previous hash plus its own canonical JSON. Writes are serialised per workspace with a PostgreSQL advisory lock, so the chain never forks.
hash = sha256(prev_hash ‖ canonical_json(event)) · change one byte anywhere and every later hash stops matching.
The Flagsmith key, SSO and Slack secrets live in the API, encrypted with FLAGMESH_SECRET_KEY. The browser only ever talks to the Next.js server.
Opaque 12-hour server-side sessions in an httpOnly cookie. Nothing a script can read.
HMAC-SHA256 webhooks with timestamps, signed Slack interactivity, OIDC ID tokens checked against the provider's JWKS.
Workspace comes from the authenticated membership on every query, never from the request alone.
Production changes need an approver with the right role who is not the requester. Enforced in the API, mirrored in the UI.
The audit chain is append-only and hash-linked; verification recomputes every hash from the start.
| Unit | Built with | Scales | Port |
|---|---|---|---|
website | Astro, static | CDN or nginx | :4321 |
frontend | Next.js App Router, TypeScript | stateless, horizontal | :3000 |
api | FastAPI, Pydantic v2, SQLAlchemy 2, Alembic | stateless, horizontal | :8080 |
worker | Python, shares the backend package | horizontal via SKIP LOCKED | none |
postgres | PostgreSQL | system of record and queue | internal |
| Chose | Over | Why |
|---|---|---|
| Modular monolith + worker | Microservices | Small team, shared transactions. |
| Queue in PostgreSQL | Redis, Celery, Kafka | Transactional enqueue, one less moving part. Tens of actions per hour, not thousands per second. |
| Relational graph + BFS | Neo4j | Up to about 10⁴ edges per workspace; recursive CTEs if it ever needs more. |
| Refuse v2-versioned environments | Implement the versions API | Correct or nothing in v0.1. |
| Management API only | Read Flagsmith's database | Flagsmith stays the source of truth and its upgrade path stays clean. |
The full design record lives in decisions/ARCHITECTURE.md in the repository.