OpenGov Tech Stack
Status: living reference (engineer-facing).
OpenGov is a modular monolith: one FastAPI app, one shared PostgreSQL, strict module ownership — designed to be split into independent services later. It runs as a self-hosted Docker-Compose stack, one isolated instance per country.
This page is the index. Depth lives in two places: the full architecture in docs/specs/2026-04-04-opengov-mvp-architecture.md, and how a deployment boots and routes in docs/reference/deployment-architecture.md.
The stack at a glance
| Layer | Choice | Notes |
|---|---|---|
| Backend | Python 3.15 + FastAPI | Async throughout |
| ORM / DB | SQLAlchemy 2.x async on PostgreSQL 18 | asyncpg + psycopg; Alembic migrations in migrations/ |
| Background jobs | Procrastinate | Run with python3 -m opengov.worker |
| Validation | Pydantic v2 | Request/response models |
| Frontend | React 19 + TypeScript + Vite + Tailwind CSS 4 | One SPA per tool; shared design system in frontend/shared/ (OGDS) |
| Auth | Keycloak OIDC (dev/test), standards-based OIDC (production) | |
| Testing | pytest (backend), Vitest (frontends) | pytest-xdist for parallel runs |
| Lint / format | ruff (Python), ESLint (TS) | |
| Deployment | Docker Compose, single host per country | Managed via Coolify in production |
The four tools
Four tools share the one backend; each is its own SPA and its own module.
| Tool | Module (backend) | SPA (frontend) | Role |
|---|---|---|---|
| SmartRules | src/opengov/smartrules/ | frontend/editor/ | Agency staff author registration procedures as structured rules and publish them as open-standard APIs |
| eApproval | src/opengov/eapproval/ | frontend/approval/ | Verification runtime — claim-based review, configurable DAG, role-driven assignment |
| SmartLink | src/opengov/smartlink/ | frontend/smartlink-admin/ | External database verification — query third-party registries, audit every lookup |
| eRnext | — | frontend/portal/ | Applicant portal — discover, apply, track (consumes the published APIs) |
Module ownership
Table ownership is strict: each module owns its tables and never touches another module’s tables directly. Cross-module access goes through each module’s service.py interface — except worldmodel, whose write path is worldmodel/runtime.py.
| Table prefix | Owner |
|---|---|
smartrules_* | SmartRules |
eapproval_* | eApproval |
smartlink_* | SmartLink |
payment_* | payments |
wm_* | worldmodel (compiled register output) |
vault_* | vault |
notification_* | platform/notifications |
platform_* | platform (owned by platform, read by all) |
published_versions | SmartRules writes, others read (the seam) |
Enforced by scripts/ci/table_access_guard.py (make table-access-check).
Deeper reading
- Full architecture —
docs/specs/2026-04-04-opengov-mvp-architecture.md(topology, scope, constraints). - Deployment —
docs/reference/deployment-architecture.md(containers, self-boot, routing, onboarding). - Module interactions —
docs/runbooks/module-interactions.md(the cross-module rules and exact service APIs). - Concept ground truth —
docs/reference/SmartRules-Overview-v4.md.