frontend-engineer-hiring-test

Chat Backend WebSocket API 1.0.0 documentation

Real-time chat server with WebSocket support for bidirectional messaging and reactions.

User identification is automatic based on client IP address. All messages are broadcast to all connected clients.

Limits & Scalability

Table of Contents

Servers

development Server

Development server

Operations

SEND /ws Operation

Send a new chat message

Client sends a message that will be broadcast to all connected clients

Message Send Message send_message

Payload
Name Type Description Value Constraints Notes
(root) object - - - additional properties are allowed
type string - const ("send_message") - required
data object - - - required, additional properties are allowed
data.text string Message content - <= 500 characters required
data.author_name string Display name for the author default ("Anonymous") - -

Examples of payload (generated)

{
  "type": "send_message",
  "data": {
    "text": "string",
    "author_name": "Anonymous"
  }
}

SEND /ws Operation

Toggle reaction on a message

Add or remove a reaction. If user already reacted with this emoji, it will be removed

Message Add Reaction add_reaction

Payload
Name Type Description Value Constraints Notes
(root) object - - - additional properties are allowed
type string - const ("add_reaction") - required
data object - - - required, additional properties are allowed
data.message_id string ID of the message to react to - format (uuid) required
data.emoji string Emoji character - - required

Examples of payload (generated)

{
  "type": "add_reaction",
  "data": {
    "message_id": "d7d9d9fd-478f-40e6-b651-49b7f19878a2",
    "emoji": "string"
  }
}

RECEIVE /ws Operation

Receive new messages

Server broadcasts new messages to all connected clients. On connection, all existing messages are sent

Message Message message

Payload
Name Type Description Value Constraints Notes
(root) object - - - additional properties are allowed
type string - const ("message") - required
data object - - - required, additional properties are allowed
data.id string Unique message identifier - format (uuid) required
data.text string Message content - - required
data.author_id string User ID based on client IP - - required
data.author_name string Display name - - required
data.created_at integer Unix timestamp in seconds - format (int64) required
data.reactions object Map of emoji to array of user IDs who reacted - - required
data.reactions (additional properties) array<string> - - - -
data.reactions (single item) string - - - -

Examples of payload (generated)

{
  "type": "message",
  "data": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "text": "string",
    "author_id": "string",
    "author_name": "string",
    "created_at": 0,
    "reactions": {
      "property1": [
        "string"
      ],
      "property2": [
        "string"
      ]
    }
  }
}

RECEIVE /ws Operation

Receive reaction updates

Server broadcasts reaction changes with the full updated message

Message Reaction Updated reaction_updated

Payload
Name Type Description Value Constraints Notes
(root) object - - - additional properties are allowed
type string - const ("reaction_updated") - required
data object - - - required, additional properties are allowed
data.message_id string - - format (uuid) required
data.emoji string - - - required
data.user_id string - - - required
data.action string - allowed ("added", "removed") - required
data.message object - - - required, additional properties are allowed
data.message.id string Unique message identifier - format (uuid) required
data.message.text string Message content - - required
data.message.author_id string User ID based on client IP - - required
data.message.author_name string Display name - - required
data.message.created_at integer Unix timestamp in seconds - format (int64) required
data.message.reactions object Map of emoji to array of user IDs who reacted - - required
data.message.reactions (additional properties) array<string> - - - -
data.message.reactions (single item) string - - - -

Examples of payload (generated)

{
  "type": "reaction_updated",
  "data": {
    "message_id": "d7d9d9fd-478f-40e6-b651-49b7f19878a2",
    "emoji": "string",
    "user_id": "string",
    "action": "added",
    "message": {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "text": "string",
      "author_id": "string",
      "author_name": "string",
      "created_at": 0,
      "reactions": {
        "property1": [
          "string"
        ],
        "property2": [
          "string"
        ]
      }
    }
  }
}

RECEIVE /ws Operation

Receive error messages

Server sends error messages when rate limits are exceeded or validation fails

Message Error error

Payload
Name Type Description Value Constraints Notes
(root) object - - - additional properties are allowed
type string - const ("error") - required
data object - - - required, additional properties are allowed
data.error string Error message examples ("Rate limit exceeded. Maximum 60 messages per minute.", "Invalid message format", "message text cannot be empty", "message too long (max 500 characters)") - required

Examples of payload (generated)

{
  "type": "error",
  "data": {
    "error": "Rate limit exceeded. Maximum 60 messages per minute."
  }
}