| layout | default |
|---|---|
| title | Deployment Guide |
| description | Local development, server persistence, Pages deployment, and workflow configuration for Note Sync Now |
| permalink | /docs/en/deployment/ |
| lang | en |
This guide covers how to run Note Sync Now locally, in production, and key configuration boundaries when adjusting deployment and workflows.
cd apps/api
npm ci
node index.jsDefault port: 3002
| Variable | Description | Default |
|---|---|---|
PORT |
Server port | 3002 |
CORS_ORIGIN |
CORS origin (dev: http://localhost:5173) |
Required in production |
PRIMARY_STORAGE |
Main storage backend (redis, sqlite, memory) |
memory |
FALLBACK_STORAGE |
Fallback storage backend | memory |
REDIS_HOST |
Redis server hostname | localhost |
REDIS_PORT |
Redis server port | 6379 |
REDIS_PASSWORD |
Redis authentication password | - |
REDIS_DB |
Redis database number | 0 |
SQLITE_DB_PATH |
SQLite database file path | ./data/sync.db |
ROOM_TTL_MS |
Room time-to-live in milliseconds | 3600000 (1 hour) |
MAX_MEMORY_ROOMS |
Maximum number of rooms in memory | 10000 |
Key entry points:
apps/api/index.jsapps/api/start-local.shapps/api/.env.example
The start-local.sh script requires dependencies to be pre-installed and starts with NODE_ENV=development by default. If CORS_ORIGIN is not explicitly set, it uses http://localhost:5173 as the local development default. To avoid blocking on Redis connection, it defaults both PRIMARY_STORAGE and FALLBACK_STORAGE to sqlite.
cd apps/web
npm ci
npm run devDefault development address: http://localhost:5173
| Variable | Description | Default |
|---|---|---|
VITE_SOCKET_URL |
WebSocket server URL | http://localhost:3002 (dev only) |
Key files:
apps/web/vite.config.jsapps/web/package.json
In local development, if VITE_SOCKET_URL is not set, the client falls back to http://localhost:3002. In non-development environments, this variable must be explicitly provided to avoid silently connecting to the wrong address.
The server initializes the persistence layer on startup:
- Attempt to initialize
PersistenceManager - Select Redis as primary storage and SQLite as fallback based on configuration
- If persistence initialization fails, fall back to pure memory mode
- Expose
/healthand/statsendpoints for runtime status checks
This means:
- Development environments can verify the sync main link without full persistence dependencies
- Production environments should prioritize ensuring both primary and fallback storage are available
- When falling back to memory mode, sync state cannot be preserved after restart
PersistenceManager
โโโ Primary Storage
โ โโโ Redis (recommended for production)
โ โโโ SQLite (lightweight alternative)
โ โโโ Memory (development only)
โโโ Fallback Storage
โโโ SQLite (if primary is Redis)
โโโ Memory (last resort)
Create a docker-compose.yml:
version: '3.8'
services:
redis:
image: redis:7-alpine
restart: unless-stopped
volumes:
- redis-data:/data
server:
build: ./apps/api
restart: unless-stopped
environment:
- NODE_ENV=production
- PORT=3002
- CORS_ORIGIN=https://your-domain.com
- PRIMARY_STORAGE=redis
- FALLBACK_STORAGE=sqlite
- REDIS_HOST=redis
- REDIS_PORT=6379
- ROOM_TTL_MS=3600000
ports:
- "3002:3002"
depends_on:
- redis
volumes:
redis-data:- Set explicit
CORS_ORIGIN(do not use wildcard) - Configure primary storage (Redis recommended)
- Configure fallback storage (SQLite)
- Set up SSL/TLS termination
- Configure firewall rules
- Set up log aggregation
- Configure monitoring (health checks)
- Set resource limits (CPU, memory)
| Endpoint | Purpose | Example Response |
|---|---|---|
GET /health |
Basic health status | {"status":"healthy","connections":5,"rooms":3,"persistence":"connected"} |
GET /stats |
Detailed statistics | Connection count, room count, memory usage, persistence stats |
The repository root hosts the GitHub Pages documentation site. Key files:
index.mdREADME.mdREADME.zh-CN.mdCONTRIBUTING.mddocs/(this directory)_config.yml.github/workflows/pages.yml
Pages serves as:
- Project introduction
- Architecture and sync mechanism documentation
- Deployment and operations guides
- Changelog archive
# Install Jekyll (requires Ruby)
gem install bundler jekyll
# Serve locally
bundle exec jekyll serve# Client tests and build
cd apps/web && npm ci && npm test -- --run && npm run build
# Server tests
cd ../api && npm ci && npm test
# Property-based tests (recommended for sync/persistence changes)
cd ../api && npm run test:propertyThe project uses GitHub Actions with two workflows:
-
CI Workflow (
.github/workflows/ci.yml)- Runs on PR and push to main
- Executes client tests and build
- Executes server tests
-
Pages Workflow (
.github/workflows/pages.yml)- Builds and deploys documentation
- Triggers on docs changes
Verify:
- Health check
/healthremains functional join-chain/push-update/request-syncmaintain compatibility- Persistence failure correctly falls back to memory mode
Verify:
- Local development allows
VITE_SOCKET_URLto fall back tohttp://localhost:3002 - Production environment gives clear error if
VITE_SOCKET_URLis missing - Reconnection properly rejoins room after disconnect
- Error events and status indicators remain functional
Verify:
- Pages covers all public documentation pages
- CI at minimum runs client tests, client build, server tests, and server property tests
- Documentation structure changes are reflected in
changelog/
| Symptom | Cause | Solution |
|---|---|---|
| Client cannot connect | CORS misconfiguration | Check CORS_ORIGIN matches client URL |
| Server not starting | Port already in use | Change PORT or kill existing process |
| Redis connection fails | Redis not running | Start Redis or use SQLite fallback |
| Symptom | Cause | Solution |
|---|---|---|
| Updates not received | Room mismatch | Verify same mnemonic on all clients |
| Large content fails | Size limit exceeded | Content is chunked automatically; check server limits |
| Rate limit errors | Too frequent updates | Reduce edit frequency or adjust rate limits |
- Documentation Home
- Quick Start Guide
- Architecture Overview
- Current page: Deployment Guide
- Security & Synchronization
- Contributing Guide
Last updated: 2026-04-16