Smart Site
Home Docs Getting Started Installation Guide

Installation Guide

This guide covers the complete installation process of Smart SCADA Data Platform (ss-data), from environment preparation to startup verification, for both development and production build scenarios.

1. Environment Requirements

1.1 Required Environment

Component Minimum Version Recommended Version Description
Node.js 18.0 18.x LTS / 20.x LTS Runtime environment
pnpm 8.0 8.15+ Package manager (Monorepo)
SQLite 3.35 Built-in (better-sqlite3) Metadata storage, zero configuration
Git 2.20 Latest Clone repository

1.2 Optional Environment

Component Purpose Default Status
InfluxDB 2.7+ Time-series data storage (device historical data) Degrades to SQLite-only when not configured
Redis Offline message persistence, caching Degrades to in-memory mode when not configured
MQTT Broker MQTT protocol collection Install on demand

⚠️ InfluxDB is strongly recommended for production environments, otherwise historical data query and report features are limited.

1.3 Operating Systems

  • Windows 10/11 (primary development environment)
  • Linux (Ubuntu 20.04+ / CentOS 7+, production deployment)
  • macOS (development environment compatible)

2. Clone Repository and Install Dependencies

2.1 Clone Code

git clone <repository-url> smart-site
cd smart-site

2.2 Install Backend Dependencies

cd ss-services\ss-node
pnpm install

2.3 Install Frontend Dependencies

cd ss-editor
pnpm install

💡 You can also run pnpm install directly in the root directory. The pnpm workspace will recursively install all sub-package dependencies.

3. Configure .env Files

The backend provides three environment configuration templates under ss-services\ss-node, choose by use case:

File Scenario Data Directory Load Method
.env.dev Local development ./data (project local) Auto-loaded when APP_ENV=dev
.env.ss Deployment runtime (points to ss-run) ../../ss-run/ss/data Loaded by deployment script
.env.pro Production environment Independent data directory Auto-loaded when APP_ENV=pro

3.1 Development Environment Configuration

Create development configuration from template:

cd ss-services\ss-node
# Template .env.dev already exists, modify as needed

Key parameters (see .env.dev):

# Application configuration
NODE_ENV=development
PORT=4000

# Data directory (development uses project-local directory)
DATA_DIR=./data
DATABASE_PATH=${DATA_DIR}/ss-node.db

# Project database mode: isolated (per-project isolated DB)
PROJECT_DB_MODE=isolated

# JWT configuration (must change in production)
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_EXPIRES_IN=7d

# InfluxDB (optional, SQLite-only when not configured)
INFLUXDB_URL=http://localhost:8086
INFLUXDB_TOKEN=
INFLUXDB_ORG=ss-org
INFLUXDB_BUCKET=ss_node_data

3.2 Deployment Runtime Configuration

Deployment scenarios use ../../../../../../../ss-services/ss-node/.env.ss, with data directory pointing to ss-run\ss\data:

# Data directory points to unified runtime directory
DATA_DIR=../../ss-run/ss/data
RUN_DIR=../../ss-run/ss
DATABASE_PATH=${DATA_DIR}/db/ss-node.db

# Base services (Redis / InfluxDB portable)
BASE_SERVICES_DIR=${RUN_DIR}/base_services
AUTO_START_BASE_SERVICES=false

3.3 Frontend Environment Configuration

Frontend config is located at ss-editor/apps/web/.env.development:

# Backend API address
VITE_API_BASE_URL=http://localhost:4000
VITE_WS_URL=http://localhost:4000

⚠️ After changing the backend PORT, you must also update the frontend VITE_API_BASE_URL and VITE_WS_URL.

4. Initialize Database

The database is automatically created on first startup, no manual SQL execution needed:

  • Global database: {DATA_DIR}/ss-node.db (users, system configs, menus, etc.)
  • Project database: {PROJECTS_DIR}/{projectName}/db/system.db (devices, tags, alarms, etc.)

Initialization scripts are located at ../../../../../../../ss-services/ss-node/data/init:

  • init-system-db.sql — Global table structure and default menus
  • init-event-db.sql — Event database structure

To manually initialize (e.g., reset database):

# Delete old database file and restart the service to auto-rebuild
del ss-services\ss-node\data\ss-node.db

5. Start Backend

Run in the repository root directory:

.\bin\start.bat

This script launches both frontend and backend windows, automatically installing dependencies and compiling workspace packages.

5.2 Start Backend Only

cd ss-services\ss-node
pnpm dev

Successful startup indicators:

🚀 Smart SCADA Server running on: http://localhost:4000
📚 API Docs: http://localhost:4000/api/docs
💚 Health Check: http://localhost:4000/api/v1/system/health

⚠️ On first startup, if workspace packages are not compiled, pnpm build runs automatically. After modifying workspace packages, recompile: pnpm --filter @ss-node/ss-core build.

6. Start Frontend

cd ss-editor
pnpm dev:web

After successful startup, visit http://localhost:5173.

7. Verify Installation

7.1 Backend Verification

Check Item Method Expected Result
Service alive Visit http://localhost:4000/api/v1/system/health Returns {"status":"ok"}
API docs Visit http://localhost:4000/api/docs Swagger page loads normally
Database Check ss-services/ss-node/data/ss-node.db file exists File is created
Logs Check data/logs/combined.log No ERROR level logs

7.2 Frontend Verification

Check Item Method Expected Result
Page loads Visit http://localhost:5173 Login page or initialization wizard displays
Data platform Visit http://localhost:5173/system Enter system management interface
API connectivity Browser F12 → Network No CORS errors
WebSocket Enter ws-monitor page Connection status shows connected

7.3 First-Time Initialization Wizard

On first startup with no admin account in the database, visiting the frontend triggers the initialization wizard:

  1. Visit http://localhost:5173
  2. Follow the wizard to fill in admin account (default username admin), password, email
  3. After initialization, redirects to login page

8. Production Build

8.1 Backend Build

cd ss-services\ss-node
pnpm build              # Compile all workspace packages
# Production start
pnpm start:prod

8.2 Frontend Build

cd ss-editor
pnpm build:web          # Build core package + editor + system package + web app

Build artifacts are output to ss-editor\apps\web\dist\, which can be served by Nginx or other static servers.

8.3 Production Environment Checklist

  • [ ] JWT_SECRET in .env.pro changed to a strong random value
  • [ ] NODE_ENV set to production
  • [ ] LOG_LEVEL adjusted to info or warn
  • [ ] InfluxDB Token correctly configured
  • [ ] Data directory DATA_DIR points to persistent storage path
  • [ ] VITE_API_BASE_URL in frontend .env.production points to production backend address
  • [ ] CORS configuration (CORS_ORIGINS) restricted to production domains

9. Common Installation Issues

Issue Cause Solution
pnpm install fails Network issue or low Node version Upgrade Node 18+, configure npm mirror
better-sqlite3 compilation fails Missing build tools Windows: install windows-build-tools; Linux: install python3 make g++
Port 4000 in use Other process occupies the port Change PORT in .env.dev or release the port
Workspace package not effective Not recompiled after modification Run pnpm --filter @ss-node/<package-name> build and restart
Frontend API 404 Backend not started or wrong proxy address Confirm backend is running, check VITE_API_BASE_URL