← Selected work
PWA · Security2026

Offline-First Notes

An installable notes app where every record is encrypted before it touches disk and every action survives losing the network.

Local · encryptedRemotePUTDELPUTADDSWreplayv3 conflict → resolve
System schematic Offline-First Notes

My contribution

Solo build: storage layer, encryption, service worker, sync engine, conflict resolver and UI.

The problem

Most web apps treat offline as an error state: the request fails, the spinner hangs, the work is lost. A note-taking tool is exactly the case where that is unacceptable — you write when you have a moment, not when you have bandwidth.

The approach

The app never writes to a server directly. Every create, update and delete is appended to an encrypted action queue in IndexedDB and applied to local state immediately. A service worker precaches the shell so the app opens instantly with no network at all. When connectivity returns — or when the Background Sync API fires the `sync-actions` tag — the queue is replayed in order, and version conflicts are surfaced to the user rather than silently resolved.

Decisions

Encrypt before persisting, not after
A passphrase derives a key via PBKDF2 against a stored salt; records are encrypted with AES-GCM before they are written. Only ciphertext blobs reach IndexedDB and decryption happens in memory, so a copied profile directory yields nothing readable.
An action queue instead of last-write-wins
Storing intent rather than final state means the replay is deterministic and auditable. It also makes undo/redo fall out of the same records, and gives the sync timeline something real to display.
Make the sync visible
Offline apps fail quietly. A sync timeline, a queue panel and a data-weight indicator turn invisible background behaviour into something the user can inspect and trust.
Ship a simulator with the app
A developer panel forces offline mode and injects latency, and the service worker honours those overrides. Offline behaviour that cannot be reproduced on demand does not get tested.