apps/readest-app/docs/code-layout.md
This note summarizes the runtime boundaries inside apps/readest-app, with two goals:
apps/readest-app/src/servicessrc-tauriapps/readest-app/src-tauri is the Tauri native shell layer for all Tauri targets, not just desktop.
That is visible in apps/readest-app/src-tauri/tauri.conf.json, which contains both bundle.android and bundle.iOS configuration, plus mobile deep-link settings.
So the rough split is:
apps/readest-app/src: the Next.js/React appapps/readest-app/src-tauri: the native host layer for Tauri desktop and mobile buildsapps/readest-appapps/readest-app/src/app/api
Next.js App Router server endpoints (route.ts). These run on the server / edge runtime, not in the browser.
apps/readest-app/src/pages/api
Next.js Pages Router API endpoints. This is where the classic server handlers live, including sync, storage, send, DeepL, and user endpoints.
apps/readest-app/src/app/runtime-config.js
A server route that emits runtime JavaScript config for the client.
apps/readest-app/workers
Worker-side backend code outside the normal page UI tree. For example, workers/send-email is operational backend code.
apps/readest-app/src/components
Reusable React UI components.
apps/readest-app/src/context
React context providers and app state wiring.
apps/readest-app/src/hooks
Client-side React hooks.
apps/readest-app/src/store
Frontend state stores.
apps/readest-app/src/styles
Styling, theme assets, and UI presentation helpers.
apps/readest-app/src/data
Static or bundled app data.
apps/readest-app/src/i18n
Internationalization resources and setup.
apps/readest-app/src/workers
Browser worker code used by the frontend.
apps/readest-app/public
Static assets served to the frontend.
apps/readest-app/extension
Browser-extension-specific client code.
apps/readest-app/extensions
Platform integration extensions such as Windows thumbnail support.
apps/readest-app/src/app
Mostly frontend routes and UI, but not purely client-side. In Next App Router, page.tsx, layout.tsx, and related files can mix server rendering and client components. The exception is src/app/api, which is server-only.
apps/readest-app/src/pages
Mixed. src/pages/api is server-only; src/pages/reader/[ids].tsx is frontend page code; _document.tsx is server-side document wiring.
apps/readest-app/src/services
Shared domain/service layer. Most of this is not “backend-only”; it contains platform adapters, client logic, network clients, sync logic, and some code that is reused by server routes.
apps/readest-app/src/utils
Shared helpers used by both frontend code and server handlers.
apps/readest-app/src/libs
Shared library code. Some of it is server-oriented, some client-oriented, some neutral.
apps/readest-app/src/helpers
General helper code, usually shared.
apps/readest-app/src/types
Shared type definitions.
apps/readest-app/src/__tests__
Test code covering both client and server behavior.
apps/readest-app/e2e
End-to-end test suite.
apps/readest-app/scripts
Build, release, and maintenance scripts.
apps/readest-app/docs
App-specific documentation.
src/app and src/pages at directory levelsrc/appsrc/app/api: server-side HTTP endpointssrc/app/auth: auth pages and auth-related UI/helperssrc/app/library: library UIsrc/app/o: frontend routesrc/app/offline: frontend offline pagesrc/app/opds: OPDS browsing UIsrc/app/reader: reader UIsrc/app/runtime-config.js: server-generated runtime config endpointsrc/app/s: share landing UIsrc/app/send: send/import UIsrc/app/updater: updater UIsrc/app/user: account/subscription/settings UISo src/app is mostly application UI, with one explicitly server-only subtree: src/app/api, plus the runtime-config route.
src/pagessrc/pages/api: server-side API routessrc/pages/reader: frontend page route(s)src/pages/_app.tsx: application wrapper for Pages Routersrc/pages/_document.tsx: server-side document shellSo src/pages is mixed, not purely client-side.
src/services breakdownThe most important point is this:
src/services is mostly a shared application/service layersrc/pages/api and src/app/apisrc/servicesappService.ts
Base application service abstraction.
nativeAppService.ts
Native/Tauri-facing app service implementation.
nodeAppService.ts
Node-capable service implementation.
webAppService.ts
Web/browser-oriented service implementation.
bookService.ts
Book-level operations such as covers, metadata shaping, and book-related domain logic.
libraryService.ts
Library management logic.
settingsService.ts
Reading and persisting settings.
backupService.ts
Backup/import-export related logic.
cloudService.ts
Cloud-related app behavior.
fontService.ts
Custom font handling.
imageService.ts
Image-related helper logic.
ingestService.ts
Import / ingest pipeline for incoming content.
persistence.ts
Shared persistence utilities.
transformService.ts
Content transformation entrypoints.
commandRegistry.ts
Command registration / dispatch.
transferManager.ts and transferMessages.ts
Transfer pipeline coordination.
environment.ts and runtimeConfig.ts
Runtime environment detection and injected runtime configuration.
constants.ts and errors.ts
Shared constants and error types.
These top-level files are mostly shared client/application-layer code, with some runtime branching for web, node, and Tauri.
src/services/databasePlatform-specific database access and migrations.
webDatabaseService.ts: browser/web DB implementationnodeDatabaseService.ts: Node-side DB implementationnativeDatabaseService.ts: native/Tauri DB implementationmigrate.ts and migrations/: schema and migration logicThis is shared infrastructure code, not an HTTP backend directory.
src/services/syncSync clients and replica-sync orchestration.
KOSyncClient.tsThis is mostly client-side sync orchestration talking to backend endpoints like src/pages/api/sync.ts and src/pages/api/sync/replicas.ts.
src/services/send“Send to Readest” and content conversion logic.
sendAddress.ts, devicePrefs.ts, inboxDrainer.tsconversion/: article/page-to-EPUB conversion pipeline, sanitization, TOC building, asset bundling, and worker protocolThis is mostly application logic used by frontend flows and server endpoints together.
src/services/metadataBook metadata lookup services.
This is shared integration logic. Actual HTTP exposure happens via route handlers such as src/app/api/metadata/search.
src/services/dictionariesDictionary import, parsing, lookup, and provider registry.
This is primarily client/application functionality.
src/services/annotationAnnotation models and provider adapters.
Mostly shared reader-side logic.
src/services/navNavigation, fragments, grouping, locations, and lookup utilities for books.
Mostly client-side reader logic.
src/services/opdsOPDS feed handling and subscription state.
Mostly frontend/domain logic, sometimes paired with server proxy routes.
src/services/translatorsTranslation provider integration.
Mixed integration code. Some providers are used via server APIs to avoid exposing secrets.
src/services/ttsText-to-speech abstraction and implementations.
WebSpeechClient.ts: browser TTSNativeTTSClient.ts: native/Tauri TTSEdgeTTSClient.ts: remote/provider-backed TTSMixed runtime code, mostly used by the reader frontend.
src/services/aiAI chat/embedding/RAG related abstractions.
Mixed integration code. The services are shared, while actual HTTP endpoints live under src/app/api/ai.
src/services/hardcover and src/services/readwiseThird-party reading service integrations.
Mostly client/application integration code.
src/services/rsvpRSVP reader mode logic.
Client-side reading feature code.
src/services/transformersText/content transformation modules.
Shared pure logic, usually frontend-facing but not tied to a single runtime.
If you want a fast rule of thumb for this repo, use this:
src/pages/api, src/app/api, workerssrc/app except api, plus src/components, src/hooks, src/storesrc/services, src/utils, src/libs, src/typessrc-tauriThat model matches the codebase much better than “everything under src is client code.”