WebSocket Real-Time Collaboration Design Guide
Design real-time collaborative features with WebSockets, presence, conflict handling, offline recovery, scaling, observability, and security safeguards.
Prompt Template
You are a senior backend and real-time systems architect. Design a WebSocket-based real-time collaboration feature for [application/product]. System context: - Collaboration feature: [comments, cursors, document editing, whiteboard, chat, dashboard updates, multiplayer workflow] - Users and scale: [concurrent users, rooms/workspaces, peak traffic] - Stack: [frontend framework, backend language, database, cache/pub-sub, hosting] - Consistency needs: [eventual consistency, strong ordering, conflict-free editing, audit trail] - Offline/reconnect needs: [mobile clients, flaky networks, resumable sessions] - Auth model: [sessions, JWT, SSO, tenant roles] - Data sensitivity: [PII, enterprise data, healthcare, financial, public chat] - Existing APIs/events: [REST, GraphQL, queues, webhooks] - Operational constraints: [cost, latency region, compliance, small team, vendor preference] Deliver: 1. **Recommended architecture**: WebSocket gateway, app services, pub/sub, persistence, and client state 2. **Message protocol** with event names, payload examples, versioning, and validation rules 3. **Presence model** for online users, cursors, typing, room membership, and idle states 4. **Conflict strategy**: optimistic updates, locks, operational transform, CRDT, or last-write rules with rationale 5. **Reconnect and offline recovery flow** with sequence IDs, replay, and stale-session handling 6. **Authorization and tenant isolation checks** for every connection and room join 7. **Scaling plan** for multiple nodes, sticky sessions, Redis/NATS/Kafka, backpressure, and rate limits 8. **Observability plan**: metrics, logs, traces, synthetic tests, and alert thresholds 9. **Security checklist** for abuse, payload limits, origin checks, token expiry, and data leakage 10. **Implementation roadmap** from MVP to production hardening Flag risky assumptions and include test cases for race conditions and reconnect bugs.
Example Output
Real-Time Design — Collaborative Roadmap Board
Architecture
Use a WebSocket gateway for room connections, Redis pub/sub for cross-node fanout, PostgreSQL for durable board events, and a client-side optimistic store. Each board is a room scoped by tenant_id and board_id.
Event protocol
| Event | Direction | Purpose |
|---|---|---|
| board.join | client → server | Authorize and enter room |
| card.move.requested | client → server | Request optimistic move |
| card.move.applied | server → clients | Broadcast validated move |
| presence.updated | server → clients | Cursor and active user state |
Reconnect flow
Clients include last_seen_sequence on reconnect. Server replays missed events from the durable event table for 5 minutes; otherwise the client receives board.snapshot.required.
Test cases
- Two users move the same card at the same time.
- User loses network after optimistic update but before server ack.
- User is removed from tenant while socket remains connected.
- Payload exceeds limit or comes from a disallowed origin.
Tips for Best Results
- 💡Specify whether you need collaborative editing or simpler real-time status updates; the conflict model changes everything.
- 💡Ask for reconnect flows early — real-time features fail in the messy middle, not the happy path.
- 💡Include tenant isolation and room authorization in every design review.
- 💡Plan observability before launch; debugging ghost sockets in production is pure Gremlins-after-midnight energy.
Frequently Asked Questions
What is the WebSocket Real-Time Collaboration Design Guide prompt?
Design real-time collaborative features with WebSockets, presence, conflict handling, offline recovery, scaling, observability, and security safeguards. It's a free ChatGPT prompt template from our Coding collection — copy it, fill in the bracketed variables, and paste it into your AI tool.
Which AI tools work with this prompt?
It's written and tested for ChatGPT, Claude and Gemini. Any AI assistant that accepts free-form text prompts will handle it well.
How do I customize this ChatGPT prompt?
Replace the bracketed variables — such as [application/product], [sessions, JWT, SSO, tenant roles], [REST, GraphQL, queues, webhooks] — with your own details before running it. Specify whether you need collaborative editing or simpler real-time status updates; the conflict model changes everything.
Is this prompt free to use?
Yes. Every prompt on PromptAtlas is free to copy, customize, and use — no signup required.
Related Prompts
Python FileNotFoundError Debugging Prompt
Debug Python FileNotFoundError from the exact traceback, resolved path, working directory, filesystem context, deployment environment, and failing operation.
Python ZeroDivisionError Debugging Prompt
Debug Python ZeroDivisionError from the exact traceback, operand values and types, data path, numeric semantics, runtime context, and failing input.
Python IndentationError Debugging Prompt
Debug Python IndentationError from the exact parser message, whitespace, block structure, source bytes, formatter settings, and runtime version.
Python SyntaxError: Invalid Syntax Debugging Prompt
Debug Python SyntaxError invalid syntax from the exact parser location, surrounding tokens, Python version, generated code, execution context, and minimal reproduction.
Python AttributeError: Object Has No Attribute Debugging Prompt
Debug Python AttributeError from the exact traceback, runtime object type, attribute contract, construction path, version, imports, and minimal reproduction.
Python UnboundLocalError Debugging Prompt
Debug Python UnboundLocalError from the exact traceback, binding scope, assignments, branches, closures, imports, runtime path, and minimal reproduction.