Build team chat organised by topic, not by time. Stack: your choice with websockets, Postgres, Docker Compose, a domain with TLS. The structural decision: a message belongs to a **topic** inside a channel, and a topic is created by whoever starts the conversation, with a name. Reading a channel means reading a list of topics with unread counts, not scrolling a merged river of messages. This is the one design choice that makes chat searchable a year later, and it should be enforced — there is no way to post to a channel without naming a topic, though picking an existing one is one keystroke. Messages: Markdown, edit and delete with an edit marker, reactions, @mentions writing to a notifications table, and file attachments to local disk with a content-hash filename and a type allowlist. Search has to be genuinely good or the design is pointless: full-text over message bodies with Postgres, filterable by channel, topic, sender and date range, with the matching term highlighted and three messages of surrounding context. Search must include topic names, since a well-named topic is often the whole answer. Retention: a per-channel policy in days, defaulting to unlimited but easy to set, deleting messages and their attachments from disk. Show the policy in the channel header so nobody is surprised. A channel marked as a decision log can be exempted explicitly. Read state per user per topic, so an unread badge means something. Mark-all-read at the channel level. Export: a whole channel as JSON, and as readable Markdown with one file per topic — that second format is what makes an archive useful after you stop running the server. Write tests for read-state correctness with concurrent posts, for retention deleting attachments from disk and not just rows, and for search returning correct context at message boundaries. Do not build voice or video calling, screen sharing, or a mobile app.