# Architecture overview Status: phase 1 walking skeleton built and verified against a real `loreserver`; a first production deployment (Linux, systemd, Caddy, TLS, backups) is written but not yet run on Linux. Last updated 2026-11-26. ## What lore-forge is A single Rust binary that runs beside an unmodified Lore server (`loreserver`) and provides what Lore deliberately leaves out: - accounts and sign-in, including GitHub, Discord and Google; - the tokens `loreserver` verifies, scoped per repository; - user and organisation namespaces, teams and permissions; - a web forge: repository browsing, change requests, review-gated landing, activity. lore-forge is **not** a proxy. Repository data flows directly between Lore clients and `loreserver`. lore-forge handles login, tokens, permissions and the web UI. ## Why this shape Lore's server has no user database and no login. It verifies JWTs issued by an external OIDC issuer and reads permissions from token claims. Any off-the-shelf provider can supply global roles, but Lore's own survey found no open-source provider able to issue the per-repository tokens its finer-grained mode needs, and the sample service Lore ships for that is marked as not for production. lore-forge fills that gap by being the issuer. See [lore-integration.md](lore-integration.md). ## Block diagram ``` ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────────────────────┐ │ Lore CLI │ │ Browser │ │ CI jobs │ │ Sign-in providers │ │ │ │ │ │ │ │ GitHub, Discord, Google │ └─┬──────┬─┘ └────┬─────┘ └────┬─────┘ └────────────┬─────────────┘ │ │ login, │ web UI │ API tokens │ OAuth redirects │ │ tokens │ │ │ │ ┌──▼─────────▼─────────────▼─────────────────────▼─────────────┐ │ │ lore-forge (one Rust binary, one data directory) │ │ │ ┌──────────────────────────────────────────────────────────┐ │ │ │ │ Web layer: server-rendered UI, JSON API │ │ │ │ └──────────────────────────────────────────────────────────┘ │ │ │ ┌────────────────┐ ┌────────────────┐ ┌────────────────────┐ │ │ │ │ Accounts │ │ Token issuer │ │ Access │ │ │ │ │ sign-in, │ │ signs Lore │ │ orgs, teams, │ │ │ │ │ invites │ │ tokens │ │ role presets │ │ │ │ └────────────────┘ └────────────────┘ └────────────────────┘ │ │ │ ┌────────────────┐ ┌────────────────┐ ┌────────────────────┐ │ │ │ │ Repo browser │ │ Change │ │ Activity │ │ │ │ │ trees, diffs, │ │ requests, │ │ events, webhooks │ │ │ │ │ locks │ │ landing │ │ │ │ │ │ └────────────────┘ └────────────────┘ └────────────────────┘ │ │ │ ┌───────────────────────────┐ ┌────────────────────────────┐ │ │ │ │ Lore client │ │ SQLite │ │ │ │ │ gRPC as the signed-in user│ │ data, signing keys, cache │ │ │ │ └─────────────┬─────────────┘ └────────────────────────────┘ │ │ └───────────────┼──────────────────────────────────────────────┘ │ repository data │ browse, land, subscribe ▲ keys, registry, │ (QUIC / gRPC) │ │ name lookup ┌─▼───────────────────▼──────────────────────────────┴───────────────┐ │ loreserver: unmodified Lore server. Verifies tokens locally and │ │ stores all repository data. Hosts every namespace's repositories. │ └────────────────────────────────────────────────────────────────────┘ ``` `loreserver` calls back into lore-forge for three things: signing keys at startup, approval of repository creates and deletes, and user name lookups. ## Modules One cargo workspace, built as a modular monolith. Crate names are provisional. Built so far: `forge-store`, `forge-access`, `forge-id`, `forge-lore`, `forge-web` and the `lore-forge` binary. `forge-core` and `forge-events` come with phases 2 and 3. | Crate | Responsibility | Design document | | --- | --- | --- | | `forge-id` | Accounts, sessions, provider linking, the token issuer | [accounts-and-sign-in.md](accounts-and-sign-in.md), [token-issuer.md](token-issuer.md) | | `forge-access` | Namespaces, orgs, teams, grants, role presets, the Lore registry service | [namespaces-and-access.md](namespaces-and-access.md) | | `forge-lore` | Lore's protocols: serves `UserService` and `RepositoryRegistryService`, generates the `loreserver` config; later a typed client for `loreserver`. The only crate that depends on Lore's protocol definitions | [lore-integration.md](lore-integration.md) | | `forge-core` | Change requests, reviews, comments, landing | [forge-features.md](forge-features.md) | | `forge-events` | Lore notification subscriber: activity feed, webhooks | [forge-features.md](forge-features.md) | | `forge-web` | HTTP server, templates, JSON API | [web-ui.md](web-ui.md) | | `forge-store` | SQLite access and migrations | [storage.md](storage.md) | There is no separate worker process. Landing a change is a single call to `loreserver`, so background work runs as tasks inside the one binary. ### Desktop client A separate tree, `desktop/`, holds the client side: `forge-service` (a per-user Rust service that drives Lore through liblore and runs policies such as autosync), `forge-desktop` (a C++ tray application, Dear ImGui on vendored UHDK) and later `forge-tui`. The frontends talk to the service over a local socket. It has its own Cargo workspace and `zig build`, so the server never needs Zig. See [desktop-client.md](desktop-client.md). ## Decisions | Topic | Decision | Source | | --- | --- | --- | | Relationship to Lore | Issuer and forge beside `loreserver`, not a proxy in front of it | Follows from Lore's design | | Scope | Full forge, built in phases with identity first | Owner | | UI | Server-rendered from the Rust binary | Owner | | Second factor | None required. "2FA" in the original brief meant sign-in through GitHub, Discord or Google | Owner | | Account model | Follow piki: local accounts, signup toggle, invite keys, explicit provider linking | Owner | | Database | SQLite | Owner | | Repository layout | GitHub-style user and organisation namespaces | Owner | | Permission UI | Role presets, with an advanced per-action view | Owner | | Landing | Per-branch choice between review-gated and direct push | Owner | | Permission source | Grants managed in lore-forge, optional mapping from GitHub teams and Discord roles later | Recommended; owner had no preference | | Deployment | `loreserver` as a separate process; lore-forge generates its auth config | Recommended; owner had no preference | | Lore binaries | The official release pinned with SHA-256 in `lore.lock`, fetched into `.lore/`; `scripts/start.sh` runs a whole deployment from `run/` | Owner, 2026-11-25 | | Desktop client | A per-user client service (Rust, liblore) with a C++ Dear ImGui tray GUI (pixel-art look) on vendored UHDK and a later Rust TUI as frontends, in `desktop/` | Owner, 2026-11-25; details in [desktop-client.md](desktop-client.md) | | Desktop SYNC and SUBMIT | SYNC pulls and keeps local edits; SUBMIT commits and pushes the files checked in CHANGES, all by default | Owner, 2026-11-25; details in [desktop-client.md](desktop-client.md) | | Desktop autosync and locks | Autosync only pulls, and warns and refuses rather than overwrite overlapping local edits; the GUI locks and unlocks files, SUBMIT releases your locks, and the service refuses submits of files others hold (Lore itself does not enforce locks) | Owner, 2026-11-26; details in [desktop-client.md](desktop-client.md) | | Production deployment | One Linux host with systemd; one public hostname and Let's Encrypt certificate shared by Caddy (forge) and `loreserver` (QUIC and gRPC over TLS); nightly backups that stop `loreserver` for seconds | Owner, 2026-11-26; details in [deployment.md](deployment.md) | | Audience | A self-hosted instance for one studio or community | Assumed; owner had no preference | | Per-repo tokens | Use Lore's per-repository token mode from the start | Recommended, not explicitly confirmed | | Identity in Lore history | A stable internal user ID, with names resolved through lore-forge | Owner, 2026-11-25 | | Database library | `sqlx` with its built-in migrations | Owner, 2026-11-25 | | Templates and interactivity | maud and vendored htmx | Owner, 2026-11-25 | | Phase 1 order | Walking skeleton first: store, keys, issuer grants and registry, tested against a real `loreserver`; full account UI after | Owner, 2026-11-25 | | Who may create orgs | An owner setting, defaulting to instance admins only | Defaulted, not confirmed | | Web UI look | The desktop client's pixel style: VGA font, Sweetie 16 palette | Owner, 2026-11-25 | | Passkeys | Dropped for now; possibly later | Owner, 2026-11-25 | | Service accounts | `users` rows of kind `service`, named `.`, logging in with client credentials | Implementation choice | | Browser reads | As the viewer, with a one-minute read-only repository token per page view; file diffs computed in lore-forge because Lore's `ContentDiff` is unimplemented | Implementation choice | | Browser layout | FILES, GRAPH and TREE, as in the desktop explorer | Owner, 2026-11-25 | | Provider sign-in testing | Built and tested against an in-process fake; the owner registers real apps later | Owner, 2026-11-25 | | Token lifetimes | Login token 1 h, scoped 5 min, CLI login 30 d idle / 90 d max | Defaulted, not confirmed | | Ports | Pages, issuer and Lore's gRPC directory share one port, routed by content type | Implementation choice | | Revocation speed | Token exchange checks the CLI login is live, so revoking a login ends repository access within five minutes | Implementation choice | ## Phases 1. **Identity.** `lore auth login` works end to end: accounts, provider sign-in, the issuer, namespaces, grants, per-repository tokens. Everything else depends on this. - **Done (walking skeleton):** store and migrations, ES256 keys, discovery, JWKS, device grant, refresh with rotation, token exchange, revocation, the registry and user directory over gRPC, setup, password sign-in and device approval pages. Verified by `scripts/e2e-lore.sh` against the Lore v0.14.0 release. `scripts/start.sh` starts a deployment from this repository alone. - **Done (accounts, milestone A):** signup modes and invite keys; GitHub, Discord and Google sign-in and linking (tested against a fake provider); session and CLI-login lists; organisation, team, member and grant pages; service accounts with the client credentials grant; API tokens, API-key login and a first JSON API; key rotation from the UI and the `rotate-signing-key` command; sign-in rate limiting; the admin pages; the pixel restyle. API-key and client credentials logins are in the e2e test. - **Remaining:** a first sign-in against each real provider. Passkeys are dropped for now. 2. **Read-only forge.** Repository list, file browser, history, diffs, locks, activity feed. - **Done (browser, milestone B):** FILES, GRAPH and TREE tabs and a revision page with diffs, read from `loreserver` as the viewer. Verified by unit tests against an in-process fake and by `scripts/e2e-lore.sh` against the Lore v0.14.0 release, including a branch and a merge. - **Remaining:** history paging, downloads, locks, activity feed. 3. **Collaboration.** Branch-based change requests, reviews, comments, gated landing. 4. **Integrations.** Webhooks, Discord notifications, CI status checks, API tokens for CI. 5. **Game-development specifics.** Asset previews (textures, `.uasset` thumbnails), lock management. Deployment is not a phase of its own: [deployment.md](deployment.md) records the production shape and what about it is verified. The desktop client has its own milestones, in [desktop-client.md](desktop-client.md). Milestones 1 (the GUI and tray shell), 2 (liblore in the service: real workspaces, sign-in through the forge, clone, submit and sync) and 3 (file locking, autosync and notifications) are done on macOS. ## Things to keep in mind - **Epic plans its own web client.** Lore's roadmap lists an open-source web client with code review tools as committed for 2027. lore-forge overlaps with it. The parts Epic is least likely to cover are the identity layer, GitHub and Discord integration, and single-binary self-hosting. - **Lore is pre-1.0.** Its APIs and protocols can change between releases. All contact with Lore is confined to one crate for that reason. - **The issuer is the most sensitive component.** Whoever holds its signing keys can mint access to every repository. See the security section of [web-ui.md](web-ui.md).