NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Middle1 view

Design a service for sharing and collaborating on maps, with versioning, permissions, and offline edits.

Practice

Asked at

AI answer

Architecture and data model

Clients interact through an API and a collaborative editing service. Store Map, Layer, Feature, Membership, Permission, and immutable Operation/Version records. Store geospatial data and map metadata in a spatial database; store large attachments and version snapshots in object storage. A CDN speeds up delivery of tiles and immutable assets.

Collaborative editing

Each edit includes an operation ID, user, base version, timestamp, and modified object. The server checks permissions, saves the operation, and broadcasts it to subscribers over WebSocket; periodic snapshots keep the log from growing too long. CRDTs/operational transformations can be used for text fields or structured layers when concurrent edits are needed. For geometry, it is safer to detect competing changes to the same object and offer a comparison or explicit conflict resolution: automatic merging can alter the meaning of the map.

Versions and offline mode

The client stores a local copy of the map and a queue of operations with unique IDs. When connectivity is restored, it sends the operations along with the base version; the server checks permissions and conflicts, deduplicates retries, and returns either accepted changes or a conflict to resolve. Versions must be reproducible: record the author, timestamp, parent version, and operations; support viewing and rollback by creating a new version rather than deleting history.

Availability and security

Set permissions at the map level and, if needed, at the layer level: owner, editor, viewer; the server checks permissions for every operation. Use TLS, auditing, backups, and access controls for shared links. Isolate maps by owner/organization. Metrics: edit propagation latency, offline sync queue size, conflicts, save errors, and map loading time.