Re:Flex is a lightweight, self-hosted, privacy-first messaging server written in Go with E2EE support and WebSocket real-time gateway.
- Dual Authentication: Register/login with Email (RFC5322) OR Phone number (E.164 format).
- Public Key Binding: Stores Ed25519 or Curve25519 public keys during registration for End-to-End Encryption (E2EE).
- Embedded SQLite: Zero-dependency database using
modernc.org/sqlite. - Real-time WebSocket Gateway: Authenticated
/wsendpoint supporting ping/pong heartbeat and JSON frame messaging. - Dockerized: Multi-stage Dockerfile and Docker Compose with volume persistence.
Register a new user with an email or phone number and upload their E2EE public identity key.
Request:
{
"username": "alice",
"identifier": "alice@example.com", // or "+14155552671"
"password": "strongpassword123",
"public_identity_key": "MCowBQYDK2VwAyEA..."
}Response (201 Created):
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "c620456c-0e78-43db-b864-4424ff433230",
"username": "alice",
"identifier_type": "email",
"identifier_value": "alice@example.com",
"public_identity_key": "MCowBQYDK2VwAyEA...",
"created_at": "2025-01-01T00:00:00Z"
}
}Authenticate with email or phone number + password.
Request:
{
"identifier": "alice@example.com",
"password": "strongpassword123"
}Response (200 OK):
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": { ... }
}Fetch a user's public identity key for initiating E2EE sessions.
Response (200 OK):
{
"username": "alice",
"public_identity_key": "MCowBQYDK2VwAyEA..."
}Connect with a JWT token passed via query parameter or Authorization header:
ws://localhost:8080/ws?token=<JWT_TOKEN>- Or Header:
Authorization: Bearer <JWT_TOKEN>
{
"type": "ping" | "message" | "ack" | "pong",
"payload": {}
}- Go 1.22+
go run ./cmd/reflex-servergo test ./...docker compose up -dThe server will run on port 8080, saving SQLite data to ./data/reflex.db.