A real-time chat and video-calling application with a C++23 backend and a Svelte 5 + TypeScript frontend. It uses a custom NPRPC framework for typed RPC between client and server, SQLite for persistence, and WebRTC for peer-to-peer media.
- Secure login with cookie-based sessions and CSRF protection
- Chats, contacts, messages, unread tracking
- Real-time notifications via observer pattern
- WebRTC video calls with trickle ICE and TURN support
- Custom IDL (.npidl) → generated client/server RPC stubs
- Optimized hybrid build (CMake/Docker for C++, Vite for client)
- Backend: C++23, CMake, SQLite, OpenSSL, spdlog
- Frontend: Svelte 5, TypeScript, Vite, Tailwind CSS
- RPC: NPRPC (custom), IDL in
idl/ - Media: WebRTC (STUN/TURN)
server/— C++ server and servicesclient/— Svelte 5 frontendidl/— NPRPC IDL files (generate TS/CPP bindings)external/— NPSystem/NPRPC sourcesbuild.sh,configure.sh— Build scripts (hybrid)gen_stubs.sh— Generate RPC stubs and copy to client
Prerequisites
- Linux host (tested), C++ toolchain, CMake
- Node.js 18+ and npm
- OpenSSL (for TLS if using HTTPS/WSS)
Setup
- Configure once
./configure.sh
- Build all (server + client)
./build.sh
- Run backend server
./build.sh run
- Frontend dev server (in another terminal)
cd client && npm run dev
The client dev server runs with HTTPS (see client/vite.config.ts) and proxies RPC/WebSocket to the C++ backend.
Server (.env in repo root)
USE_SSL=1— enable TLS (default in this repo)BUILD_TYPE=Debug|Release
Client (client/.env.* for Vite)
- Preferred (JSON array of ICE servers)
VITE_WEBRTC_ICE_SERVERS='[{"urls":"stun:stun.l.google.com:19302"},{"urls":"turn:example.com:3478","username":"user","credential":"pass"}]'
- Fallback (individual vars)
VITE_WEBRTC_STUN_URLS=stun:stun.l.google.com:19302,stun:stun1.l.google.com:19302VITE_WEBRTC_TURN_URL=turn:example.com:3478VITE_WEBRTC_TURN_USERNAME=userVITE_WEBRTC_TURN_CREDENTIAL=pass
Notes
- Vite only exposes variables prefixed with
VITE_to client code. - See
client/.env.examplefor examples.
- Generate RPC stubs after updating
idl/npchat.npidl:./gen_stubs.sh
- Incremental rebuilds:
./build.sh server(backend only)./build.sh client(frontend bundle only)
- Hot reload for UI:
cd client && npm run dev
- Open the app in two browser tabs or devices
- Start a call from a chat using the “Call” button
- ICE trickling and end-of-candidates are handled automatically
- Ensure your ICE/TURN config is set via Vite env for NAT traversal
- Docker build and packaging scripts included:
./01_docker_build.sh— Build production images./02_pack_runtime.sh— Create runtime package./03_deploy.sh— Deploy to remote host
Adjust server certificates and hostnames in client/vite.config.ts and server config as needed.
- Cookie-based sessions with CSRF protection
- 256-bit cryptographically secure session IDs (OpenSSL)
- Authorization checks for chat operations (creator permissions)
This project is licensed under the MIT License. See LICENSE.
- NPSystem / NPRPC framework (in
external/) - spdlog, Tailwind CSS, Svelte, Vite