Frontend Repo (Vite, React, TS)
REST API backend for a real-time messaging application. Handles user authentication, friend requests, conversations, and message delivery. The frontend is a separate Vite + React + TypeScript app.
- Runtime: Bun. Originally written for Node.js, migrated to the Bun runtime with minimal changes. It is still a standard Express.js app.
- Framework: Express.js
- Database: MongoDB via Mongoose
- Real-time: Socket.IO used for live message delivery between connected clients
- Authentication: JWT bearer tokens. Protected routes require a valid
Authorization: Bearer <token>header. - Validation: Zod schemas applied via Express middleware on all incoming request bodies and params
- Testing: Bun's built-in test runner with Supertest and
mongodb-memory-serverfor in-process integration tests. Originally used Jest, replaced withbun:testlater. Bun's test runner is Jest-compatible.
- User registration and login
- Friend request system
- One-on-one conversations between users
- Paginated message history
- Real-time messaging via Socket.IO rooms
Containerized with Docker. A multi-stage Dockerfile compiles the app into a single self-contained executable using bun build --compile. Docker BuildKit secrets are used to inject environment variables at build time without leaking them into image layers.
The live demo runs on a Hetzner VPS.
bun run devbun run build
bun run startbun run docker:build
bun run docker:runbun test
bun test --watch