A lightweight, local-first chat server and single-page web client for quick LAN messaging and peer-to-peer video calls — with on-device or remote AI helpers, no external database required.
What is XteVision SecuChat and who is it for?
XteVision SecuChat (xtevision-secuchat v1.0.0) is a lightweight, local-first, self-hosted chat server and single-page web client for quick LAN messaging and peer-to-peer video calls. It stores data in data.json, serves the UI from public/, and saves uploads to uploads/. It is designed to run with minimal setup — no external database required.
scrypt password hashinguploads/5009)High-level design and communication flow
┌─────────────────────────────────────────────────────────────────┐
│ Browser (Single-Page Client) │
│ ┌────────┐ ┌──────────┐ ┌────────┐ ┌────────┐ ┌──────────────┐ │
│ │ Login │ │ Chat │ │Contacts │ │Calls │ │AI Assistant │ │
│ └────────┘ └──────────┘ └────────┘ └────────┘ └──────────────┘ │
└──────────────────────────────┬──────────────────────────────────┘
│ HTTP / SSE
┌──────────────────────────────┴──────────────────────────────────┐
│ Node.js Server (port 5008) │
│ ┌───────────┐ ┌──────────┐ ┌──────────┐ ┌────────────────────┐ │
│ │ Auth │ │Messages │ │Contacts │ │AI Proxy (optional) │ │
│ │(scrypt) │ │(SSE) │ │(request/ │ │ → local/remote LLM │ │
│ │ │ │ │ │ accept) │ └────────────────────┘ │
│ └───────────┘ └──────────┘ └──────────┘ │
│ ┌───────────┐ ┌───────────────────────────────────────────────┐ │
│ │Uploads │ │ data.json (users, messages, contacts) │ │
│ │ (uploads/ │ │ public/ (served UI) │ │
│ └───────────┘ └───────────────────────────────────────────────┘ │
└──────────────────────────────┬──────────────────────────────────┘
│ PeerJS signaling
┌──────────────────────────────┴──────────────────────────────────┐
│ Local PeerServer (port 5009) │
│ P2P media connection between peers (video calls) │
└───────────────────────────────────────────────────────────────────┘5009), then media flows peer-to-peerXteVision SecuChat is designed for self-hosted, LAN-first operation:
Frontend, backend, and infrastructure technologies
| Layer | Technology | Purpose |
|---|---|---|
| Runtime | Node.js (≥ 16) | Server runtime |
| Server | Express.js | HTTP server + API routes |
| Auth | crypto.scrypt | Salted password hashing |
| Real-time | SSE (Server-Sent Events) | Presence & messaging events |
| Storage | data.json | Users, messages, contacts |
| File uploads | multer → uploads/ | Attachments & avatars |
| P2P Signaling | PeerJS + PeerServer | Video-call signaling (port 5009) |
| AI Backend | LLM-compatible API | Chat, translate, summarize, embeddings, moderation |
| Frontend | Vanilla HTML/CSS/JS | Single-page client served from public/ |
Get XteVision SecuChat running on your server
peerjs/)Install dependencies, then optionally install the Peer server for P2P fallback.
# 1. Install server dependencies
npm install
# 2. (Optional) Install Peer server for P2P fallback
cd peerjs
npm install
cd ..
http://your-server-ip:5008
The server runs on port 5008 by default. Connect from your local network. The PeerServer for P2P calls uses port 5009.
# Development
npm run dev # if defined in package.json
# Production
NODE_ENV=production npm start
# or: node server.js
Runtime settings in config.json
XteVision reads runtime settings from config.json in the project root. Edit it for your deployment values before starting the server.
| Section | Settings |
|---|---|
| server | HTTP port, PeerJS port/path, file paths, cookie settings, size limits, CSP sources |
| ai | AI user identity, default engine, and per-engine host/port/path/model settings |
| client | PeerJS signaling settings and default client-side AI engine |
| Variable | Description |
|---|---|
| PORT | HTTP server port (default 5008) |
| AI_BASE_URL | Base URL of the local/remote AI service (preferred when configured) |
| AI_API_KEY | API key read from env vars — never logged |
| AI_STREAM | Set true to receive incremental assistant tokens via SSE |
| AI_LOCAL_ONLY | Set true to prevent forwarding content to external services |
| AI_RATE_LIMIT | Per-client request rate limit to avoid abuse |
Directory layout and key files
xtevision-secuchat/ ├── server.js # Main Express server: routes, SSE, uploads, AI proxy ├── config.json # Runtime configuration (server / ai / client) ├── data.json # Users, messages, and contacts (back up before edits) ├── public/ # Single-page UI (served as static assets) ├── uploads/ # Attachments & avatars (enforced limits) ├── peerjs/ # Optional local PeerServer for P2P fallback └── package.json # Dependencies & scripts
| File | Purpose |
|---|---|
| server.js | Main Express server — all API routes, SSE, uploads, AI proxy, static serving |
| config.json | Runtime configuration for server, AI, and client |
| data.json | Persisted users, messages, and contacts — back up before manual edits |
| public/ | Single-page client UI served statically |
| uploads/ | Attachments and avatars (size limits enforced server-side) |
| peerjs/ | Optional local PeerServer (port 5009) for P2P fallback |
data.json before manual edits. Ensure the server process can write to uploads/. Oversized uploads are rejected server-side.API routes and their purpose
| Category | Method & Path | Purpose |
|---|---|---|
| Auth | POST /api/register | Create account |
| Auth | POST /api/login | Obtain session |
| Contacts | POST /api/contacts/request | Send contact request |
| Contacts | POST /api/contacts/accept | Accept contact request |
| Messages | POST /api/messages | Send a message (multipart for attachments) |
| Messages | GET /api/messages/:conversationId | List messages |
| SSE | GET /sse | Subscribe to real-time events (presence, messages) |
| Uploads | POST /api/uploads | Upload files (attachments & avatars) |
Optional — require a configured AI service. Refer to the server code for exact parameter names and response formats.
| Method & Path | Purpose |
|---|---|
POST /api/ai/chat | Conversational assistant. Accepts { messages: [{ role, content }], model? }. Supports streaming with Accept: text/event-stream (SSE). |
POST /api/ai/translate | Translate text (requires AI service) |
POST /api/ai/summarize | Summarize text |
POST /api/ai/embeddings | Generate embeddings for an array of texts; returns embeddings array |
POST /api/ai/moderate | Check content safety (optional) |
Local-first, optional AI helpers
AI_BASE_URL) is available it is preferred; requests are proxied to it with model + key as configured.AI_STREAM=true and request with Accept: text/event-stream to receive incremental assistant tokens (SSE)./api/ai/embeddings for vector representations for search or clustering; batching controlled by AI_BATCH_EMBEDDINGS.AI_LOCAL_ONLY=true to prevent forwarding content to external services. API keys are read from env vars and not logged.Chat (non-streaming):
curl -s -X POST http://localhost:5008/api/ai/chat \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Summarize this message: ..."}]}'
Chat (streaming SSE):
curl -N -X POST http://localhost:5008/api/ai/chat \
-H "Content-Type: application/json" \
-H "Accept: text/event-stream" \
-d '{"messages":[{"role":"user","content":"Tell me about XteVision in one paragraph."}], "model":"gpt-4o-mini"}
Embeddings:
curl -s -X POST http://localhost:5008/api/ai/embeddings \
-H "Content-Type: application/json" \
-d '{"texts":["hello","world"]}
Headers, keys, and privacy controls
scrypt — no plaintext passwords storedAI_API_KEY) remain in the server environment and are treated like secrets — the server will not log keys.AI_BASE_URL points to an external service, user content is forwarded to that service — enable AI_LOCAL_ONLY for privacy-sensitive setups.AI_RATE_LIMIT) helps avoid abuse and unexpected costs.Common issues and solutions
PORT is free or change it via env var.uploads/ directory.AI_BASE_URL, AI_API_KEY, and model names; check rate limits and set AI_STREAM_TIMEOUT appropriately. If a local AI service is used, ensure it is healthy and reachable.