Build a self-hosted team chat where permanent retention and fast search are the design centre. Chat surface: public and private channels, threads on any message, direct and group messages, reactions, mentions, file attachments, and message editing with an edit history that is visible rather than silent. Live delivery over WebSocket, but every message committed to PostgreSQL in the same transaction that broadcasts it — a message that reached a screen and not the database is the failure mode that destroys trust in a chat tool. Search, which is the point of this build: - Full-text over message bodies, thread replies, file names and the extracted text of attached PDFs and plain-text files. - Filters that compose: from a person, in a channel, before or after a date, has an attachment, in a thread. - Results with surrounding context — the two messages either side — because a chat result without context is unreadable. - Jump-to-message from a result, loading the conversation around that point rather than only the message. Keeping it fast as it grows: index messages with PostgreSQL full-text search, maintaining a generated tsvector column with a GIN index rather than computing it at query time. Partition the message table by month once it is large. Document, and actually test, the query plan at a million messages — a chat search that takes four seconds is a search nobody uses, and the whole premise of this build is that people look things up. Retention: permanent by default. If a retention policy is configured, it must be per-channel, visible to members of that channel, and announced in the channel when set. A team chat that quietly deletes history is worse than one that never had it. Export, treated as a guarantee rather than a feature: a full export of every channel, thread and attachment as JSON plus files, runnable from the command line without the application running, and documented well enough that the archive is readable if this software disappears. Also per-user export for anyone who asks. Administration: invitations by email, deactivating a user without deleting their messages, channel archiving that preserves searchability, and an audit log of administrative actions. Out of scope: desktop and mobile applications, push notifications, voice or video calls, guest accounts, and any hosted multi-tenant deployment.