Architecture
One Rust binary (Leptos SSR + hydrate, Axum underneath) serving any number of sites, one process each. The engine special-cases nothing: every page, form, desk and state graph a site serves is declared in its content repo, and instances differ only by environment variables.
Each site keeps everything it has in one redb file of its own. The
programs beside it (mail, payments, search, chat) dial it over dhd/1,
an iroh protocol, with keys of their own; anything else talks to it over
HTTPS with a token. A Git repo holds the content, and any OpenID
provider (Vipps Login, Kanidm, Rauthy) signs people in.
The pieces
Content (crates/core/src/content/) — YAML loaded from Gitea (or a
directory, CONTENT_DIR) at boot and again whenever the content repo’s
CI asks (Load), all of it checked
before any of it is swapped in, so a bad push keeps the last good content
serving. The questions/ tree is the router: file paths
become URLs, _section.yaml applies to a whole directory, and
[name].yaml serves any /dir/<value> with the segment fed into the
page’s resource keys. See filesystem routes.
The lint (crates/core/src/content/validate.rs) — every rule a content repo
is held to. It runs at boot, at every Load, and in a content
repo’s CI through iris (crates/iris), released with the site, so
it applies exactly the version the instance runs.
State machines (crates/core/src/aggregates/) — aggregates.yaml declares
each bucket’s states and legal moves. A record’s state is replayed
from its own event history, undeclared moves are refused, and racing
decisions are settled by CAS on the log’s sequence. An empty history
starts its log from the record’s own state on its first move, so a
bucket given a state graph later strands nothing. See state machines.
The store (crates/core/src/store/, crates/core/src/answers.rs) — a
site’s records, their event logs, its sessions and its outboxes, in one
redb file only the site’s process opens. A submission or a decision is
one batch: its event, the record that follows it, and whatever it tells
the programs beside the site (its mail, a request for money, the
answer for automations, a room’s message), written together or
not at all. Every commit is told to whoever watches the store; the
lists on pages are kept current from it (listing), and an open page
hears which of its lists a commit changed, over one server-sent stream
(GET /live, live), and reads those again. What the site keeps only
for a while (a change talked through, a web interview) is a bucket that
forgets past an age (store::Kept).
The network (crates/core/src/network.rs, crates/dhd/src/one.rs)
— dhd/1, irpc over iroh. The site dials no one: each program dials
the site’s key with a key of its own, and the site does for it only
what the instance names that key for (DHD_KEYS). A program holds
Serve open, takes the rows of the outboxes it does and acknowledges
each, and answers questions asked down the same call (learn’s
ranking); its open call is its presence. The other calls are Submit,
Move, Note, May, Watch, and the deploy’s Load and the
operator’s Read. The same calls go over HTTPS with a token
(dhd_http.rs), and an outbox may be posted as signed webhooks instead
(hooks.rs).
The wire (crates/dhd/) — the names and shapes portal shares with
the programs beside it, as a crate of their own: the protocol
(dhd::one, feature one) and the records and messages it carries
(Answer, the event log’s Event, the mail gate’s Outgoing and
Incoming, the money service’s Request and Changed, the rooms’
GroupDoc and Thread, the access Query and Decision). Portal
re-exports them, so portal::payments::Request is
dhd::payments::Request; gdo, kron, learn and the chat depend on it
from this repo. The rule for what belongs there: a name both sides must
spell the same, or a shape both sides serialize; never anything that
reads content or decides. Named for the dial-home device.
Answer chains (crates/core/src/chain.rs) — each submission hashes its
parents, so a visitor’s path through the questions is a verifiable
lineage. ?chain= links carry it; a followup page is offered only
once the chain has earned it, and a page behind an answer somebody has
not given is never offered.
Access (crates/core/src/access.rs) — who may do what to what, compiled from
content on every load into one Cedar policy set that every server
entry point asks. See access.
People (crates/core/src/memberships.rs, people.rs, rauthy.rs)
— onboarding as a form. An alternative with invite: {group} holds the
person a place in the group: a record in portal’s own memberships, or
a group in Kanidm or Rauthy (PEOPLE_BACKEND), with an account and a
one-time link where the backend makes accounts. A state may also grant
a group on its own (grants:), so an approval that means membership
needs no second step. See memberships.
Mail (crates/core/src/mail.rs) — a state may declare the mail its
arrival sends. Portal renders it into the mail outbox with the move;
gdo takes it from there, delivers
it, and hands replies back as notes beside the record. A note never
moves a case. A mail about a time carries the event (event: under
mail:), and gdo decides how it reaches a calendar.
Presence (crates/core/src/presence.rs) — who is beside the site:
every program holding Serve open, with what it says about itself
(dhd::srv: a money service’s providers, whether the mail gate reaches
a calendar). A payment names the provider a kron here has; a feature
that depends on a program reads the table and does what portal does
alone when nobody is there.
Backups (crates/portal/src/backup.rs) — a snapshot of the store
every six hours, sealed to the operator’s age key on the site, to
garage, or into varde and pushed to its trusted peers.
Sweepers (crates/core/src/announce.rs, crates/core/src/deadlines.rs) — the two things
that move without a person. An announced page’s window closes and its
record becomes a “post what happened” task; a state with a deadline
waits out its days and then makes the move itself. Both go through the
same transition path as a desk button and write the same event.
Resources (crates/portal/src/resource.rs) — content can read a bucket of records,
Gitea starred repos, org repos or releases, or any public JSON URL
(SSRF fail-closed), reshaped by a content-declared jq filter. What a
resource reads is never a client-supplied parameter: the client names
a page and a feature, never a bucket or URL.
Maps and icons (crates/portal/src/maps.rs, icons.rs) — MapLibre
is vendored, and every tile, style, still image and icon is fetched by
portal and served from the site’s own origin, so a page makes no
third-party request and needs no consent banner.
Desks — any Kv resource with transitions renders rows with
per-state buttons and one shared confirm. Owners walk records through
their graphs with no bespoke UI per bucket.
Sessions (crates/portal/src/sessions.rs) — in the site’s store,
so a restart signs nobody out. A sweep deletes what is past its date,
and each record’s own expiry_date decides on the way out.
Crates and binaries
One repo, one version, three binaries, and under them the crates they
share (the root Cargo.toml is the workspace):
crates/content(portal-content) — what content means: the types a site’s YAML describes, their validation, the words. Compiles for the browser too; no network, no HTTP.crates/core(portal-core) — the instance: content as the server keeps it, records and their state machines, mail, people, access, boards, rooms, memberships, notices, payments, the kit’s briefs (queued for its worker,briefs), learn and the search ranking, the lint. A function over content or over the runningInstancelives here; a function over a request does not.crates/bratac— the trainer and the kit worker, as a library with thebratacbinary. The site runs two of its pieces itself (the interview engine behind the card, the chooser behind the search box), soportaldepends on it; nothing in it knows the server exists.crates/iris— the lint as theirisbinary, overportal-core.crates/portal— the site: the pages, the server functions, the routes, and theportalbinary (serve, and stilllint,iris,mapandmanual, so a content repo’s pinned lint keeps working).crates/dhd— the wire, and the protocol every program beside the site speaks (dhd::one).learn/— the ranker, a nested package outside the workspace with a lock of its own; see learning.
The release tarball carries portal, bratac, iris and learn side
by side, and each as a bare binary; see operations.