A web-based elevator simulation system with intelligent scheduling algorithms that efficiently handle passenger requests while prioritizing user experience. This frontend application provides real-time visualization and control of a multi-elevator system serving multiple floors.
- Elevator Status Display: Real-time positions, movement directions (↑/↓/idle), door states, and passenger counts
- Floor Request Visualization: Visual indicators for up/down button requests on each floor
- Destination Requests: Internal elevator destination requests display
- Interactive Building Layout: Responsive visualization of the entire building structure
- System Control: Start, stop, and reset simulation with real-time status feedback
- Configuration Management: Adjust number of elevators, floors, elevator capacity, and request frequency
- Speed Controls: Real-time simulation speed adjustment
- Request Generation: Manual request addition and random request generation with configurable parameters
- Stress Testing: Generate high-volume requests to test system performance
- Manual Request Addition: Add specific origin-to-destination floor requests
- Random Request Generation: Configurable batch request generation
- Request Tracking: Real-time monitoring of pending, active, and completed requests
- Priority Management: Built-in priority escalation for long-waiting requests
- Live Statistics: Average/maximum wait times, completion rates, elevator utilization
- Real-time Metrics: Total requests, completed requests, pending requests
- Connection Status: WebSocket connection monitoring with error handling
- Performance Indicators: Visual feedback on system performance
- Event Logging: Detailed logging of all system events with timestamps
- Debounced Updates: Optimized log updates to prevent UI performance issues
- Event Categories: System initialization, request handling, elevator movements, errors
- Real-time Log Display: Live log viewer with scrollable history
- Framework: Next.js 15.4.5 with TypeScript
- UI Library: React 19.1.0
- State Management: Zustand with shallow subscriptions
- Real-time Communication: Socket.io client
- Styling: Tailwind CSS with shadcn/ui components
- Icons: Lucide React
- Build Tool: Turbopack for development
- Node.js 18+
- npm, yarn, pnpm, or bun package manager
- Clone the repository and navigate to the frontend directory:
cd frontend- Install dependencies:
npm install
# or
yarn install
# or
pnpm install
# or
bun install- Configure environment variables:
Create a
.env.localfile in the root directory:
NEXT_PUBLIC_BACKEND_URL=http://localhost:8000- Start the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev- Open http://localhost:3000 in your browser
This frontend application connects to a backend simulation engine via WebSocket. Ensure the backend server is running on the configured URL (default: http://localhost:8000).
- Configure the system parameters (number of elevators, floors, capacity)
- Click "Start Simulation" to begin the elevator system
- Monitor real-time statistics and elevator movements
- Manual Requests: Use the "Add Request" form to specify origin and destination floors
- Stress Testing: Use the stress test feature to generate high-volume requests
- View real-time statistics in the dashboard header
- Monitor elevator utilization and wait times
- Check the simulation logs for detailed event history
- Watch connection status for backend communication
The application uses Zustand for global state management with optimized subscriptions:
SystemState: Complete simulation state including elevators, requests, and configurationConnectionStatus: WebSocket connection state and error handlingLogs: Real-time event logging with debounced updates
- WebSocket connection to backend simulation engine
- Event-driven updates for system state, logs, and statistics
- Automatic reconnection and error handling
- Debounced log updates for performance optimization
- BuildingVisualization: Main elevator system display
- SimulationControls: Interactive control panel
- SimulationLogs: Real-time event logging
- ElevatorSystem: Core elevator visualization logic
- FloorButton: Individual floor request buttons
useElevatorSystem: Main system hook with WebSocket managementuseElevatorState: Selective elevator state subscriptionuseSystemState: Global system state accessuseConnectionStatus: Connection monitoring
NEXT_PUBLIC_BACKEND_URL: Backend WebSocket server URL (default: http://localhost:8000)
- Development uses Turbopack for faster builds
- Production builds are optimized with Next.js build system
- WebSocket connection automatically adapts to environment
- Shallow state subscriptions to prevent unnecessary re-renders
- Debounced log updates to maintain UI responsiveness
- Efficient elevator state management with selective updates
- WebSocket-based real-time updates
- Automatic connection recovery
- Error handling with user feedback
- Performance monitoring and statistics
- Configurable elevator and floor counts
- Stress testing capabilities
- Efficient state management for large systems
- Optimized component rendering