ChatWeb is an enterprise-grade, real-time messaging web application engineered with an Event-Driven Architecture (EDA), Polyglot Persistence, and multi-tier security controls.
- Polyglot Persistence: Segregates relational identity and access control (PostgreSQL 16+), high-throughput message streams and read receipts (MongoDB 7+), and in-memory routing and session states (Redis Stack).
- Decoupled Real-Time & Write-Behind: Leverages Apache Kafka (KRaft mode) with Apache Avro schemas to split message delivery into sub-10ms WebSocket fast-push and batch database persistence with Dead Letter Topic (DLT) fault isolation.
- Distributed Session Routing: Coordinates multi-instance WebSocket nodes behind Nginx using Redis Hash routing tables and targeted Pub/Sub channels.
- Sub-Millisecond Credential Preflight: Employs Redis Cuckoo Filters (
filter:usernames,filter:emails) to reject invalid authentication and registration attempts in memory before querying PostgreSQL. - Distributed Presence Debouncing: Queues disconnected sessions into a Redis Sorted Set (
presence:offline_queue) with a 5-second deadline, completely eliminating presence flapping caused by page reloads or transient network handoffs. - Watermark Read Receipts: Tracks conversation read states via atomic MongoDB
$maxupserts and Redis caching, avoiding write amplification. - Defense-in-Depth Security: Two-tier rate limiting (Nginx IP + Redis sliding window Lua), REST API idempotency (
@Idempotent), STOMP deduplication (ws:dedup), and upstream TLS verification with a private Root Certificate Authority.
.
├── .github/workflows/ # GitHub Actions CI/CD workflows (backend & frontend CI/CD)
├── chatweb_be/ # Spring Boot 3.5.x Backend (Java 21 LTS, JPA, MongoDB, Kafka, Redis)
│ ├── initdb.sql # PostgreSQL schema initialization script
│ ├── init-mongo.js # MongoDB collection and compound index setup
│ └── src/ # Backend application and integration test suites
├── chatweb_fe/ # React 19 Frontend SPA (Vite 8, Modular CSS, STOMP.js, WebRTC)
├── docs/ # Complete Technical Documentation Hub
│ ├── README.md # Master documentation index
│ ├── architecture/ # System topology, 8 ADRs, and 6 Mermaid sequence diagrams
│ ├── database/ # PostgreSQL ERD, MongoDB schemas, and Redis key catalog
│ └── api/ # WebSocket/STOMP specs, Kafka Avro catalog, and REST API guide
├── nginx/ # Nginx configuration (reverse proxy, edge rate-limiting)
├── ssl/ # Private CA and backend PKCS12 keystore (Upstream TLS)
└── docker-compose.yml # Multi-container orchestration (App, DBs, Kafka, ELK, Prometheus)
👉 Browse Full Technical Documentation
| Layer | Technologies |
|---|---|
| Backend | Java 21 LTS, Spring Boot 3.5.x, Spring Security 6, Spring Data JPA / MongoDB / Redis |
| Frontend | React 19, Vite 8, React Router DOM 7, Modular CSS, STOMP.js, WebRTC |
| Real-Time & Events | Spring WebSocket (STOMP), SockJS, Apache Kafka 3.x (KRaft), Confluent Schema Registry, Apache Avro |
| Databases & Cache | PostgreSQL 16+, MongoDB 7+, Redis Stack (RedisBloom, Lua Scripts) |
| Proxy & Ingress | Nginx Alpine, Upstream TLS (rootCA.crt), IP Rate Limiting |
| Observability | Elasticsearch, Logstash, Kibana (ELK), Filebeat, Prometheus, Grafana |
| DevOps & Cloud | Docker, Docker Compose, Google Jib, GitHub Actions, Cloudinary Media Cloud |
- Docker Engine (v24.0+)
- Docker Compose (v2.20+)
Clone the repository and instantiate your .env configuration from the provided sample:
cp .env.example .envReview and adjust secrets in .env (database credentials, JWT secrets, Cloudinary keys, etc.).
Launch all services in detached mode:
docker compose up -d --buildCheck container health statuses:
docker compose psAll primary services (cw_backend, cw_frontend, nginx_lb, cw_postgres, cw_mongo, cw_redis, kafka, kafka2, schema-registry) will report healthy.
| Service | Address | Credentials / Notes |
|---|---|---|
| ChatWeb Frontend | http://localhost (or https://localhost) |
Web Client SPA |
| REST API / Swagger UI | http://localhost/swagger-ui/index.html |
Interactive OpenAPI documentation |
| WebSocket Gateway | ws://localhost/ws |
STOMP endpoint with SockJS fallback |
| Prometheus (optional) | http://localhost:9090 |
Run with --profile monitoring |
| Grafana (optional) | http://localhost/grafana/ |
Run with --profile monitoring |
| Kibana (optional) | http://localhost/kibana |
Run with --profile monitoring |
For detailed architectural specifications, database schemas, and protocol contracts, refer to the documentation suite: