A comprehensive robot fleet management system built with NestJS backend and Next.js frontend, featuring real-time WebSocket communication, MongoDB storage, and Docker deployment.
This project demonstrates a modern, scalable architecture for IoT device management, specifically designed for robotic fleets. It showcases real-time communication, data persistence, and containerized deployment patterns commonly used in enterprise applications.
- ๐ค Real-time Robot Fleet Management - Monitor and control multiple robots simultaneously
- ๐ Live Dashboard - Interactive dashboard with real-time updates and statistics
- ๐ WebSocket Communication - Bidirectional communication for instant updates
- ๐ฑ Responsive Web Interface - Modern React-based frontend with Next.js
- ๐๏ธ MongoDB Integration - Scalable document database for robot data
- ๐ณ Docker Containerization - Easy deployment and scaling
- ๐ API Documentation - Comprehensive Swagger/OpenAPI documentation
- ๐ UUID-based Security - Non-predictable robot IDs for enhanced security
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Frontend โ โ Backend โ โ Database โ
โ (Next.js) โโโโโบโ (NestJS) โโโโโบโ (MongoDB) โ
โ โ โ โ โ โ
โ โข Dashboard โ โ โข REST API โ โ โข Robot Data โ
โ โข Robot Control โ โ โข WebSocket โ โ โข Historical โ
โ โข Real-time UI โ โ โข Authentication โ โ โข Logs โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- Framework: NestJS with TypeScript
- Database: MongoDB with Mongoose ODM
- WebSockets: Socket.IO for real-time communication
- API Documentation: Swagger/OpenAPI
- Validation: Class-validator and class-transformer
- Testing: Jest for unit and integration tests
- Framework: Next.js 14 with React 18
- Language: TypeScript for type safety
- Styling: CSS Modules and styled-components
- WebSocket Client: Socket.IO client
- State Management: React hooks and context
- Database: MongoDB 8.0
- Caching: Redis (optional for scaling)
- Containerization: Docker and Docker Compose
- Load Balancing: Nginx (optional)
- Monitoring: Prometheus and Grafana (optional)
# Make the script executable and run it
chmod +x quick-start.sh
./quick-start.shThe script will guide you through:
- Development Mode - Local backend + frontend (requires MongoDB)
- Docker Mode - Everything in containers
- Hybrid Mode - Backend in Docker, frontend local
# Open terminal and navigate to backend
cd path-to-project/robotic-dashboard/src/backend
# Install dependencies
npm install
# Create environment file (if not exists)
cp .env.example .env
# Edit .env file and set your MongoDB URI
# MONGODB_URI=mongodb://localhost:27017/robot-dashboard
# Seed database with sample robots
npm run seed
# Start backend in development mode
npm run start:devโ
Backend running at: http://localhost:8080
# Open NEW terminal and navigate to frontend
cd /Users/thinhhd/working/WeenSpace/robotic-dashboard/src/frontend
# Install dependencies
npm install
# Install WebSocket client
npm install socket.io-client@^4.8.1
# Create frontend environment configuration
cp .env.example .env.local
# Start frontend in development mode
npm run devโ
Frontend running at: http://localhost:3000
- Backend Health: http://localhost:8080/health
- API Documentation: http://localhost:8080/api/v1/docs
- WebSocket Test: http://localhost:8080/websocket/test
- Frontend Dashboard: http://localhost:3000/dashboard
# Navigate to project root
cd path-to-project/robotic-dashboard
# Start all services with Docker
docker compose up --build
# Or run in background
docker compose up -d --buildServices will be available at:
- Frontend: http://localhost:3000
- Backend: http://localhost:8080
- MongoDB:
localhost:27017
cd src/backend
# Build for production
npm run build
# Start production server
npm run start:prodcd src/frontend
# Build for production
npm run build
# Start production server
npm run start# 1. Clone repository
git clone <repository-url>
cd robotic-dashboard
# 2. Backend setup
cd src/backend
npm install
cp .env.example .env
# Edit .env with your MongoDB URI
npm run seed
npm run start:dev
# 3. Frontend setup (in new terminal)
cd src/frontend
npm install
npm install socket.io-client@^4.8.1
cp .env.example .env.local
npm run dev
# 4. Open in browser
# Frontend: http://localhost:3000
# Backend API: http://localhost:8080/api/v1/docs# Terminal 1: Backend
cd src/backend
npm run start:dev
# Terminal 2: Frontend
cd src/frontend
npm run dev
# Terminal 3: Database operations (optional)
cd src/backend
npm run seed # Reseed database
npm run db:clean # Clean database
npm run simulator # Start robot simulator# Kill processes on ports
sudo lsof -ti:3000 | xargs kill -9 # Frontend
sudo lsof -ti:8080 | xargs kill -9 # Backend
sudo lsof -ti:27017 | xargs kill -9 # MongoDB# Stop all services
docker compose down -v
# Clean everything
rm -rf src/backend/node_modules src/frontend/node_modules
docker system prune -f
# Fresh install
cd src/backend && npm install
cd ../frontend && npm install
# Start development
cd src/backend && npm run start:dev &
cd src/frontend && npm run dev# Check backend
curl http://localhost:8080/health
# Check frontend
curl http://localhost:3000
# Check WebSocket
curl http://localhost:8080/websocket/test# Use the orchestrated startup script for step-by-step service startup
chmod +x start-orchestrated.sh
./start-orchestrated.sh# Build and start all services
docker compose up --build
# Or run in background
docker compose up -d --build# Start only backend services
docker compose up -d mongodb redis backend
# Start only frontend
docker compose up -d frontend
# View logs
docker compose logs -f backend
docker compose logs -f frontend
# Stop all services
docker compose down- Frontend: http://localhost:3000
- Backend: http://localhost:8080
- MongoDB: localhost:27017
- Redis: localhost:6379
cd src/backend
# Development
npm run start:dev # Start with hot reload
npm run start:debug # Start with debugging
npm run start:prod # Start production build
# Database
npm run seed # Seed with 200 robots
npm run seed:advanced # Seed with 7 days history (5,600 records)
npm run db:clean # Clean database
npm run db:reset # Clean + seed
# Utilities
npm run simulator # Start robot simulator
npm run build # Build for production
npm run lint # Lint code
npm run test # Run testscd src/frontend
# Development
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Lint code# Development
docker compose up --build # Build and start all
docker compose up -d # Start in background
docker compose down # Stop all services
docker compose logs -f # Follow logs
# Production
docker compose -f docker-compose.prod.yml up -d
# Cleanup
docker compose down -v # Remove volumes
docker system prune -f # Clean unused images| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:3000 | React dashboard |
| Backend API | http://localhost:8080 | NestJS REST API |
| API Docs | http://localhost:8080/api/v1/docs | Swagger documentation |
| WebSocket | ws://localhost:8080/socket.io | Socket.IO endpoint |
| Dashboard WebSocket | ws://localhost:8080/dashboard | Dashboard namespace |
| Health Check | http://localhost:8080/health | Service health |
| MongoDB | mongodb://localhost:27017 | Database |
| Service | URL | Description |
|---|---|---|
| Frontend | http://localhost:3000 | Dockerized frontend |
| Backend | http://localhost:8080 | Dockerized backend |
| MongoDB | localhost:27017 | Dockerized database |
| Redis | localhost:6379 | Dockerized cache |
# Server
NODE_ENV=development
PORT=8080
# Database
MONGODB_URI=mongodb://localhost:27017/robot-dashboard
# CORS
CORS_ORIGIN=http://localhost:3000
# WebSocket
WEBSOCKET_PORT=8080
# Seeding
SEED_ON_START=true# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:8080
# WebSocket Configuration
NEXT_PUBLIC_WS_URL=http://localhost:8080
NEXT_PUBLIC_WS_DASHBOARD_URL=http://localhost:8080/dashboard
NEXT_PUBLIC_WS_ROBOT_URL=http://localhost:8080Backend Implementation:
- REST API with NestJS and TypeScript
- MongoDB integration with Mongoose ODM
- WebSocket real-time communication (Socket.IO)
- JWT authentication and authorization
- Health check endpoints
- Database seeding with sample data
- API documentation with Swagger
- Docker containerization
- Environment configuration management
Frontend Implementation:
- Next.js 14 with React 18 and TypeScript
- Responsive dashboard interface
- Real-time robot status monitoring
- Individual robot detail pages
- WebSocket integration for live updates
- Interactive data visualization
- Mobile-friendly responsive design
- Component-based architecture
Infrastructure:
- Docker Compose multi-service setup
- Service health checks and dependencies
- MongoDB and Redis containers
- Automated database seeding
- Development and production environments
Real-time Enhancements:
- Advanced WebSocket event handling
- Real-time dashboard metrics
- Live robot telemetry streaming
- Performance monitoring dashboards
User Interface Improvements:
- Enhanced robot control interface
- Advanced data filtering and search
- Custom dashboard layouts
- Notification system implementation
Backend Optimizations:
- Rate limiting implementation
- Advanced error handling
- Logging system enhancement
- Database query optimization
Authentication & Security:
- User role-based access control
- Two-factor authentication (2FA)
- Session management improvements
- Security audit and penetration testing
Advanced Functionality:
- Multi-robot fleet management
- Task scheduling and automation
- Historical data analytics
- Predictive maintenance alerts
- Data export (CSV, PDF, JSON)
- Advanced reporting system
Mobile & Performance:
- Progressive Web App (PWA) features
- Mobile application development
- Performance optimization
- Caching strategies implementation
- Code splitting and lazy loading
Testing & Quality:
- Comprehensive unit test suite
- Integration testing framework
- End-to-end testing with Cypress
- Load testing and performance benchmarks
- Code coverage reporting
DevOps & Deployment:
- CI/CD pipeline setup
- Kubernetes deployment configuration
- Monitoring with Prometheus and Grafana
- Automated backup systems
- Production logging and alerting
- โ REST API with NestJS - Complete CRUD operations for robots
- โ MongoDB Integration - Mongoose ODM with robot data models
- โ
WebSocket Gateways - Real-time communication with Socket.IO
- โ Robot Gateway (default namespace)
- โ Dashboard Gateway (/dashboard namespace)
- โ Health Check Endpoints - Service monitoring and status
- โ
Swagger API Documentation - Complete API documentation at
/api/v1/docs - โ
Database Seeding - Automatic population with sample data
- โ Basic seeding (200 robots)
- โ Advanced seeding (7 days historical data, 5,600 records)
- โ Environment Configuration - Flexible configuration management
- โ UUID-based Robot IDs - Secure, non-predictable identifiers
- โ CORS Configuration - Frontend-backend communication
- โ Docker Support - Containerized deployment
- โ Service Dependencies - Robust startup with health checks
- โ Robot Fleet Dashboard - Main dashboard with fleet overview
- โ Individual Robot Pages - Detailed robot information and control
- โ
Real-time WebSocket Integration - Live updates from backend
- โ Robot-specific WebSocket connections
- โ Dashboard-wide WebSocket updates
- โ WebSocket Status Indicators - Connection status display
- โ Responsive Design - Mobile-friendly interface
- โ TypeScript Implementation - Type-safe development
- โ Environment Configuration - Configurable API and WebSocket URLs
- โ Error Handling - Graceful error states and fallbacks
- โ Loading States - User feedback during data fetching
- โ Docker Compose Setup - Multi-service orchestration
- โ MongoDB Container - Persistent database storage
- โ Redis Container - Caching and pub/sub support
- โ Service Health Checks - Automatic service monitoring
- โ Orchestrated Startup Scripts - Step-by-step service initialization
- โ Development Scripts - Quick setup and testing utilities
- โ WebSocket Testing Tools - Automated connection testing
- โ Environment Management - Development/production configurations
- ๐ Authentication & Authorization - JWT-based user authentication
- ๐ Rate Limiting - API request throttling
- ๐ Logging System - Structured logging with Winston
- ๐ Performance Monitoring - Response time and error tracking
- ๐ Robot Control Interface - Direct robot command sending
- ๐ Historical Data Visualization - Charts and graphs for robot metrics
- ๐ Real-time Notifications - Toast notifications for events
- ๐ Advanced Filtering - Filter robots by status, location, etc.
- ๐ Production Docker Setup - Optimized production configurations
- ๐ Load Balancing - Nginx configuration for scaling
- ๐ User Management System - Multi-user support with roles
- ๐ Robot Command Queue - Queued command execution
- ๐ Data Analytics API - Statistical analysis endpoints
- ๐ File Upload System - Robot firmware and configuration uploads
- ๐ Backup & Recovery - Automated database backups
- ๐ API Versioning - Multiple API versions support
- ๐ Webhook System - External system integrations
- ๐ Robot Simulation API - Virtual robot testing
- ๐ Geolocation Tracking - GPS-based robot positioning
- ๐ Alert System - Automated notifications for critical events
- ๐ User Authentication UI - Login/logout interface
- ๐ Dashboard Customization - User-configurable dashboard layouts
- ๐ Robot Map View - Geographical robot positioning
- ๐ Advanced Charts - Interactive data visualizations
- ๐ Dark/Light Theme - User preference themes
- ๐ Mobile App - React Native mobile application
- ๐ Offline Support - PWA with offline capabilities
- ๐ Export Functionality - Data export to CSV/PDF
- ๐ Real-time Chat - Communication between operators
- ๐ Robot Scheduling - Task scheduling interface
- ๐ Machine Learning Integration - Predictive maintenance
- ๐ Video Streaming - Live camera feeds from robots
- ๐ Voice Commands - Voice control interface
- ๐ AR/VR Interface - Immersive robot control
- ๐ Multi-Language Support - Internationalization (i18n)
- ๐ Plugin System - Extensible architecture
- ๐ Edge Computing - Distributed processing capabilities
- ๐ Kubernetes Deployment - Container orchestration
- ๐ CI/CD Pipeline - Automated testing and deployment
- ๐ Monitoring & Alerting - Prometheus + Grafana setup
- ๐ Security Scanning - Automated vulnerability assessment
- ๐ Performance Testing - Load testing and optimization
- ๐ Multi-Environment Support - Dev/Staging/Production pipelines
- ๐ Auto-scaling - Dynamic resource allocation
- ๐ SSL/TLS Configuration - Secure communications
- ๐ Database Clustering - High availability MongoDB setup
- ๐ CDN Integration - Global content delivery
-
๐ Priority 1: Authentication System
- JWT implementation
- User roles and permissions
- Protected routes
-
๐ Priority 2: Real-time Robot Control
- Command interface
- Live robot status updates
- Command feedback system
-
๐ Priority 3: Data Visualization
- Historical charts
- Performance metrics
- Fleet analytics
| Category | Completed | In Progress | Planned | Total |
|---|---|---|---|---|
| Backend | 8 | 4 | 10 | 22 |
| Frontend | 8 | 4 | 10 | 22 |
| Infrastructure | 8 | 2 | 10 | 20 |
| Total | 24 | 10 | 30 | 64 |
Overall Progress: 37.5% Complete ๐
- ๐ฑ Real-time Robot Fleet Overview
- ๐ Live Statistics (Online, Offline, Maintenance, Charging)
- ๐ค Individual Robot Details
- ๐ Historical Data Visualization
- ๐ฎ Remote Robot Control
- ๐ Real-time Notifications
- ๐ WebSocket Status Indicators
- โก WebSocket Real-time Communication
- ๐๏ธ MongoDB with Mongoose ODM
- ๐ณ Docker Containerization with Service Dependencies
- ๐ Swagger API Documentation
- ๐ UUID-based Robot IDs
- ๐งช Health Check Endpoints
- ๐ Database Seeding Tools
- ๐ Automatic Database Seeding on First Startup
cd src/backend
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:cov
# Test WebSocket
node test-websocket.js
# Test Dashboard WebSocket
node test-dashboard-websocket.js# Health check
curl http://localhost:8080/health
# Get robots
curl http://localhost:8080/robots
# Get specific robot
curl http://localhost:8080/robots/{robot-id}
# Create robot
curl -X POST http://localhost:8080/robots \
-H "Content-Type: application/json" \
-d '{"status":"online","battery":85}'# Test robot WebSocket
chmod +x test-websocket.js
node test-websocket.js
# Test dashboard WebSocket
chmod +x test-dashboard-websocket.js
node test-dashboard-websocket.js
# Test Docker build
chmod +x test-docker-fix.sh
./test-docker-fix.sh# Check MongoDB is running
mongosh --eval "db.adminCommand('ismaster')"
# Start MongoDB
mongod --config /usr/local/etc/mongod.conf
# Check Docker MongoDB
docker compose logs mongodb# Kill process using port 8080
lsof -ti:8080 | xargs kill -9
# Kill process using port 3000
lsof -ti:3000 | xargs kill -9# Test WebSocket endpoint
curl http://localhost:8080/websocket/test
# Check backend logs
docker compose logs -f backend
# Test WebSocket connections
node test-websocket.js
node test-dashboard-websocket.js# Clean Docker cache
docker system prune -a -f
# Rebuild without cache
docker compose build --no-cache
# Check container logs
docker compose logs backend
docker compose logs frontend
# Test specific fix
./test-docker-fix.sh# Stop all services
docker compose down -v
# Clean Docker
docker system prune -a -f
# Remove node_modules
rm -rf src/backend/node_modules src/frontend/node_modules
# Fresh install
cd src/backend && npm install
cd ../frontend && npm install
# Start fresh
docker compose up --build# Use orchestrated startup
./start-orchestrated.sh
# Check service health
docker compose ps
# Wait for specific services
./wait-for-services.sh mongodb:mongodb:27017 redis:redis:6379robotic-dashboard/
โโโ src/
โ โโโ backend/ # NestJS API server and Websocket server
โ โ โโโ src/
โ โ โ โโโ app.module.ts
โ โ โ โโโ main.ts
โ โ โ โโโ controllers/
โ โ โ โโโ infrastructure/
โ โ โ โ โโโ socket/
โ โ โ โ โโโ gateways/
โ โ โ โ โโโ robot.gateway.ts
โ โ โ โ โโโ dashboard.gateway.ts
โ โ โ โโโ config/
โ โ โโโ package.json
โ โ โโโ Dockerfile
โ โ โโโ docker-entrypoint-simple.sh
โ โโโ frontend/ # Next.js dashboard
โ โโโ src/
โ โ โโโ app/
โ โ โ โโโ dashboard/
โ โ โ โโโ robot/
โ โ โโโ config/
โ โ โ โโโ api.config.ts
โ โ โ โโโ websocket.config.ts
โ โ โโโ hooks/
โ โ โโโ useRobotWebSocket.ts
โ โโโ package.json
โ โโโ Dockerfile
โโโ docker-compose.yml # Docker services with dependencies
โโโ start-orchestrated.sh # Orchestrated startup script
โโโ wait-for-services.sh # Service dependency helper
โโโ quick-start.sh # Quick setup script
โโโ test-websocket.js # Robot WebSocket test
โโโ test-dashboard-websocket.js # Dashboard WebSocket test
โโโ test-docker-fix.sh # Docker build test
โโโ README.md
# Build images
docker compose -f build
# Start stack
docker compose -f up -d
# Monitor
docker compose -f logs -fUpdate production environment variables in:
src/backend/.env.productionsrc/frontend/.env.production
- Set
SEED_ON_START=falsein production - Configure proper MongoDB authentication
- Use environment-specific WebSocket URLs
- Enable Redis for scaling
- Configure Nginx for load balancing
Once the backend is running, visit: http://localhost:8080/api/v1/docs
- Robot Gateway:
ws://localhost:8080(default namespace) - Dashboard Gateway:
ws://localhost:8080/dashboard
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly with provided test scripts
- Submit a pull request
MIT License - see LICENSE file for details.