TSM Platform Quick Deployment
Complete deployment guide for RAILWISE-TSM Total Station Automated Deformation Monitoring Platform using Docker Compose, environment configuration, service management, and initialization
TSM Platform Quick Deployment
Section titled “TSM Platform Quick Deployment”Estimated Reading Time: 25 minutes
Goal: Complete full-stack RAILWISE-TSM deployment locally or on server and verify total station connection
Architecture Overview
Section titled “Architecture Overview”RAILWISE-TSM adopts a frontend-backend separation + edge computing architecture:
┌─────────────────────────────────────────────────────────────┐│ User Layer ││ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ ││ │ Web Console │ │ WorkWise │ │ CLI Tool │ ││ │ (Next.js) │ │ Desktop │ │ (Bun/TS) │ ││ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │└─────────┼─────────────────┼─────────────────┼───────────────┘ │ │ │ └─────────────────┼─────────────────┘ │ HTTPS / WebSocket┌───────────────────────────┼─────────────────────────────────┐│ API Gateway Layer ││ ┌─────────────────────────┐ ││ │ Nginx (Reverse Proxy)│ ││ │ + SSL Termination │ ││ └────────────┬────────────┘ │└───────────────────────────┼─────────────────────────────────┘ │┌───────────────────────────┼─────────────────────────────────┐│ Application Layer (NestJS) ││ ┌────────────┐ ┌────────────┐ ┌────────────┐ ││ │ Monitoring │ │ Data │ │ Alert │ ││ │ Scheduler │ │ Storage │ │ Engine │ ││ └────────────┘ └────────────┘ └────────────┘ ││ ┌────────────┐ ┌────────────┐ ┌────────────┐ ││ │ User Auth │ │ Report │ │ WebSocket │ ││ │ Service │ │ Generator │ │ Push │ ││ └────────────┘ └────────────┘ └────────────┘ │└───────────────────────────┼─────────────────────────────────┘ │┌───────────────────────────┼─────────────────────────────────┐│ Data Storage Layer ││ ┌────────────┐ ┌────────────┐ ┌────────────┐ ││ │ PostgreSQL │ │ Redis │ │ MinIO │ ││ │ (Main DB) │ │ (Cache/Q) │ │ (Object) │ ││ └────────────┘ └────────────┘ └────────────┘ │└───────────────────────────┼─────────────────────────────────┘ │┌───────────────────────────┼─────────────────────────────────┐│ Edge Computing (Rust/WASM) ││ ┌─────────────────────────────────────────────────────┐ ││ │ Total Station Gateway (TS-Gateway) │ ││ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ ││ │ │ Leica │ │ Topcon │ │ Sokkia │ ... │ ││ │ │ Driver │ │ Driver │ │ Driver │ │ ││ │ └──────────┘ └──────────┘ └──────────┘ │ ││ │ ┌─────────────────────────────────────────────┐ │ ││ │ │ WASM Real-Time Compute Engine │ │ ││ │ │ (Coord Transform / Adjustment / Deformation)│ │ ││ │ └─────────────────────────────────────────────┘ │ ││ └─────────────────────────────────────────────────────┘ │└─────────────────────────────────────────────────────────────┘Prerequisites
Section titled “Prerequisites”Server Configuration
Section titled “Server Configuration”| Environment | CPU | Memory | Disk | Network |
|---|---|---|---|---|
| Dev/Test | 4 cores | 8 GB | 50 GB SSD | 100 Mbps |
| Production (<50 stations) | 8 cores | 16 GB | 200 GB SSD | 1 Gbps |
| Production (50-200 stations) | 16 cores | 32 GB | 500 GB SSD | 1 Gbps |
| Production (200+ stations) | 32+ cores | 64+ GB | 1 TB SSD | 10 Gbps |
Software Dependencies
Section titled “Software Dependencies”| Software | Minimum Version | Purpose |
|---|---|---|
| Docker | 24.0+ | Container runtime |
| Docker Compose | 2.20+ | Multi-service orchestration |
| Git | 2.30+ | Fetch deployment scripts |
If Docker is not installed, refer to official documentation:
Deployment Steps
Section titled “Deployment Steps”Step 1: Fetch Deployment Scripts
Section titled “Step 1: Fetch Deployment Scripts”git clone https://github.com/railwise/tsm-deploy.gitcd tsm-deployDirectory structure:
tsm-deploy/├── docker-compose.yml # Main orchestration file├── .env.example # Environment variable template├── nginx/│ ├── nginx.conf # Reverse proxy config│ └── ssl/ # SSL certificate directory├── init-scripts/│ ├── init-db.sql # Database initialization│ └── init-minio.sh # Object storage initialization└── scripts/ ├── start.sh # One-click start ├── stop.sh # One-click stop └── backup.sh # Data backupStep 2: Configure Environment Variables
Section titled “Step 2: Configure Environment Variables”cp .env.example .envnano .env # or vim / any editorCore configuration items:
# ==========================================# Basic Config# ==========================================COMPOSE_PROJECT_NAME=railwise-tsmTZ=Asia/Shanghai
# ==========================================# Database Config# ==========================================POSTGRES_HOST=postgresPOSTGRES_PORT=5432POSTGRES_DB=railwise_tsmPOSTGRES_USER=railwisePOSTGRES_PASSWORD=CHANGE_THIS_STRONG_PASSWORD
# ==========================================# Redis Config# ==========================================REDIS_HOST=redisREDIS_PORT=6379REDIS_PASSWORD=CHANGE_THIS_REDIS_PASSWORD
# ==========================================# MinIO Object Storage Config# ==========================================MINIO_ROOT_USER=railwiseMINIO_ROOT_PASSWORD=CHANGE_THIS_MINIO_PASSWORDMINIO_BUCKET_NAME=tsm-data
# ==========================================# API Service Config# ==========================================API_PORT=3000API_JWT_SECRET=CHANGE_THIS_JWT_SECRET_32_CHAR_MINAPI_CORS_ORIGIN=https://tsm.yourdomain.com
# ==========================================# Web Frontend Config# ==========================================WEB_PORT=3001NEXT_PUBLIC_API_URL=https://tsm.yourdomain.com/api
# ==========================================# Edge Gateway Config# ==========================================GATEWAY_PORT=50051GATEWAY_LOG_LEVEL=infoFor production environments, please change all default passwords, especially POSTGRES_PASSWORD, JWT_SECRET, and MINIO_ROOT_PASSWORD. Use random strings of 32+ characters.
Step 3: Start Services
Section titled “Step 3: Start Services”chmod +x scripts/*.sh./scripts/start.shstart.sh execution flow:
- Check Docker and Docker Compose availability
- Load
.envenvironment variables - Create necessary local directories (data volumes, log directories)
- Pull latest images (first time) or build local images (dev mode)
- Start services in dependency order: PostgreSQL → Redis → MinIO → API → Web → Gateway
- Wait for health checks to pass
- Output access addresses and initial account info
Expected output:
[RailWise TSM] Starting...✓ Docker version: 26.1.0✓ Docker Compose version: 2.27.0✓ Environment variables loaded✓ Data directories created✓ Images pulled✓ PostgreSQL health check passed (3/3)✓ Redis health check passed (3/3)✓ MinIO health check passed (3/3)✓ API service health check passed (5/5)✓ Web service health check passed (5/5)✓ Gateway service health check passed (5/5)
═══════════════════════════════════════════ RAILWISE-TSM Deployment Successful═══════════════════════════════════════════ Web Console: http://localhost:3001 API Docs: http://localhost:3000/api/docs MinIO Console: http://localhost:9001
Initial admin account: Username: admin@railwise.cn Password: RailWise@2025
Please log in immediately and change the default password!═══════════════════════════════════════════Step 4: Verify Deployment
Section titled “Step 4: Verify Deployment”4.1 Access Web Console
Section titled “4.1 Access Web Console”Open browser and visit http://localhost:3001, log in with initial account.
4.2 Verify API Service
Section titled “4.2 Verify API Service”curl http://localhost:3000/api/healthExpected response:
{ "status": "ok", "version": "2.3.1", "timestamp": "2025-06-05T14:32:18+08:00", "services": { "database": "connected", "redis": "connected", "minio": "connected", "gateway": "connected" }}Service Management
Section titled “Service Management”Common Operations
Section titled “Common Operations”| Operation | Command | Description |
|---|---|---|
| Start | ./scripts/start.sh |
Start all services |
| Stop | ./scripts/stop.sh |
Stop all services |
| Restart | docker compose restart api |
Restart single service |
| View Logs | docker compose logs -f api |
Real-time API logs |
| View All Logs | docker compose logs -f |
Real-time all service logs |
| Enter Container | docker compose exec api sh |
Enter API container for debugging |
| Data Backup | ./scripts/backup.sh |
Backup database and object storage |
| Update Version | ./scripts/update.sh |
Pull latest images and restart |
Total Station Connection Configuration
Section titled “Total Station Connection Configuration”Step 1: Add Instrument in Console
Section titled “Step 1: Add Instrument in Console”Log in to Web Console → System Settings → Instrument Management → Add Instrument
Step 2: Fill Instrument Parameters
Section titled “Step 2: Fill Instrument Parameters”| Field | Example Value | Description |
|---|---|---|
| Instrument Name | TS-16-001 | Custom identifier |
| Brand/Model | Leica TS16 | Dropdown selection |
| Connection Type | TCP/IP | TCP / Serial / Bluetooth |
| IP Address | 192.168.1.100 | Total station network address |
| Port | 8080 | GeoCOM port |
| Station ID | ZD01 | Corresponding monitoring station |
| Coordinate System | CGCS2000 | Consistent with project |
Step 3: Test Connection
Section titled “Step 3: Test Connection”Click “Test Connection” button. Console will send GET_INSTRUMENT_NAME command to verify communication.
Production Environment Hardening
Section titled “Production Environment Hardening”SSL Certificate Configuration
Section titled “SSL Certificate Configuration”Place certificate files in nginx/ssl/ directory:
nginx/ssl/├── tsm.yourdomain.com.crt└── tsm.yourdomain.com.keyEdit nginx/nginx.conf to enable HTTPS listening.
Database Backup Strategy
Section titled “Database Backup Strategy”Add cron job:
# Auto backup at 2:00 AM daily0 2 * * * /opt/tsm-deploy/scripts/backup.sh >> /var/log/tsm-backup.log 2>&1Next Steps
Section titled “Next Steps”- CLI Quick Start — Use command-line tools for batch data processing
- Metro Protection Zone Monitoring — Rail transit scenario monitoring configuration
- TSM OpenAPI Documentation — Programmatic interface calling guide
Metadata Tags
Section titled “Metadata Tags”Last updated: 2025-06-05 | Version v1.0.0 | © Ningbo RailWise Engineering Technology Co., Ltd.
