Cross-Device Reading Sync System: From Library Ingestion to Secure Remote Access

    This article presents a self-hosted architecture for keeping a book library and reading state consistent across devices. It separates book files, library indexing, and user reading state into distinct data layers, then covers stable book identity, controlled ingestion, structured reading-position sync, note handling, secure remote access, backup, and operational validation. The goal is to help readers design a system that is reliable over time rather than occasionally usable.

    1. Start by Separating the Problem: Syncing Books Is Not the Same as Syncing Reading Progress

    Reading a chapter on a phone and then having to find the same location again on a computer is one problem. Organizing books on a computer and failing to get them onto a mobile device in time is another. Downloading the same book again and losing the connection to existing notes is yet another. These issues look similar, but they involve three independent data layers.

    The first layer is the book file itself, including the body text, cover, and metadata carried inside the file. This layer answers the question: can a device obtain this book?

    The second layer is the library index, including book identifiers, titles, authors, file locations, and ingestion status. This layer answers the question: how does the system manage and identify this book?

    The third layer is user reading state, including reading position, bookmarks, annotations, and modification records for that data. This layer answers the question: after switching devices, can the user continue reading?

    Copying book files through file synchronization usually covers only the first layer. Even if the reader application’s data directory is copied as well, conflicts can still occur because of differences in client versions, database schemas, cache formats, and file-locking mechanisms. A safer approach is therefore to use a centralized library to manage content and an explicit synchronization protocol to exchange reading state, so that the two paths have clear responsibilities.

    It is especially important to note that reading-position sync, bookmark sync, and annotation sync are not necessarily supported together. When choosing clients and server-side services, verify each capability individually. Do not interpret “supports sync” as meaning that all reading data can be exchanged.

    2. Overall Architecture: Two Data Paths and One Unified Entry Point

    A self-hosted solution suitable for personal use can be divided into the following modules:

    • Reading client: opens books, records position, and submits state when conditions allow.
    • Book synchronization component: transfers files from a designated download directory to a home network storage device.
    • Library service: scans the book directory, builds an index, and provides access under permission control.
    • State synchronization service: receives and returns reading state, and can be deployed on the same device as the library service.
    • Remote access layer: provides an external access entry point through an encrypted tunnel, reverse proxy, and certificate management.

    The two main paths can be represented as follows:

    1. Book path:
    2. Local download directory → File sync → Staging directory → Validation and scanning → Central library
    3. State path:
    4. Reading client → Authentication → State sync service → Persistent storage
    5. Another client ← Pull and check state ← State sync service

    If the home network cannot directly accept external connections, a remote entry point can be added:

    1. External client
    2. ↓ Encrypted access
    3. Public entry point and reverse proxy
    4. ↓ Protected tunnel
    5. Library and state services in the home network

    This module division is a general architecture. It does not mean that any client can directly connect to any service. Before implementation, confirm whether the content acquisition method, authentication method, and state protocol are compatible, and then decide whether an adaptation layer is needed.

    3. The Key to a Centralized Library: Stable Identity and Controlled Ingestion

    3.1 Establish Stable Book Identifiers

    One of the most easily overlooked problems in cross-device sync is how different devices confirm that they have opened the same book.

    File names are not suitable as direct unique identifiers. They may be renamed by the user or changed because of different download sources. Titles and authors are also insufficient to uniquely identify content, because different editions, revisions, and layout files may share the same metadata.

    In a self-hosted system, a file content digest can be used to identify identical files, while separate book records can manage version relationships. Note that a file digest only proves whether file contents are identical; it cannot automatically determine whether two different files belong to the same work.

    If a client uses its own document identifier, the server must understand or map that identifier. Generating a new number only on the library side does not guarantee that the client will use it during state synchronization.

    For versions with different content, do not directly reuse an existing reading position. Once chapter structure or body offsets change, the old position may point to the wrong passage.

    3.2 Separate the Staging Directory from the Production Library

    Treating a download directory directly as the production library makes it easy to scan files whose transfer has not completed. A more reliable approach is to set up a staging area:

    1. Completed downloads enter the synchronization scope.
    2. The synchronization component transfers files to the staging directory.
    3. The system confirms that file transfer is complete and checks format and readability.
    4. Qualified files enter the production library.
    5. The scanner updates the index and records success or failure results.

    Prefer explicit completion signals provided by the synchronization component. If no such signal exists, temporary-file conventions, file-size stability checks, and integrity checks can reduce the probability of misjudgment, but “size unchanged for a short period” should not be treated as absolute proof of completion.

    3.3 Make the Scanning Process Repeatable

    Library scanning should be idempotent: when the same file is discovered repeatedly, it should not create multiple duplicate records.

    Library records can store the content digest, file location, scan status, and failure reason. For abnormal files, record the problem and continue processing other files instead of interrupting the entire scan task.

    Deletion policy should also be explicit. Deleting a file from the download directory does not necessarily mean that it should also be deleted from the production library. If the central library is expected to provide long-term preservation, use a one-way import strategy to avoid accidental deletion of archived content when cleaning up the source side.

    4. Cross-Device Progress Sync: Position Representation Matters More Than Percentage

    4.1 Percentages Are Good for Display, Not as the Sole Location Basis

    Showing reading progress as “half read” is intuitive, but it is not enough to accurately restore a position. Changes in font size, window width, line spacing, and pagination algorithms can cause the same content to correspond to different page numbers.

    A better approach is to save a structured position within the limits of the client and document format, such as chapter location information and position within the chapter. The percentage can then serve as an auxiliary display value.

    Different formats have different locating mechanisms, and an unverified coordinate system should not be forced onto all of them. If both sides can only exchange coarse-grained progress, the system should clearly tell the user that restoration accuracy is limited.

    4.2 Define Sync Timing and Failure Behavior

    Synchronization should not depend only on exiting the reader, because the application may be terminated by the system or the device may suddenly go offline.

    More practical triggers include:

    • When opening a book, check whether a newer remote state exists.
    • During reading, merge and submit changes at reasonable intervals.
    • When switching books or entering the background, attempt to submit the latest position.
    • After network recovery, process locally pending synchronization records.

    These behaviors depend on whether the client allows configuration or extension. If building a custom client, avoid sending a request immediately on every page turn. Instead, merge changes over a short period to reduce network usage while keeping a local persistent record.

    Synchronization failure must not block normal reading. The client should save local state first, wait for retry, and distinguish for the user between “saved locally” and “synced to the server.”

    4.3 Do Not Treat “Further Ahead” as Automatically Newer

    A user may return to earlier chapters for review or restart reading. Simply taking the maximum progress will overwrite legitimate rollback actions.

    Similarly, relying entirely on device time is risky because clocks on different devices may not be consistent. In a synchronization service that you control, server-side version numbers or revision records can be used to identify concurrent modifications. The client submits the version on which its change is based, and the server decides how to handle the conflict after detecting it.

    For a personal reading system, a practical strategy is to retain recent state history and show both positions for the user to choose from when a conflict occurs. If an existing protocol is used, follow its established conflict rules and understand the boundaries through actual testing. Do not assume that the server already provides complex merge capabilities.

    5. Note Sync Requires a Separate Design

    Reading position can usually be treated as a single updatable record, while notes are multiple independent objects. Their data models are different.

    If annotations need to be synchronized, at minimum consider note identifiers, associated books, body anchors, note content, revision status, and deletion status. Deletion operations in particular cannot be represented only by “this note is absent locally”; otherwise, another device may re-upload an old record and cause the note to reappear.

    In a system you implement yourself, deletion markers can be retained with reasonable cleanup rules. If an existing client supports only reading-position sync, notes should be preserved through its supported export, backup, or another independent mechanism. Do not claim that complete cross-device note sync has been implemented unless it has.

    In addition, migrating annotations between different book versions usually requires extra matching logic. Text references can serve as auxiliary evidence, but repeated passages, content revisions, and character-processing differences can all cause mismatches. Manual confirmation should be allowed.

    6. External Access: Connectivity and Security Must Be Designed Together

    Home network storage devices are usually located behind a router. Actively establishing a tunnel to a public server can provide a remote entry point, but the tunnel itself only solves the connection path; it does not automatically provide complete access control.

    A public entry point can use a reverse proxy to forward business requests and terminate external encrypted connections. Automatic certificate renewal reduces maintenance burden, but renewal results still need monitoring. Validation methods, entry-point reachability, and related configuration changes can all cause renewal failures.

    Security design should cover at least the following:

    • Expose only the entry points required for reading services; do not directly expose storage management interfaces and database ports.
    • Implement authentication for book downloads and state reads/writes; do not protect only the home page.
    • Partition data permissions for different users to prevent reading another user’s progress or notes.
    • Protect the link between the public entry point and home services; do not mistake external encryption for end-to-end encryption.
    • Manage tunnel credentials and business credentials separately, limit permissions, and rotate them regularly.
    • Apply reasonable limits to failed logins and abnormal requests so that the service is not continuously drained of resources.

    If only your own devices need access, a private encrypted network can also be prioritized to reduce the public exposure surface. Regardless of the method chosen, test separately on the home network and the external network to confirm that clients correctly handle addresses, authentication, and certificates.

    7. Backup and Operations: Sync Is Not a Substitute for Recovery Capability

    File synchronization can propagate accidental deletion, incorrect overwrites, and corrupted content to other devices. A synchronized copy is therefore not equivalent to a backup.

    Data that should be backed up includes at least:

    • Original book files.
    • Library index and version mapping information.
    • Reading state, bookmarks, and notes.
    • Service configuration and necessary recovery material.

    Credentials should be stored in a protected manner and should not be mixed with public configuration. For databases, use a method that can produce a consistent backup. Do not assume that directly copying data files from a running system will always be recoverable.

    After backups are completed, perform a restore drill in an isolated environment. Check whether books can be accessed again, whether state can be associated correctly, and whether permissions are correct. Only a verified backup has real recovery value.

    Operational metrics do not need to be complex, but they should answer several questions: Have files finished transferring? Did scanning succeed? Was state submitted? Is the remote entry point reachable? Is the certificate valid? Is storage space sufficient? Logs should record necessary failure information while avoiding complete credentials and unnecessary note body text.

    8. Implementation Order and Acceptance Checklist

    It is advisable to validate a minimal closed loop first and then expand automation.

    Step 1: Within the home network, verify that two devices can identify the same book and accurately restore reading position.

    Step 2: Connect the file synchronization and scanning workflow, and check handling of duplicate imports, incomplete files, and format anomalies.

    Step 3: Test offline reading and concurrent updates, and confirm that conflicts do not silently overwrite important state.

    Step 4: Enable remote access, and verify authentication, link protection, and entry-point permissions separately.

    Step 5: Configure backups and alerts, and complete one restore drill.

    Acceptance testing should focus on these scenarios: a phone submits a position and a computer continues reading; a computer makes offline changes and then reconnects; the same book is renamed; a book is replaced with a different version; the download directory is cleaned while the production library is retained; and the client can still read when the service is briefly unavailable.

    The core value of this approach is not simply connecting several components. It is establishing clear data boundaries: book files handle content distribution, the library index handles identity and organization, the state protocol handles cross-device continuity, the secure entry point handles controlled access, and the backup mechanism handles failure recovery. Only when these boundaries are verified one by one does reading continuity between phone and computer move from occasionally usable to reliably maintained over time.