← Todas las plantillas

Mensajes por WebSockets, indicadores de escritura, confirmaciones de lectura, historial paginado.

Spec — Real-time chat

Status: draft · Created: 2026-11-10

1. Context and goal

Members of a conversation exchange messages over a WebSocket connection and see in real time who is typing and who has read what, while older messages load page by page.

2. Functional requirements (EARS)

  • FR-1: WHEN a member sends a message, THE SYSTEM SHALL deliver it over WebSockets to every connected member of the conversation within 500 ms at the 95th percentile.
  • FR-2: THE SYSTEM SHALL store each message before acknowledging it to the sender with its server id and timestamp.
  • FR-3: WHEN a client resends a message with a client id the server already stored, THE SYSTEM SHALL return the stored message instead of creating a second one.
  • FR-4: WHILE a member is typing, THE SYSTEM SHALL show a typing indicator to the other members and remove it at most 5 seconds after the last keystroke.
  • FR-5: WHEN a member views a message, THE SYSTEM SHALL record a read receipt and show it to the sender within 1 second.
  • FR-6: WHEN a member opens a conversation, THE SYSTEM SHALL load the latest 50 messages and load the next 50 older messages each time the member scrolls to the top.
  • FR-7: IF the WebSocket connection drops, THEN THE SYSTEM SHALL reconnect with exponential backoff starting at 1 second and capped at 30 seconds, and fetch every message missed meanwhile.
  • FR-8: IF a message exceeds 4,000 characters, THEN THE SYSTEM SHALL reject it with an error that states the limit.
  • FR-9: WHILE a member sends more than 10 messages in 10 seconds, THE SYSTEM SHALL reject further messages and tell the member when sending is possible again.
  • FR-10: WHEN a connection opens, THE SYSTEM SHALL authenticate it and accept only conversations the member belongs to, closing it with an error code otherwise.

3. Out of scope

  • Voice and video calls.
  • End-to-end encryption.
  • File attachments larger than an image preview.