Online Block Diagram Maker App

Difficulty: MEDIUMCategory: HLDFrequency: 1Asked On 2024-09-13

Problem Statement

Design a web-based application that allows users to create, edit, and share block diagrams online. The system should support real-time collaboration, versioning, and export features, while being scalable, performant, and responsive.


Functional Requirements (FR)


User Management

•Users can register/login using email, social login, or SSO.
•Manage user profiles and preferences.
•Support sharing permissions (view/edit) for diagrams.

Diagram Creation & Editing

•Add, delete, and move blocks/shapes.
•Connect blocks using arrows or connectors.
•Change colors, sizes, labels, and styles.
•Support undo/redo operations.

Collaboration

•Multiple users can edit the same diagram in real-time.
•Show cursors and edits of collaborators.
•Optional: Commenting and annotations.

Persistence & Versioning

•Save diagrams in the user’s account.
•Support version history and rollback.

Export & Import

•Export diagrams as PDF, PNG, SVG, or JSON.
•Import diagrams from supported formats.

Templates & Libraries

•Provide predefined templates for flowcharts, UML diagrams, org charts, etc.
•Maintain a library of shapes and connectors.


Non-Functional Requirements (NFR)


•Scalability: Support many concurrent users and collaborative sessions.
•Low Latency: Edits and updates should reflect in real-time.
•Availability: App should be highly available for global users.
•Persistence: Reliable storage of user diagrams and version history.
•Security & Privacy: Ensure diagrams are accessible only to authorized users.


Suggested Components / System Architecture


Client Application

•Web front-end (React/Canvas/SVG) for diagram editing.
•Handles rendering, drag-and-drop, and real-time updates.

API Gateway

•Entry point for client requests; handles authentication and routing.

Diagram Service

•Stores diagram structure, metadata, and versions.
•Handles CRUD operations for diagrams.

Collaboration / Real-Time Service

•Supports WebSockets or WebRTC for real-time editing.
•Manages sessions, cursors, and operational transforms (OT) or CRDTs to handle concurrent edits.

User Service

•Manages user accounts, profiles, and access control.

Storage Layer

•Relational DB: Store user profiles, diagram metadata, and permissions.
•NoSQL / Object Storage: Store diagram content, versions, and exported files.
•Cache (Redis): Optional, for session management and quick access to frequently accessed diagrams.
1.Notification Service (Optional)
•Notify collaborators about edits, comments, or shares.


Data Flow (High-Level)


1.User logs in → User Service authenticates.
2.User opens or creates a diagram → Diagram Service fetches data.
3.User makes edits → changes sent to Collaboration Service → updates Diagram Service and broadcasts to other users in real-time.
4.User saves diagram → persisted in storage → versioning maintained.
5.Export request → Diagram Service generates export file (PDF/PNG/SVG).


Key Design Considerations


•Real-Time Collaboration: Use Operational Transforms (OT) or CRDTs to handle concurrent edits.
•Scalability: Horizontal scaling for collaboration sessions and storage.
•Persistence & Versioning: Efficient storage of diagram versions.
•Undo/Redo: Maintain operation history per user or per session.
•Extensibility: Support new shapes, templates, or integrations with other tools (e.g., Google Drive).


Solution

Comments