LetsChat
A full-stack real-time messaging application built on an async FastAPI backend and a React 19 frontend. Messages, presence, and typing all flow over a single per-user WebSocket connection authenticated with a first-message token handshake so credentials never land in server access logs. The frontend pairs TanStack Query optimistic updates with a client-generated nonce so a sent message renders instantly and reconciles idempotently when the server echo arrives - no duplicates, no flicker, and a clear failed state on error. A WebSocket client singleton living outside React survives StrictMode remounts and reconnects with exponential backoff and heartbeat pings. Authentication is handled by fastapi-fullauth, my own open-source library, giving the app JWT access/refresh rotation for free. The backend is cleanly layered into repositories, services, and Pydantic schemas over async SQLAlchemy 2.0, with the chat list resolving each conversation's latest message in a single Postgres DISTINCT ON query and ordering by recent activity to avoid N+1 fan-out.