Backend / Real-time
Real-Time Messaging Platform
A real-time messaging backend built with FastAPI, WebSocket and PostgreSQL.
- Python 3.13
- FastAPI
- WebSocket
- PostgreSQL
- SQLAlchemy
- Alembic
- JWT
- Docker
- Nginx
- Sentry
- pytest
- pytest-asyncio
Architecture overview
// reliable boundaries
Messaging Clients
Nginx
FastAPI + WebSocket
PostgreSQL
Sentry
Overview
This messaging backend uses FastAPI and WebSockets for live delivery, with PostgreSQL as the source of truth. Authentication is JWT-based, while friend, block, typing, read and presence flows sit on top of an async data layer with Alembic migrations.
Technology Stack
- Python 3.13
- FastAPI
- WebSocket
- PostgreSQL
- SQLAlchemy
- Alembic
- JWT
- Docker
- Nginx
- Sentry
- pytest
- pytest-asyncio
Technical Implementation
- Real-time WebSocket messaging.
- Async PostgreSQL data layer.
- Database migrations with Alembic.
- JWT authentication.
- Friend / block flows.
- Message deletion.
- Typing / read indicators.
- Online / offline status tracking.
- Docker + Nginx deployment structure.
- Error monitoring with Sentry.
- Async tests.
Key Engineering Decisions
- Use WebSockets for live events and keep message history in PostgreSQL so reconnects can restore conversation state.
- Build the data layer with async SQLAlchemy so connection handling stays compatible with FastAPI's async runtime.
- Track presence, typing and read receipts as first-class events rather than inferring them only from message traffic.
- Put Nginx in front of the containerized app so TLS and reverse proxy concerns stay outside the Python process.
- Send runtime errors to Sentry and cover async paths with pytest-asyncio.