Backend
server/server.js starts the lifecycle, migrations, jobs, and watcher; server/app.js composes Express, security, CORS, parsers, metrics, access, files, and routes. Controllers translate HTTP; services hold domain logic.
Actual layers
Section titled “Actual layers”config: environment and Google;routes: HTTP mapping;controllers: validation/adaptation and status;services: catalog, storage, readers, metadata, product, and operations;middleware: headers, request ID, rate limit, and sessions;migrations: immutable incremental schema.
The backend does not serve the SPA. /sw.js is only a migration worker for removing old installations from the API port.
Main services include driveService, libraryIndexService, readerService, metadataService, readingStateService, workService, profileService, jobQueueService, cacheService, integrityService, backupService, and observability.
Identity and initial setup
Section titled “Identity and initial setup”system_settingsis the source of truth for setup state and general settings;usersstores individual accounts andscrypthashes; passwords are never persisted as plaintext;profilesrepresent reading contexts, not credentials;user_profilesimplements the many-to-many association;user_sessionskeeps HttpOnly sessions and the active profile on the server;POST /api/v1/setupperforms initial creation in a transaction and returns409after completion;- administrative actions are authorized in the backend, including protection of the last active administrator.
Redis remains reserved for cache and rebuildable data. Users, sessions, associations, preferences, and settings remain in PostgreSQL.
