← 返回 snapchat 的题目列表Build an AI-Assisted Chat Backend
类型:online_judge
Using an AI coding assistant such as Claude or Codex, build a Python backend-only chat system from an empty project. No UI is required. First write a brief implementation plan, then implement the system while clarifying ambiguous requirements with the interviewer.
The system must support at least:
Sending and receiving messages
A user can send a message to another user.
Online users can receive messages addressed to them.
Offline messages
Messages sent while a recipient is offline must not be lost.
When the recipient comes back online, they can retrieve messages received while offline.
Conversation history
A user can retrieve the conversation log with another user.
Messages should be returned in a reasonable chronological order.
Storage evolution
Implement the core functionality with in-memory storage first.
Then replace or abstract the storage layer for database-backed persistence with minimal impact on business-facing interfaces.
After the core implementation, explain and discuss:
Should delivery use polling, long polling, WebSockets/push, or a combination? Why?
How should unread messages be defined and maintained?
How do you handle persistence, duplicate delivery, retries, and retrieval after a user reconnects?
How would you design APIs, data models, and a storage abstraction to migrate smoothly from memory to a database?
You may define reasonable REST APIs, data models, and simplified authentication, but clearly state your assumptions and trade-offs.