Self-hosted multi-tenant chat platform with:
- backend API (
Fastify+PostgreSQL) - operator admin console (
Next.js) - embeddable widget engine (plain script + React SDK)
The project is designed for teams that want to host chat infrastructure in their own perimeter.
- Multi-project tenancy via
projectKey - Widget API + operator admin API
- SSE-first real-time updates with polling fallback
- CSRF-protected admin mutations
- DB-backed operator sessions and audit log
- Telegram notification guard that avoids sending PII message content
chat-me/
├── apps/
│ ├── admin/ # Next.js operator console (/admin/*)
│ ├── api/ # Fastify backend, migrations, seeds
│ └── widget/ # standalone browser bundle build
├── packages/
│ ├── sdk/ # React wrapper + DOM widget engine
│ └── shared/ # shared schemas, types, constants
├── examples/
│ ├── next-site-a/
│ ├── next-site-b/
│ └── insales-liquid/
└── docs/
└── vps-deploy.md
- Node.js 22+
- npm 10+
- PostgreSQL 15+
- Copy env template:
cp .env.example .env-
Update
.envvalues (at minimumDATABASE_URLandPASSWORD_PEPPER). -
Install dependencies:
npm install- Export env variables for local shell session:
set -a
source .env
set +a- Apply schema and seed demo data:
npm run migrate
npm run seed- Start local services:
npm run dev:api
npm run dev:admin
npm run dev:widgetLocal URLs:
- admin:
http://localhost:3100/admin/login - api:
http://localhost:4100 - widget bundle:
http://localhost:4100/widget/chat-me-widget.js
npm run checkcheck runs production builds for all workspace packages/apps.
See .env.example.
Core variables:
DATABASE_URLAPI_HOST,API_PORT,API_PUBLIC_BASE_URLNEXT_PUBLIC_API_BASE_URL,ADMIN_PUBLIC_URLSESSION_COOKIE_NAME,CSRF_COOKIE_NAME,SESSION_TTL_HOURSPASSWORD_PEPPERSMTP_*andNOTIFICATION_EMAIL_TOTELEGRAM_ALERTS_ENABLED,TELEGRAM_BOT_TOKEN,TELEGRAM_CHAT_IDWEB_PUSH_VAPID_PUBLIC_KEY,WEB_PUSH_VAPID_PRIVATE_KEY,WEB_PUSH_SUBJECT
- Next.js site A: examples/next-site-a/README.md
- Next.js site B: examples/next-site-b/README.md
- InSales/Liquid snippets: examples/insales-liquid/
Primary tables include:
chat_projectschat_visitorschat_conversationschat_messageschat_internal_noteschat_operatorschat_operator_sessionschat_internal_notificationschat_audit_log
Schema: apps/api/src/db/schema.sql
Generic VPS deployment template: docs/vps-deploy.md
- Keep
.envand production secrets out of git. - Rotate
SEED_OPERATOR_PASSWORDafter first seed in production. - Set strict
allowedOriginsper project before enabling production traffic.
Please read CONTRIBUTING.md before opening PRs.
MIT, see LICENSE.