This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
synchronizer-cli is a Node.js CLI application for managing Multisynq Synchronizer Docker containers with real-time WebSocket monitoring and web dashboard capabilities. The project uses Commander.js for CLI structure, Express for the web dashboard, and WebSocket for real-time communication.
# Run the CLI (no build required - pure JavaScript)
node index.js [command]
# Test the help output (basic test)
npm test
# Security scan before publishing
./security-scan.sh
# Pre-publish validation
node pre-publish-check.js
# Test WebSocket connections
node test-websocket-direct.js
node websocket-test.js# Interactive setup
node index.js init
# Start synchronizer container
node index.js start
# Launch web dashboard
node index.js web
node index.js web --port 8080 --metrics-port 8081
# Check service status
node index.js status
# View points
node index.js points
# Validate synq key
node index.js validate-key [key]# Run security and pre-publish checks first
./security-scan.sh
node pre-publish-check.js
# Publish to npm
npm publishThe entire application is contained in index.js (239KB), which implements:
- CLI Framework - Commander.js-based command structure with subcommands
- Configuration Management - Stored in
~/.synchronizer-cli/config.json - Docker Integration - Container management via child_process.spawn
- Web Dashboard - Express server with dual-port architecture
- WebSocket Client - Real-time communication on port 3333
- API Integration - Points API, Enterprise API, and validation endpoints
-
Port Configuration:
- Dashboard: Default 3000 (configurable with --port)
- Metrics API: Default 3001 (configurable with --metrics-port)
- WebSocket: Fixed at 3333 (server endpoint)
-
Configuration Storage:
- Main config:
~/.synchronizer-cli/config.json - Points cache:
~/.synchronizer-cli/points.json - Other caches: Various JSON files for API responses
- Main config:
-
Docker Container:
- Image:
cdrakep/synqchronizer:latest - Multi-arch support: AMD64 and ARM64
- Port mapping: 3333:3333 for WebSocket
- Image:
-
API Endpoints:
- Points API:
https://api.multisynq.io/points/[wallet] - Enterprise API:
https://ent.multisynq.io/v1/ - Validation API:
https://api.multisynq.io/validate/[key]
- Points API:
The WebSocket client connects to ws://localhost:3333 and handles:
- Container stats (CPU, memory, disk usage)
- Real-time metrics updates
- Connection retry logic with exponential backoff
- Message deduplication
The dashboard uses a dual-server approach:
- Main Server (port 3000): Serves HTML interface and dashboard APIs
- Metrics Server (port 3001): Provides JSON API endpoints
Key dashboard endpoints:
GET /- Main dashboard HTMLGET /api/status- System statusGET /api/performance- Performance metrics and QoSGET /metrics- Raw metrics JSON
The project follows standard Node.js conventions:
- Callbacks and Promises (no async/await due to Node 10 compatibility)
- Commander.js action handlers for commands
- Express middleware for web routes
- Child process spawning for Docker commands
The application implements comprehensive error handling:
- Docker installation detection and auto-install prompts
- Permission error handling with fix suggestions
- Platform compatibility checks
- WebSocket reconnection logic
- Sensitive data (synq keys) are masked in displays
- Configuration stored in user home directory
- Security scan script checks for exposed secrets
- Password protection for web dashboard
Current testing is minimal:
npm testruns help command- WebSocket test utilities in
test-websocket-direct.jsandwebsocket-test.js - Manual testing of Docker commands and web dashboard
- Main application:
index.js - Configuration:
~/.synchronizer-cli/config.json - Points cache:
~/.synchronizer-cli/points.json - Systemd services: Generated in
~/.synchronizer-cli/ - Deployment scripts:
startup-synchronizer.sh,startup-synchronizer-service.sh
The package includes only essential files:
index.js- Main applicationREADME.md- DocumentationENTERPRISE.md- Enterprise featuresstartup-synchronizer.sh- Cloud deployment script
The startup-synchronizer.sh script provides automated deployment for:
- AWS EC2
- DigitalOcean
- Google Cloud
- Azure
- Any Ubuntu/Debian instance
The project tracks versions in multiple places:
package.json- NPM package version- Launcher ID - Format:
cli-[version]/docker-[croquet-version] - Docker image - Uses
latesttag