Workflow was retired 2026-11-14: remove its catalog entry, COMPASS_BASE_URL setting, env example and README mention. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
13 KiB
Panorama
Pulpit platformy: bieżące liczby z modułów i trendy ze zdarzeń.
Self-hosted and single-tenant, built on dredd-core — the shared substrate this app family installs as a dependency rather than copies.
What Panorama is
The platform's dashboard (work package M4 of the Compass split, docs/plans/2026-11-06-podzial-compassu.md
in the Compass repo), split out of Compass: its dashboard, the per-person layout (dashboard_layout)
and the durations chart. It is rebuilt on two read contracts, never on another module's tables:
- Current numbers come from each module's
GET /api/v1/stats(dredd-core'sstats_contract, 0.23.0), called with the person's own session token throughdredd_core.module_client, so each module applies its own authorisation. A tile counts only what that person may see and equals the list its link opens (<module>/#/<link>). Panorama adds nothing up and re-checks nothing. - History and trends come from the platform's event log (
module_event, dredd-core 0.20.0), read through the log's reader tier (SELECTonly, 0.23.0). Events carry ids and numbers only; the charts show sums (events per day and kind, how long documents took between two kinds of event), never a document. Because events are not filtered per person,TRENDS_AUDIENCEkeeps the charts to moderators by default.
Which modules exist is configuration: GALENA_BASE_URL, SYGNA_BASE_URL, COUNSEL_BASE_URL,
ARBITER_BASE_URL, LEXICON_BASE_URL, AGORA_BASE_URL, PARAFA_BASE_URL, SCRIBE_BASE_URL, INSIDER_BASE_URL
(each module's public base URL; empty = not deployed). A module that is absent, down, slow
(STATS_TIMEOUT_SECONDS, parallel calls) or closed to the person is a status on its card
(absent · unavailable · no_access), and the rest of the dashboard renders.
Standalone (no IDENTITY_SCHEMA) Panorama runs, but its session means nothing to another app and
there is no event log, so every card says so: its numbers need the platform's one account.
Stack
FastAPI + SQLAlchemy 2 + Alembic + PostgreSQL 16 / 17, Argon2id password hashing, server-side cookie sessions, an append-only audit log enforced by database grants, RFC 9457 Problem Details errors, opt-in OpenTelemetry, and a no-build vanilla-JS console (Open Color palette, Tabler icons, light/dark theme, two languages). Shipped with Docker Compose; the backend is its own edge (no reverse proxy). Apache-2.0, and CI refuses any GPL/AGPL/SSPL dependency.
dredd-core
Identity and sessions, authentication, the access-control resolver, the org tree, the audit
writer, the security primitives, the shared enums and error types, and the engine/session
factories all come from one installed package. backend/requirements.txt pins it by tag:
dredd-core @ git+https://github.com/Alpaq92/dredd-core@v0.23.0
The app-side files that used to hold that code (services/auth.py, models/__init__.py,
security.py, errors.py, … and, in nodes tenancy, services/authz.py) are now thin shims:
they re-export from dredd_core so every call site keeps its import path, and they hold only what
is genuinely this app's — the panorama_pat_ token prefix, the panorama_session cookie,
the settings fed into core's auth policy. Fixing shared behaviour means changing dredd-core, tagging
a release and moving the pin here — never patching a shim.
dredd-core ships models, not migrations: importing it registers its tables on the shared
metadata, and this repo owns its own 0001 (native enum types are created first, then
create_all). A core upgrade that changes the schema needs a new revision here.
It is a private repository. Local installs use your own GitHub credentials; CI authenticates
with a DREDD_CORE_TOKEN repository secret (a fine-grained PAT with read access to
Alpaq92/dredd-core), which the workflow injects before pip install. Without it, the install
step fails with an authentication error.
This app is its own deployment with its own domain data. It shares code with its siblings, not that data: locally it has its own database; in the family's shared managed database it has its own schema and roles, which no sibling's roles can reach.
Identity is the exception, and it is shared on purpose: the family's shape is one platform, one
account, one admin pane — one origin, one module per path, where you sign in once at the hub and
every module resolves the same session. Separate schemas, one roster. As scaffolded this app is
standalone: it serves at the root of its own host with its own accounts, its own sign-in and its
own Users administration, and it keeps running that way whatever the family does. Mounting it under
a path prefix of a shared origin is one setting (ROOT_PATH, empty by default) and no code change.
Joining the platform
Sharing the roster is one more setting, IDENTITY_SCHEMA, plus three steps that are not this app's
to take. Once it is set, app_user, session and module_permission live in a neutral schema the
hub owns and this app reads: there is no password here, the sign-in screen becomes a link to the
hub, creating or re-passwording an account answers 409 pointing there, and app tokens stay listable
and revocable but are minted at the hub. And module_permission is what decides who may open this
app at all — no row for this module is no entry — so the hub is where somebody is admitted to it
and where somebody is made its moderator. Standalone that table is inert: there is one application,
and having an account here is permission to use it. One origin means one cookie, so there is no handoff to
build — no signed assertion, no audience binding, nothing to exchange. A design that adds one for
this topology is over-engineering.
Both shapes are the same code, switched at runtime, and that is the property to defend: the moment they fork, the shape nobody runs locally is the shape that breaks.
The order matters, because only the last of the four steps happens in this repository:
- The platform admin provisions.
db/managed/provision.sql, re-rendered with--identity-schema dredd --identity-owner atrium_migrator(commit it, and add the same flags to CI's--check-filestep — the platform'spush.shrefuses a module whose committed file is not that rendering): the schema,USAGEfor this app's two roles, and asearch_paththat reaches it. A migrator role may do none of those. The kit also setsFRAME_ANCESTORS='self'. - The hub migrates. It owns the schema, so it creates the three tables and grants this app's
roles their tier — a column-restricted
SELECTonapp_userthat does not includepassword_hash,SELECTplus a narrowUPDATEonsession,SELECTand nothing else onmodule_permission, andINSERTon none of them. - A person imports any account this app has and the hub does not. Neither side can do it alone,
by design, so it is a platform-admin step run from a census of every schema's
app_user. alembic upgrade headhere runs0003_shared_identity: it matches this schema's accounts to the shared ones by e-mail address, rewrites every id that names a person, re-points every foreign key, and drops the local copies. Read it before running it on anything you care about. Sessions and app tokens are deliberately not carried over — everybody signs in once more, at the hub.
Two administration tiers come with it, and these are the only two words for them: an administrator is platform-wide and is made in the hub; a moderator administers this module only, is also made in the hub, and is merely read here. Standalone they are the same thing and nothing queries anything.
Quick start
cp .env.example .env # then set the three DB passwords
DREDD_CORE_TOKEN=github_pat_... docker compose up -d --build # postgres -> migrate(+seed) -> backend
Building the image needs
DREDD_CORE_TOKEN(a read-only fine-grained PAT forAlpaq92/dredd-core) in your shell — compose hands it to the build as a BuildKit secret, so it never lands in an image layer. Don't put it in.env: every container loads that file at runtime. CI'scompose-smokejob runs exactly this stack on every push.
Open http://localhost and sign in with BOOTSTRAP_ADMIN_EMAIL / BOOTSTRAP_ADMIN_PASSWORD.
Windows: write
.envwithout a BOM —[System.IO.File]::WriteAllText("$PWD\.env", (Get-Content .env.example -Raw)). PowerShell'sOut-File -Encoding utf8adds one, and pydantic-settings folds it into the first key name, which produces a baffling "field required" error at startup.
Development
cd backend
python -m venv .venv && . .venv/Scripts/activate # or: source .venv/bin/activate
pip install -r requirements-dev.txt # pulls dredd-core from GitHub — needs repo access
pytest # DB-free unit tests
alembic upgrade head --sql # inspect the DDL without a database
python scripts/license_gate.py # no GPL/AGPL/SSPL
python scripts/deploy_check.py # stack-definition coherence
node --check ../frontend/app.js # the console has no build step, so this is the check
The API is served under /api/v1, with OpenAPI docs at /api/v1/docs.
Deploying on a managed PostgreSQL
The Dredd family can run in one shared managed database (one PostgreSQL 16/17 database at a managed
provider), with Atrium as the hub; Panorama joins it as schema panorama with its own roles
panorama_migrator and panorama_app. The provider hosts only the database — the backend still
runs on your server, with docker compose -f docker-compose.yml -f docker-compose.managed-db.yml up -d --build. The same path works against any PostgreSQL 16/17 whose admin may create roles and schemas.
- Database-wide steps (creating the database, the provider's root CA, keeping the schemas out of
any auto-generated API, TLS enforcement, network restrictions, the connection budget, backups and
point-in-time restore): step 0 of
db/managed/README.md, and in more depth the family runbook in Atrium,deploy/README.md. - Panorama's steps (provisioning with
python -m dredd_core.managed provisionor the rendereddb/managed/provision.sql,.envwithDB_APP_ROLEand the pool knobs, migrate + seed,python -m dredd_core.managed check, restore specifics):db/managed/README.md. - Connect through the provider's pooler in session mode (never a transaction-mode port such as
6543) or directly, as
<role>— or<role>.<tenant>where the pooler wants the tenant in the user name — with?sslmode=verify-full&sslrootcert=/run/certs/db-ca.crt. Never migrate aspostgres. - The TLS rule: a database host that is not local (
"",localhost,127.0.0.1,::1,postgresor aDB_LOCAL_HOSTSentry) must carrysslmode=verify-full, or the app refuses to start.
CI's managed-db job rehearses this path on PostgreSQL 17 without a superuser: it emulates a managed
Postgres (python -m dredd_core.managed emulate), provisions the app next to a sibling, migrates, runs
the integration suite as panorama_app and runs the managed check.
Security model
Two Postgres roles do the heavy lifting. migrator owns DDL and is used only by Alembic; app
is the runtime role and holds DML only. The migration then revokes UPDATE/DELETE on
audit_log from app, which is what makes the audit log evidence rather than a convenience: a
compromised application cannot rewrite its own history, because the database will not let it.
The runtime role's name is configuration (DB_APP_ROLE, app by default): the grants migration
(0002_runtime_grants) grants to it and fails loudly — rolling back — when that role is missing,
when it runs as a superuser or the platform admin, or when a grant did not take. Migrations run as the
migrator and nothing else.
Only the backend is published to the host (:80) — it serves the console and sets every security
header itself (backend/app/edge.py); Postgres is expose-only. There is no reverse proxy.
Access control lives in exactly one module, backend/app/services/authz.py — a re-export of
dredd_core.authz in nodes tenancy, a local admin/owner check in simple tenancy. No access
returns 404, not 403: a 403 confirms that the record the caller may not see exists.
Project layout
| Path | What |
|---|---|
backend/app/models/ |
this app's ORM entities; __init__.py re-exports dredd-core's |
backend/app/services/ |
every domain rule and all SQL; auth/audit are core shims (authz too, in nodes tenancy) |
backend/app/routers/ |
HTTP shape, validation, authz calls — no SQL |
backend/alembic/ |
0001: enum types → create_all; 0002: runtime grants for DB_APP_ROLE |
backend/scripts/ |
license gate, deploy pre-flight |
frontend/ |
the console: index.html + app.css + app.js, no bundler |
db/init/ |
least-privilege role creation for the local stack, run once by Postgres |
db/managed/ |
the shared managed database: rendered provision.sql + this app's runbook |
docker-compose.managed-db.yml |
override for a managed database: no local postgres, CA mounted, no migrator in the backend |
License
Apache-2.0. See CREDITS.md for dependencies and design credits.