Architecture Guide for contributors working on HappyView itself. For a user-facing overview, see the Introduction .
Queries go through the query handler to the database (SQLite by default, or Postgres). Writes go through the procedure handler to the user's PDS, then HappyView indexes the record locally. Real-time record events stream in via Jetstream ; historical records are backfilled in-process by discovering repos via the relay's listReposByCollection and fetching records directly from each PDS. Labelers are external services that emit content labels over a direct WebSocket connection — they operate out-of-band, outside the relay/repo system. Spaces provide permissioned data containers with membership-gated access, per-user repo state tracking (LtHash + signed commits), and cross-service credential-based authentication.
Column Type Description uritext (PK) AT URI (at://did/collection/rkey) didtext Author DID collectiontext Lexicon NSID rkeytext Record key recordjsonb Record value cidtext Content identifier indexed_attimestamptz When HappyView indexed this record
Column Type Description idtext (PK) Lexicon NSID revisioninteger Incremented on upsert lexicon_jsonjsonb Raw lexicon definition lexicon_typetext record, query, procedure, definitions backfillboolean Whether to backfill on upload target_collectiontext For queries/procedures: which record collection created_attimestamptz updated_attimestamptz
Column Type Description iduuid (PK) didtext (unique) User's atproto DID is_superboolean Whether this is the super user (only one allowed) created_attimestamptz last_used_attimestamptz Updated on each authenticated request
Column Type Description user_iduuid (FK) References users.id permissiontext Permission string (e.g. lexicons:create) (PK) Composite primary key: (user_id, permission)
Column Type Description iduuid (PK) user_iduuid (FK) References users.id nametext Descriptive label key_hashtext SHA-256 hash of the full key key_prefixtext First 11 characters for display permissionstext[] Permissions granted to this key created_attimestamptz last_used_attimestamptz revoked_attimestamptz Set when revoked (soft delete)
Column Type Description didtext (PK) User's atproto DID session_datatext Serialized OAuth session (managed by atrium) created_attimestamptz updated_attimestamptz
Column Type Description state_keytext (PK) OAuth state parameter state_datatext Serialized state (managed by atrium) created_attimestamptz
Column Type Description keytext (PK) Setting name (e.g. app_name) valuetext Setting value updated_attimestamptz Last modified
Column Type Description iduuid (PK) event_typetext Category.action format (e.g. user.created) severitytext info, warn, or erroractor_didtext DID of the user who triggered the event subjecttext What was affected (DID, NSID, URI, etc.) detailjsonb Event-specific data created_attimestamptz
Column Type Description keytext (PK) Variable name valuetext Variable value (encrypted at rest) created_attimestamptz updated_attimestamptz
Column Type Description idtext (PK) Internal space identifier didtext The space's own DID authority_didtext DID that controls the space creator_didtext DID of the user who created the space type_nsidtext Space type as an NSID skeytext Space key (differentiates spaces of the same type) display_nametext Human-readable name (optional) descriptiontext Description (optional) mint_policytext member-list, public, or managing-appapp_accesstext (JSON) {"type":"open"} or {"type":"allowList","allowed":[...]}managing_app_didtext DID of the managing app (optional) configtext (JSON) Space config (membershipPublic, recordsPublic, extras) revisiontext Current revision TID created_attext updated_attext
Column Type Description idtext (PK) space_idtext (FK) References spaces.id didtext Member's DID (or space URI for delegation) accesstext read, read_self, or writeis_delegationboolean Whether this member is a delegated space granted_bytext DID of who granted membership created_attext
Column Type Description uritext (PK) at:// URI of the recordspace_idtext (FK) References spaces.id author_didtext DID of the record author collectiontext Lexicon NSID rkeytext Record key recordjsonb Record value cidtext Content identifier indexed_attext
Column Type Description idtext (PK) space_idtext (FK) References spaces.id author_didtext DID of the repo author lthash_statebytea 2048-byte LtHash state revtext Current revision hashbytea Content hash ikmbytea Input keying material for deniable signatures sigbytea Signature macbytea Message authentication code updated_attext
Column Type Description idtext (PK) space_idtext (FK) References spaces.id author_didtext DID of the operation author revtext Revision this operation belongs to idxinteger Index within the revision actiontext create, update, or deletecollectiontext Lexicon NSID rkeytext Record key cidtext Content identifier (for create/update) prevtext Previous CID (for update/delete) created_attext
Column Type Description idtext (PK) space_idtext (FK) References spaces.id author_didtext Filter by author DID (optional) endpointtext Notification endpoint URL registered_bytext DID of who registered expires_attext When the registration expires created_attext
Column Type Description idtext (PK) space_idtext (FK) References spaces.id token_hashtext SHA-256 hash of the invite token created_bytext DID of the user who created the invite accesstext Access level granted: read, read_self, write max_usesinteger? Maximum number of uses (null = unlimited) usesinteger Current use count expires_attext? Expiry timestamp (null = never) revokedboolean Whether the invite has been revoked created_attext
Column Type Description idtext (PK) space_idtext (FK) References spaces.id issued_totext DID the credential was issued to token_hashtext Hash of the credential token expires_attext When the credential expires created_attext
Column Type Description idtext (PK) didtext The space's DID space_idtext (FK) References spaces.id signing_key_enctext Encrypted signing key (AES-256-GCM) rotation_key_enctext Encrypted rotation key (AES-256-GCM) created_bytext DID of who provisioned the key created_attext
Column Type Description idinteger (PK) Always 1 (singleton) modetext did_web, did_plc, or linked_accountdidtext The service's DID signing_key_enctext Encrypted signing key rotation_key_enctext? Encrypted rotation key (did:plc only) attached_account_didtext? Linked account DID (linked_account mode) setup_completeboolean Whether setup has been finalized created_attext updated_attext
Column Type Description idinteger (PK) fragment_idtext DID document fragment identifier service_typetext Service type (e.g. AtprotoAppView) access_modetext all or scoped to specific XRPCscreated_attext updated_attext
Column Type Description service_entry_idinteger (FK) References service_entries.id lexicon_idtext Lexicon NSID this entry handles
Column Type Description idtext (PK) fragment_idtext DID document fragment (e.g. #atproto_space) key_typetext Always Multikey public_key_multibasetext Public key in multibase encoding private_key_enctext Encrypted private key (AES-256-GCM) created_attext
Column Type Description iduuid (PK) collectiontext Target collection (null = all) didtext Target DID (null = all) statustext pending, running, pausing, paused, cancelling, cancelled, completed, failed stagetext pending, discovering_repos, resolving_and_fetching, completed, failed, cancelled total_reposinteger Total DIDs discovered resolved_reposinteger DIDs with PDS endpoint resolved processed_reposinteger DIDs with records fetched total_recordsinteger Total records indexed errortext Error message if failed started_attimestamptz completed_attimestamptz created_attimestamptz
# Unit tests (no database needed)
cargo test --lib
# All tests including end-to-end (SQLite by default)
cargo test
# Or run against Postgres
docker compose -f docker-compose.test.yml up -d
TEST_DATABASE_URL = postgres://happyview:happyview@localhost:5433/happyview_test cargo test
docker compose -f docker-compose.test.yml down
End-to-end tests use wiremock to mock external services (PLC directory, PDSes) and a real database for full integration coverage. By default tests use SQLite; set TEST_DATABASE_URL to a Postgres connection string to test against Postgres.