Skip to content
Senior0 views

Design a service for sharing and collaborating on architectural diagrams, with versioning and comments.

Practice

AI answer

Architecture and Data

The web client displays diagrams, an editor, version history, and discussions. The API manages projects, access, and comments; the diagram storage service handles saving and versioning; background tasks generate previews and validate imported files. Use a relational database for users, projects, permissions, and comments, and object storage for large files and diagram snapshots.

Store diagrams in a stable format (for example, JSON with a format version). Each save creates an immutable version with its author, timestamp, and a link to the previous version. To restore a version, simply create a new version based on the selected one without rewriting history. Comments are linked to a version and, if the format allows, to a diagram element; when a diagram changes, the interface should indicate if the link is outdated.

Collaboration

Optimistic locking is sufficient for the first version: the client sends the base version, and the server rejects conflicting saves and offers to compare the changes. If low-latency simultaneous editing is required, add WebSocket and an operation reconciliation algorithm (CRDT or OT), first defining the semantics of diagram changes. Saves and comments should be idempotent.

Access and Operations

  • Roles at the organization, project, and invitation-link levels; server-side permission checks and the ability to revoke access.
  • Audit changes and downloads; restrict file sizes and types; scan imports for viruses.
  • Version the API and diagram format; back up the database and files; monitor save errors and synchronization latency.
  • For scaling, use read caching, a CDN for previews, and horizontal API scaling; version consistency remains in the transactional database.

Clarify the maximum diagram size, the need for offline mode, import/export requirements, and real-time collaborative editing requirements.