How tunar-ssp/tssp works
1. Overall shape
This is a Rust monorepo for a self-hosted LAN-first storage and transfer system. The three main runtime products are the daemon (tsspd), the CLI client (tssp), and the embedded web dashboard (tssp-web) served by the daemon. The architecture is deliberately split into domain logic, application services, and adapters.
2. Core layering
The cleanest architectural boundary is:
- tssp-domain: pure types and validation rules
- tssp-ports: abstract interfaces for storage, repositories, clocks, IDs, queries, sessions, and blobs
- tssp-app: use-case services that orchestrate domain and ports
- adapters: filesystem, SQLite, and system services
- binaries/UI: tsspd, tssp, and the Svelte frontend
3. Domain model
tssp-domain contains the invariant-heavy model for files, notes, tags, sessions, hashes, text, pagination, search queries, timestamps, and terminal/LSP-related concepts. This is where data correctness is enforced before anything touches storage or HTTP. It is the foundation shared by both the daemon and the CLI.
4. Ports and abstract dependencies
tssp-ports defines the dependency boundaries the rest of the system targets: blob storage, repositories, queries, sessions, clocks, IDs, and workspace access. The application layer depends on these traits rather than on SQLite, the filesystem, or wall-clock APIs directly. This makes the storage backend swappable and keeps use cases testable.
5. Application services
tssp-app implements the business workflows: upload, delete, folders, notes, tags, pins, sessions, audit, workspace file handling, and upload cleanup behavior. These services are the main coordination layer, combining validation, repository updates, blob writes, and side effects. Important cross-cutting behavior like idempotent tag mutation, final-reference blob cleanup, and upload rollback lives here rather than in controllers.
6. Persistence and storage adapters
tssp-adapter-fs stores file blobs on disk using content-addressed BLAKE3 storage with fanout directories and deduplication. tssp-adapter-sqlite stores metadata in SQLite with migrations, WAL configuration, prepared statements, integrity checks, aggregate counts, and relation joins for tags and sessions. tssp-adapter-system supplies UTC time, UUIDv7 file IDs, and session tokens. These adapters satisfy the ports used by the app layer.
7. Daemon (tsspd) as the orchestration boundary
tsspd is the primary server process. It wires config, auth, router, state, metrics, startup, cleanup jobs, rate limiting, public API, and workspace features into a single Axum-based service. It owns the runtime boundaries: HTTP, WebSocket/LSP integration, uploads/downloads, search, notes, admin functions, and background maintenance.
8. HTTP API surface
The daemon exposes health/readiness probes plus /api/v1/* endpoints for files, tags, pins, search, notes, workspaces, sessions, and auth. The request path is: HTTP handler → application service → ports → adapters. The API layer also supports public/shared access patterns, bulk actions, file content streaming, and GCS-style static dashboard hosting.
9. Authentication and authorization
Authentication is dual-mode: open on trusted LAN by default, but password/hash-based auth is required when exposed remotely. The tsspd/src/auth subtree contains handlers, middleware, device trust, user management, local-network heuristics, and auth storage. Admin-oriented flows are separated under admin/, while public links and public sessions are handled separately from authenticated user sessions.
10. Workspace and editing subsystem
Workspace editing is its own subsystem spanning backend workspace state, filesystem interaction, terminal/LSP support, and front-end editor views. On the server side, workspace_fs, workspace_features, terminal_*, lsp, and lsp_ws support file-tree manipulation and interactive editing sessions. On the frontend, the workspace views, Monaco/Tiptap-style editors, and terminal client components consume those APIs. This is the main interactive “remote dev” boundary in the product.
11. Notes, search, tags, pins, and trash
Notes are treated as a first-class object with dedicated handlers, query/response types, validation, and tests. Tags and pins are separate metadata dimensions with their own mutation and list flows. Search is a distinct query path, not just client-side filtering. Deletion and trash-related cleanup are explicit subsystems, with garbage collection and temp/terminal/trash cleanup jobs in the daemon.
12. CLI client (tssp)
tssp is a thin command surface that mirrors the daemon’s API and local workspace operations. It includes commands like status, list, search, info, pull, tag/untag, pin/unpin, pins, remove, upload, login/logout, and workspace-related actions. The CLI is organized around command modules plus shared config/discovery/session helpers, and uses tssp-cli-core for output formatting and exit codes.
13. Web frontend
The frontend/ package is a Svelte/Vite UI that talks to the daemon through typed API service modules. It is organized around views for auth, drive/files, notes, workspace, public links, search, admin, and operations, with component libraries, stores, and utility layers beneath. The frontend is a consumer of server APIs rather than a separate backend.
14. Cross-cutting operational concerns
The repo includes explicit handling for metrics, rate limiting, integrity checks, status/health reporting, startup sequencing, and cleanup tasks. There are also extensive integration and HTTP tests in the daemon and adapter crates, which suggests the architecture is validated across the main boundaries: storage, API, auth, uploads, and workspace behavior.
15. How to draw the system
A useful architecture diagram would center on tsspd as the hub, with arrows to:
- filesystem blob storage
- SQLite metadata store
- system services for time/IDs/tokens
- CLI clients over HTTP
- browser frontend over HTTP/WebSocket
- optional public/shared access paths
Above that, show tssp-app as the use-case layer between transport and adapters, and tssp-domain/tssp-ports as the shared policy boundary underneath.
Main entry points: src/lib.rs tsspd · router.rs router · src/lib.rs tssp-ports · src/lib.rs tssp-app
Components 20
Core policy
Shared domain model, ports, and application workflows.
- tssp-domain · Invariant-heavy types for files, notes, tags, sessions, hashes, text, pagination, search, time, terminal, and LSP concepts.
crates/tssp-domain/src/lib.rs - tssp-ports · Abstract traits for blob storage, repositories, queries, sessions, clocks, IDs, records, and workspace access.
crates/tssp-ports/src/lib.rs - tssp-app · Business workflows that coordinate validation, repository updates, blob writes, and cleanup side effects.
crates/tssp-app/src/lib.rs
Adapters
Storage and system implementations behind the ports.
- fs adapter · Content-addressed filesystem blob storage with deduplication and workspace file handling.
crates/tssp-adapter-fs/src/lib.rs - sqlite adapter · SQLite persistence for metadata, queries, notes, sessions, migrations, and joins.
crates/tssp-adapter-sqlite/src/lib.rs - system adapter · Clock, UUIDv7 IDs, and session token generation.
crates/tssp-adapter-system/src/lib.rs
Daemon
Primary server process and its major subsystems.
- tsspd · Axum-based server process that wires auth, API routes, workspace features, metrics, cleanup, and runtime state.
crates/tsspd/src/lib.rs - auth · LAN-aware auth, device trust, user management, middleware, and auth storage.
crates/tsspd/src/auth/mod.rs - router · Top-level HTTP route assembly for API, health, public access, and dashboard hosting.
crates/tsspd/src/router.rs - files · File transfer, content access, deletion, renaming, moving, and trash flows.
crates/tsspd/src/file.rs - notes · Notes query, validation, response shaping, and handlers.
crates/tsspd/src/notes/mod.rs - tags · Tag mutation and listing endpoints.
crates/tsspd/src/tags.rs - workspace · Workspace filesystem, file tree, terminals, LSP, WebSocket integration, and interactive editing state.
crates/tsspd/src/workspace_features.rs - public api · Public/shared sessions, links, and unauthenticated access paths.
crates/tsspd/src/public_api.rs - ops · Startup sequencing, integrity checks, metrics, rate limiting, garbage collection, and cleanup tasks.
crates/tsspd/src/startup.rs
CLI
Command-line client and shared presentation helpers.
Frontend
Browser UI and its feature surfaces.
- frontend · Svelte/Vite browser application that consumes typed daemon APIs for drive, notes, workspace, public, search, auth, and admin flows.
frontend/src/App.svelte - api client · Frontend service modules for drive, notes, auth, workspace, sharing, search, and admin endpoints.
frontend/src/lib/api/index.ts - workspace ui · Browser workspace surface with Monaco/Tiptap editors, terminal client, file tree, and inspector views.
frontend/src/views/workspace/WorkspaceView.svelte
Connections 24
- tssp-app → tssp-domain: validates · Business workflows enforce domain invariants before persistence.
- tssp-app → tssp-ports: depends on · Use cases target abstract repository, blob, clock, ID, query, and workspace ports.
- fs adapter → tssp-ports: implements · Filesystem blob storage satisfies the blob/workspace boundary.
- sqlite adapter → tssp-ports: implements · SQLite satisfies repository, query, notes, and session ports.
- system adapter → tssp-ports: implements · System time, IDs, and tokens fulfill infrastructure ports.
- tsspd → tssp-app: orchestrates · The daemon wires HTTP handlers to application services.
- tsspd → fs adapter: uses · Runtime stores and reads blobs from the filesystem adapter.
- tsspd → sqlite adapter: uses · Runtime persists and queries metadata through SQLite.
- tsspd → system adapter: uses · Runtime draws time and identity services from the system adapter.
- tsspd → auth: contains · Authentication and authorization are handled inside the daemon.
- tsspd → router: contains · Route assembly is the daemon's HTTP boundary.
- router → files: routes to · File-related endpoints are exposed through the router.
- router → notes: routes to · Notes endpoints are exposed through the router.
- router → tags: routes to · Tag endpoints are exposed through the router.
- router → workspace: routes to · Workspace and editing endpoints are exposed through the router.
- router → public api: routes to · Public/shared access paths are exposed separately.
- ops → tsspd: supports · Background maintenance supports the daemon runtime.
- tssp → cli core: formats via · Commands rely on shared output and exit-code helpers.
- tssp → tsspd: calls · The CLI talks to the daemon over its API surface.
- frontend → api client: uses · UI screens consume typed service modules.
- frontend → workspace ui: contains · The browser app includes the remote workspace editor surface.
- api client → tsspd: calls · Frontend services interact with daemon endpoints.
- public api → frontend: serves · The daemon serves the browser dashboard and public views.
- workspace → workspace ui: supports · Workspace transport and editing features back the UI.