Skip to content
Infrastructure

Infrastructure

External systems behind small contracts. Decision 34 is recorded in ADR 0001. Folder rules are guideline §1. The checked-rule table is architecture.md.

Owns

One package per folder. SDK_ADAPTERS in scripts/lint/.dependency-cruiser.cjs names one adapter path per vendor SDK.

The tree has audit, email, firehose, image, net-guard, pds, postgres, seal, session and storage. These pages follow the tree.

PackagePathPage
auditinfrastructure/auditaudit
emailinfrastructure/email
firehoseinfrastructure/firehose
imageinfrastructure/image
net-guardinfrastructure/net-guardnet-guard
pdsinfrastructure/pdspds
postgresinfrastructure/postgrespostgres
sealinfrastructure/sealseal
sessioninfrastructure/sessionsession
storageinfrastructure/storagestorage

May import

Transcribed from scripts/lint/.dependency-cruiser.cjs (MATRIX and the forbidden rules named here). dependency-cruiser 18.7.0 is pinned in package.json. An edge no row lists fails as not-in-allowed.

FromMay reach
infrastructure/<name>/, except net-guardIts own folder, infrastructure/net-guard/, infrastructure/seal/, domains/, shared/, Node built-ins (dependencyTypes: core), and npm types npm, npm-dev, npm-optional, npm-peer, npm-bundled.
infrastructure/net-guard/Its own folder, the npm package undici, and Node built-ins.

The infrastructure row’s $1 is the package folder. A package may reach net-guard and seal. It may not reach another infrastructure package: session does not import postgres, and pds does not import session. Callers pass a query function in.

Rules that refuse an edge a row would otherwise allow:

RuleEffect
infra-shared-via-indexAnother module under infrastructure/<name>/ or shared/<name>/ is reached through its index.ts. A *.fake.ts and a .css file are the exceptions this rule allows. domains/ is not this rule.
infrastructure-not-entryNo import from interfaces/ or apps/.
net-guard-leafA non-test file under infrastructure/net-guard/ reaches only its own folder, undici and Node built-ins. A *.test.ts there may also import fast-check and vitest.
vendor-sdk-one-adapterpg only in infrastructure/postgres/. undici only in infrastructure/net-guard/. @atproto/oauth-client-node and @atproto/api only in infrastructure/pds/. age-encryption only in infrastructure/seal/. @atproto/lex* only in shared/lexicons/. The list also names the path infrastructure/storage/ for @aws-sdk/client-s3 and the path apps/chat/matrix/ for matrix-js-sdk.
no-product-imports-toolingProduct code does not import scripts/ or tests/.
fake-only-in-composition-rootA *.fake.ts is imported only by tests and by interfaces/<name>/compose.ts, and only with a dynamic import() after the UNSET_ENV check.

@unset/infrastructure-seal does not depend on age-encryption. infrastructure/seal/seal.ts calls node:crypto. The cruiser row is the import rule; the package is absent.

@unset/infrastructure-storage depends on aws4fetch 1.0.20. It does not depend on @aws-sdk/client-s3. The cruiser row is the import rule; that package is absent.

Entry points

No main.ts under infrastructure/. Each package publishes index.ts (package.json export .). Rule DC-2 (infra-shared-via-index) is that file.

PackagePublic moduleProcess
auditinfrastructure/audit/index.tsNone. interfaces/web/src/lib/server/compose.ts does not construct it. interfaces/web/src/lib/server/age-gate-audit.ts calls appendAudit.
emailinfrastructure/email/index.tsNone. interfaces/web/src/lib/server/compose.ts calls createSmtpMailer.
firehoseinfrastructure/firehose/index.tsNone. interfaces/indexer/compose.ts reads the PDS event stream through it.
imageinfrastructure/image/index.tsNone. interfaces/review/compose.ts calls createImagePool. interfaces/web/src/lib/server/compose.ts calls createRemoteImageProcessor.
net-guardinfrastructure/net-guard/index.tsNone. interfaces/web/src/lib/server/compose.ts calls createNetGuard.
pdsinfrastructure/pds/index.tsNone. interfaces/web/src/lib/server/compose.ts calls createIdentityNetwork, createOAuthClient and createPdsCall.
postgresinfrastructure/postgres/index.tsunset-migrate and unset-rewrap. See postgres.
sealinfrastructure/seal/index.tsNone. interfaces/web/src/lib/server/compose.ts calls createSealer.
sessioninfrastructure/session/index.tsNone. interfaces/web/src/lib/server/compose.ts calls createSessionStore.
storageinfrastructure/storage/index.tsNone. interfaces/web/src/lib/server/compose.ts calls createObjectStore for the drafts store, and interfaces/media/compose.ts calls it for reads.

Data

Schemas, roles, grants and migrations live under postgres. net-guard, seal and storage run no SQL. The other packages name the tables their statements touch on their own pages. idx has schema USAGE in grant-matrix.json and no CREATE TABLE in infrastructure/postgres/migrations/.