Skip to content

Repository files navigation

Novps Chat Demo

Demonstration Next.js (App Router) app for the Novps platform. It includes an HTTP server and an independent WebSocket server for chat rooms with Redis as storage.

Features

  • Create chat rooms without authentication while selecting message retention: 1 hour, 6 hours, 12 hours, 24 hours, 7 days.
  • Generate invite links as the room owner.
  • Store message history in Redis with per-room expiration.
  • Use JWT tokens in http-only cookies to identify the owner, validate invites, and store participant names. Tokens are forwarded to the WebSocket connection via query parameters when the page is rendered so authentication works even if the WebSocket server is on another domain.
  • Direct navigation to a room without an invite returns 404.
  • Invitees must supply a name after following the invite link before they can send messages.
  • Clients only use anonymous UUIDs; the name is kept in an http-only cookie.
  • UI built with Tailwind CSS.
  • Two independent processes: HTTP (Next.js) and WebSocket (ws) server.

Run with Docker Compose

  1. Copy .env.example to .env and update variables if needed:
    cp .env.example .env
  2. Start the services (both servers read configuration from .env):
    docker-compose up --build
  3. The HTTP server runs at http://localhost:3000, WebSocket at ws://localhost:3001, Redis at localhost:6379.

Local run without Docker

Requires Node.js 20+ and a running Redis.

npm install
npm run dev:http           # Next.js HTTP server on 3000
npm run websocket          # WebSocket server on 3001

Both processes load environment variables from .env via Next.js and dotenv, so ensure the file exists before starting.

Key scripts

  • npm run dev:http — Next.js dev server.
  • npm run build — build client and server components.
  • npm run start — Next.js production server.
  • npm run websocket — standalone WebSocket server (ws + Redis pub/sub).

Data architecture

  • room:<id>:meta — hash with ownerId, messageTtlSeconds, createdAt.
  • room:<id>:invites — set of invite tokens.
  • room:<id>:messages — list of messages (JSON) filtered by expiresAt.
  • JWT cookies: owner_<roomId>, invite_<roomId>, username_<roomId>.

Environment variables

  • REDIS_URL — Redis URI.
  • JWT_SECRET — JWT secret.
  • NEXT_PUBLIC_WS_URL — WebSocket server address, e.g., ws://localhost:3001.
  • WS_PORT — WebSocket server port.

About

Demo Next.js (App Router) chat app for Granite: an HTTP server plus a standalone WebSocket server, with Redis-backed message history.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages