Skip to content
/ dash Public

Robot & 3D Printer Dashboard - Machine management, reservations, and monitoring

Notifications You must be signed in to change notification settings

X9X0/dash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dash - Robot & 3D Printer Dashboard

A modular web dashboard for managing robots and 3D printers with reservation, tracking, logging, and real-time monitoring capabilities.

Quick Start

Prerequisites

  • Node.js 20+
  • npm or yarn

Installation

  1. Install dependencies:
npm install
  1. Initialize the database:
npm run db:push
npm run db:seed
  1. Start the development servers:
npm run dev

The application will be available at:

Default Login

Project Structure

dash/
├── client/                    # React frontend
│   ├── src/
│   │   ├── components/        # UI components
│   │   ├── pages/             # Page components
│   │   ├── services/          # API client
│   │   ├── store/             # Zustand state
│   │   └── types/             # TypeScript types
├── server/                    # Node.js backend
│   ├── src/
│   │   ├── routes/            # API endpoints
│   │   ├── middleware/        # Auth middleware
│   │   └── socket/            # WebSocket handlers
│   └── prisma/
│       └── schema.prisma      # Database schema

Features

  • Dashboard: Real-time machine status overview
  • Calendar: Reservation scheduling system
  • Machines: Add, edit, and monitor equipment
  • Jobs & Logs: Track job history and activity
  • Maintenance: Submit and manage repair requests
  • Real-time: WebSocket updates for live status changes

Tech Stack

  • Frontend: React 18, TypeScript, Vite, Tailwind CSS
  • Backend: Node.js, Express, TypeScript
  • Database: SQLite with Prisma ORM
  • Real-time: Socket.io
  • Auth: JWT with bcrypt

Available Scripts

  • npm run dev - Start both frontend and backend in development mode
  • npm run build - Build for production
  • npm run db:push - Push schema changes to database
  • npm run db:seed - Seed database with sample data
  • npm run db:studio - Open Prisma Studio

API Endpoints

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login
  • GET /api/machines - List machines
  • POST /api/machines - Create machine
  • GET /api/reservations - List reservations
  • POST /api/reservations - Create reservation
  • GET /api/maintenance - List maintenance requests
  • POST /api/maintenance - Submit maintenance request

Installation & Deployment

Development Setup

Prerequisites

  • Node.js 20 or higher
  • npm (comes with Node.js)
  • Git

Steps

  1. Clone the repository

    git clone <your-repo-url> dash
    cd dash
  2. Install dependencies

    npm install
  3. Configure environment files

    # Copy example environment files
    cp server/.env.example server/.env
    cp client/.env.example client/.env
  4. Initialize the database

    npm run db:push
    npm run db:seed
  5. Start development servers

    npm run dev
  6. Access the application

Production Deployment (Linux)

For production deployment on Linux servers, use the automated deployment script:

  1. Clone and deploy

    git clone <your-repo-url> dash
    cd dash
    chmod +x scripts/*.sh
    ./scripts/deploy.sh

    The deployment script will:

    • Install Node.js 20 LTS (if needed)
    • Create data directories
    • Generate secure .env files
    • Install dependencies
    • Build client and server
    • Create and start systemd service
  2. Access the application

    http://your-server-ip:3001
    
  3. Manage the service

    sudo systemctl start dash      # Start
    sudo systemctl stop dash       # Stop
    sudo systemctl restart dash    # Restart
    sudo systemctl status dash     # View status
    journalctl -u dash -f          # View logs

Production Deployment (Windows)

  1. Clone the repository

    git clone <your-repo-url> dash
    cd dash
  2. Install dependencies

    npm install
  3. Configure environment

    copy server\.env.example server\.env
    copy client\.env.example client\.env

    Edit server\.env and set a secure JWT_SECRET.

  4. Initialize database

    npm run db:push
    npm run db:seed
  5. Build for production

    npm run build
  6. Run the server

    cd server
    node dist/index.js

    For running as a Windows service, consider using PM2 or NSSM.

Updating an Existing Installation

Linux

./scripts/update.sh [OPTIONS]

Options:

  • --reset - Discard all local changes and update (recommended for production servers)
  • --stash - Automatically stash changes without prompting
  • --help - Show help message

Examples:

# Interactive mode (prompts if there are local changes)
./scripts/update.sh

# Production mode (discards any local modifications)
./scripts/update.sh --reset

# Auto-stash mode (preserves changes, restores after update)
./scripts/update.sh --stash

This will pull latest changes, install dependencies, run migrations, rebuild, and restart the service.

Windows / Manual Update

git pull
npm install
npm run db:push
npm run build
# Restart the server

Backup

Regular backups protect your data. Backups include the SQLite database, uploaded files, and configuration.

What Gets Backed Up

  • data/dash.db or server/prisma/dev.db - SQLite database
  • data/uploads/ - Uploaded files
  • server/.env and client/.env - Configuration files

Windows Backup

Using the batch script:

scripts\backup.bat

Using PowerShell:

.\scripts\backup.ps1

Backups are saved to the backups/ folder with timestamp: dash_backup_YYYYMMDD_HHMMSS.zip

Manual backup:

mkdir backups
powershell Compress-Archive -Path server\prisma\dev.db,server\.env,client\.env -DestinationPath backups\manual_backup.zip

Linux Backup

Create a backup:

./scripts/backup.sh
# Output: data/backups/dash_backup_20240123_120000.tar.gz

Manual backup:

mkdir -p data/backups
tar -czf data/backups/dash_backup_$(date +%Y%m%d_%H%M%S).tar.gz \
    data/dash.db \
    data/uploads \
    server/.env \
    client/.env

Automated Daily Backups (Linux)

# Enable daily backups at 2 AM
./scripts/setup-backup.sh --daily

# With SSH transfer to remote server
./scripts/setup-backup.sh --daily --ssh user@backup-server:/backups/dash

# Check status
./scripts/setup-backup.sh --status

# Disable automated backups
./scripts/setup-backup.sh --disable

Transferring Backups

# Linux to Linux (SCP)
scp data/backups/dash_backup_*.tar.gz user@newmachine:/path/to/dash/

# Windows to Linux (using PowerShell with SSH)
scp backups\dash_backup_*.zip user@linux-server:/path/to/dash/backups/

Restore

Windows Restore

  1. Stop the server if running

  2. Extract the backup

    Expand-Archive -Path backups\dash_backup_YYYYMMDD_HHMMSS.zip -DestinationPath restore_temp
  3. Copy files to their locations

    copy restore_temp\dev.db server\prisma\dev.db
    copy restore_temp\.env server\.env
  4. Restart the server

    cd server
    node dist/index.js

Linux Restore

Using the restore script:

./scripts/restore.sh data/backups/dash_backup_20240123_120000.tar.gz

Restore without overwriting config:

./scripts/restore.sh data/backups/dash_backup_20240123_120000.tar.gz --no-config

Manual restore:

# Stop the service
sudo systemctl stop dash

# Extract backup
tar -xzf data/backups/dash_backup_20240123_120000.tar.gz -C /

# Restart service
sudo systemctl start dash

Migrating to a New Server

  1. On the source machine: Create a fresh backup

    ./scripts/backup.sh
  2. Transfer the backup to the new server

    scp data/backups/dash_backup_*.tar.gz user@newserver:/tmp/
  3. On the new server: Deploy and restore

    # Clone and deploy
    git clone <your-repo-url> dash
    cd dash
    chmod +x scripts/*.sh
    ./scripts/deploy.sh
    
    # Stop service and restore data
    sudo systemctl stop dash
    ./scripts/restore.sh /tmp/dash_backup_*.tar.gz
    sudo systemctl start dash

Configuration Reference

Server Environment Variables (server/.env)

Variable Description Default
PORT Server port 3001
DATABASE_URL SQLite database path file:./prisma/dev.db
JWT_SECRET Secret key for JWT tokens (generate secure random)
NODE_ENV Environment mode development
SMTP_HOST Email server (optional) -
SMTP_PORT Email port (optional) -
SMTP_USER Email username (optional) -
SMTP_PASS Email password (optional) -
SLACK_WEBHOOK_URL Slack notifications (optional) -

Client Environment Variables (client/.env)

Variable Description Default
VITE_API_URL Backend API URL http://localhost:3001

Troubleshooting

Service won't start (Linux)

# Check logs
journalctl -u dash -n 100

# Check if port is in use
sudo lsof -i :3001

# Try running manually
cd /path/to/dash
node server/dist/index.js

Database issues

# Reset database (WARNING: deletes all data)
cd server
rm prisma/dev.db
npx prisma db push
npx prisma db seed

Permission issues (Linux)

sudo chown -R $USER:$USER /path/to/dash

Port already in use

# Find process using port
# Linux:
lsof -i :3001
# Windows:
netstat -ano | findstr :3001

# Kill process (Linux)
kill -9 <PID>
# Kill process (Windows)
taskkill /PID <PID> /F

Additional Resources

About

Robot & 3D Printer Dashboard - Machine management, reservations, and monitoring

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •