Skip to content

Architecture Overview

This directory contains the codified architectural decisions for Substratum v1.0. These documents outline the core design philosophies, system boundaries, and implementation strategies that guide the development of the SaaS dashboard, the Identity-Gated Gateway, and the local Sidecar.

Core Design Principles

Substratum is designed for long-term sovereignty, testability, and eventual decomposition. We prioritize modularity over rapid MVP monolithic coupling.

Ubiquitous language: Canonical product and engineering terms are defined in the Glossary. ADRs and new docs should link there instead of redefining terms.

Architecture Decision Records (ADRs)

We track architectural decisions and proposals using ADRs. Please read the following documents in order to understand the system design:

ADRTitleStatusDescription
01The Modular MonolithAcceptedWhy we are building a single logical boundary partitioned into publishable modules.
02Ports and AdaptersAcceptedHow we isolate the core domain logic from the network, storage, and user interfaces.
03Network BehaviorAcceptedWhy we are not forking IPFS, and how we swap modules to create a private swarm.
04Sidecar DesignAcceptedThe architecture of the local agent, starting as a headless daemon.
05Phase 1 ScopeAcceptedThe minimal set of adapters and domain logic required for the initial implementation.
06Documentation HostingAcceptedHow we use Tangled's Spindle CI to build and deploy VitePress to a tngl.sh domain.
07Core Language SelectionProposedSelecting the primary language for the core domain, Sidecar, and Gateway.
08Hosting and Frontend StackAcceptedDefining the infrastructure (DigitalOcean) and UI framework (Mithril.js).
09Database and ORM (SeaORM)AcceptedUsing DO Managed PostgreSQL and SeaORM (Rust) for Native RLS.
10Repository StructureAcceptedPolyglot Monorepo (Nx + Cargo) and the 4-pillar Gateway architecture.
11Cross-Boundary StrategiesAcceptedWASM for client-side crypto, OpenAPI (utoipa), and the Actor Pattern.
12AT Protocol IntegrationAcceptedLeveraging the atproto-* workspace for identity, OAuth, and DPoP.
13Twelve-Factor AppAcceptedEnsuring cloud-native scalability, config management, and disposability.
14Frontend InternationalizationAcceptedLingui, hand-maintained JSON catalogs, explicit IDs, and ui-kit boundaries for the Mithril dashboard.
15Web File ExplorerAcceptedMiller columns, TanStack virtual-core windowing, selection and prefetch, Passport-driven affordances in apps/file-explorer.
16Drive-Centric Domain VocabularyAcceptedConway-aligned naming: Drive (not Vault) for the user-scoped root in APIs, ingress DTOs, and UI; folders and files under it.
17Multi-Tenant PSK InjectionAcceptedUsing Secure WebSockets (WSS) and HTTP Upgrades to dynamically inject user-specific PSKs into a single libp2p Swarm.
18Gateway Connectivity Presence and Push UpdatesProposedDefine a hybrid browser connectivity model combining online/offline signals, adaptive health probing, and server push events for responsive gateway status UX.
19Rust Build OptimizationAcceptedStrategies for fast Cargo compilation (lld, sccache) and manual Nx project.json graph integration.
20File Explorer Service LayerAcceptedService interfaces, singleton composition, RxJS-backed state, resolver adapters, and OpenAPI-aligned API URLs in apps/file-explorer.
21Passport Lexicons and Ref-Only AT Protocol RecordsSuperseded (in part)cloud.substratum.* lexicons and ref-only records; detached provenanceSignature superseded by ADR 27.
22Drive Lexicon and PersistenceAcceptedCanonical drive metadata schema, dual persistence in swarm and DB, and native RLS-backed listing.
23Personal Unified Installer and Cross-Platform KitAcceptedSingle onboarding story and config contract across macOS, Windows, Android, and iOS; Tauri orchestrator on desktop; storage policy from installer, enforcement in node runtime.
24Installer post-MVP — mesh modes, explicit roles, and cloud relayProposedStep 0 hosting topology (self-hosted vs cloud); cross-platform install_self_hosted; Postgres port 35432; mesh_mode / installer profile separate from triangle JSON; explicit device selection; discovery plug-ins.
25Directory Lexicons and First-Class PassportsProposedElevate directories to first-class cryptographic objects with their own AT Protocol lexicons and verifiable passport receipts, removing frontend shims.
26TUS Resumable Drive UploadsProposedtus.io transport via fileloft, drive-scoped routes, finalize into swarm/DB, batch SSE progress, file-explorer integration; deprecate multipart upload after rollout.
27Zero Trust PDS-Based ProvenanceAcceptedEnforcing Zero Trust by using the user's PDS to sign cloud.substratum.passport.receipt records via createRecord, replacing Gateway Attestation.
28Receipt Sync Queue and Grantee Access RemovalAcceptedTransactional outbox to converge Postgres catalog ACL on owner-repo receipts; grantee accessRemovalRequest on grantee PDS; shared pipeline for gateway and home-base.
29Private PDS Namespace and Local CAR Emergency ExportProposedPrivate cloud.substratum.* collections; local .car vault; break-glass mesh deferred.
30Catalog–PDS Dual-WriteProposedFilesystem lexicons (filesystem.drive / driveEntry / directory) catalog↔PDS via CatalogSyncWorker; passport private namespace is a separate ADR 29 refactor on receipt sync.
31Personal kit updates and in-app update checksProposedKit Release Manifest, Update Coordinator, built-in checks in installer/Substratum/explorer; phased path from installer-only refresh to signed remote apply.
32Account entitlements and hosting policyProposedThree policy layers (hosting, account plan, node disk); deployment_mode, UploadPolicy, GET /me/limits; SaaS-only ingress enforcement; /account UI.
33Frontend modular monolith and package boundariesAcceptedOne web SPA and shared libraries—not runtime micro-frontends; in-process shell, feature folders, deployment-aware nav.

| 34 | Idempotent Directory Creation and Concurrency | Accepted | Preventing duplicate entries and race conditions during high-concurrency nested folder uploads. | | 35 | Drive Node Delete (Four-Layer Removal) | Proposed | Four delete layers (catalog, PDS tombstones, quota/local GC, triangle unpin + DLQ) plus Account sync-failures dashboard (/account/sync-failures, GET /api/v1/me/sync-failures) for DELETE /api/v1/drives/{id}/nodes. | | 36 | Marketing Landing Page | Accepted | apps/landing on DO Droplet + Caddy; Spindle rsync deploy; build-time prerender per locale; families-first Midnight Gallery SPA; v1 Pricing section (Coming soon badges). | | 37 | PDS Entitlement Proxy and Payment-Provider-Agnostic Billing | Proposed | Entitlement service + PDS repo authz proxy for cloud.substratum.*; billing adapters (Stripe one of many); deleteRecord allowed on lapse for migration; gateway/home sync uses same capabilities. | | 38 | Support and Entitlement Admin Tooling | Proposed | v1 operator admin API + manual billing adapter + audit log; Discourse hooks; PDS company SSO + localized operator UI (apps/admin at admin.*); closes ADR 32 CC10. | | 39 | AT Protocol OIDC Bridge for Discourse Support SSO | Proposed | id.support.* OIDC provider → AT Proto OAuth on pds.*; entitlement-gated Discourse login at support.*; reuses crates/auth. | | 40 | Orval Fetch Mutators for Cross-App HTTP Clients | Accepted | createApiFetch() per OpenAPI surface; Orval override.mutator for cookie auth and global 401 handling; ops live, gateway migration planned. | | 41 | Operated PDS Hosting Topology and AT Protocol Plane Separation | Proposed | Garage v1 single Tranquil PDS; Postgres repo store + Spaces blobs; stateless droplet; gateway as product read plane (AppView analog); defer Entryway/sharding. | | 42 | Branded PDS Portal (apps/pds-portal) | Accepted | ui-kit SPA on pds.* for sign-in and OAuth consent; keep Tranquil upstream; signup stays gateway-mediated on app.*; phased account-security and Tranquil fallback. | | 43 | Centralized Log Observability | Proposed | Vector on edge droplets → Loki + Grafana on infra/observability; Phase 1 local disk; optional Phase 2 Spaces chunk storage. | | 44 | Explorer Workspace Decomposition | Proposed | Thin ExplorerWorkspace orchestrator; extend explorerTreeService.refreshPath; coordinator modules in lib/ / components/explorer-workspace/; URL stays source of truth for path and panels. |

Implementation Roadmap