A comprehensive real-time vehicle tracking and fleet management system built with modern technologies. This system provides live GPS tracking, driver authentication via RFID, route analytics, and comprehensive fleet management capabilities.
- Live GPS Monitoring: Real-time vehicle location tracking with WebSocket connections
- Interactive Maps: Leaflet-based maps with custom vehicle markers and route visualization
- Multi-vehicle Dashboard: Monitor entire fleet simultaneously with status indicators
- Automatic Session Management: Smart session handling based on GPS and RFID data
- RFID Authentication: Secure driver identification using RFID cards
- Driver Profiles: Complete driver information management
- Session Authorization: Automatic authorized/unauthorized session classification
- Driver Performance Analytics: Individual driver statistics and performance metrics
- Vehicle Registration: Complete vehicle information with ESP32 device mapping
- Fleet Overview: Real-time status of all vehicles in the fleet
- Vehicle Analytics: Individual vehicle performance and usage statistics
- Maintenance Tracking: Vehicle usage data for maintenance scheduling
- Route History: Complete journey replay with speed and location data
- Performance Metrics: Distance, time, and efficiency analytics
- Daily/Weekly/Monthly Reports: Comprehensive reporting system
- Export Capabilities: Data export for external analysis
- Interactive Charts: Beautiful visualizations using Recharts
- ESP32 Integration: Custom firmware for GPS and RFID data collection
- GPS Module Support: High-accuracy GPS tracking with quality indicators
- RFID Reader: MFRC522 RFID module for driver authentication
- Audio Feedback: MP3 player for system status notifications
- Watchdog System: Hardware reliability and auto-recovery
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β ESP32 Device β β Backend API β β React Client β
β β β β β β
β β’ GPS Module βββββΆβ β’ Express.js ββββββ β’ Material-UI β
β β’ RFID Reader β β β’ PostgreSQL β β β’ Leaflet Maps β
β β’ WiFi β β β’ Socket.IO β β β’ Real-time UI β
β β’ Audio Alert β β β’ Sequelize ORM β β β’ Analytics β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- React 19 with TypeScript
- Material-UI v7 for modern UI components
- Leaflet for interactive maps
- Socket.IO Client for real-time communication
- Recharts for data visualization
- Axios for API communication
- Node.js with Express.js
- TypeScript for type safety
- PostgreSQL with Sequelize ORM
- Socket.IO for real-time communication
- Winston for logging
- Helmet & rate limiting for security
- ESP32 microcontroller
- GPS Module (UART communication)
- MFRC522 RFID Reader (SPI communication)
- MP3 Player Module for audio feedback
- Custom C++ firmware with modular design
- Docker Compose for containerization
- PostgreSQL database with optimized indexes
- Environment-based configuration
- Graceful shutdown handling
- Node.js 18+ and npm
- Docker and Docker Compose
- ESP32 development environment (Arduino IDE or PlatformIO)
git clone https://github.com/yourusername/vehicle-tracking.git
cd vehicle-trackingCreate .env file in the root directory:
# Database
DB_HOST=db
DB_PORT=9042
DB_NAME=vehicle_tracking
DB_USER=your_username
DB_PASSWORD=your_password
# Server
PORT=9040
NODE_ENV=development
JWT_SECRET=your_jwt_secret_here
# Client
CLIENT_URL=http://localhost:9041
SOCKET_URL=http://localhost:9040# Start all services
docker-compose up -d
# View logs
docker-compose logs -fcd server
npm install
npm run devcd client
npm install
npm run dev# Create PostgreSQL database
createdb vehicle_tracking
# Database will auto-sync on first run- Open
esp32/main/main.inoin Arduino IDE - Install required libraries:
- TinyGPS++
- MFRC522
- WiFi (ESP32 core)
- Update
SystemConfig.hwith your WiFi credentials and server URL - Flash to ESP32 device
- Navigate to
http://localhost:9041 - Login with admin credentials
- Access different modules:
- Dashboard: Overview of system status
- Live Tracking: Real-time vehicle monitoring
- Analytics: Performance reports and charts
- Drivers: Driver management
- Vehicles: Fleet management
- Route History: Historical journey data
- Power On: Device initializes and connects to WiFi
- GPS Acquisition: Waits for GPS fix (uses default coordinates if no fix)
- RFID Ready: Scans for driver cards continuously
- Data Transmission: Sends GPS data every 5 seconds
- Session Management: Automatically manages driving sessions
- Register drivers in the web dashboard
- Associate RFID card IDs with driver profiles
- Cards are automatically recognized when scanned
Modify esp32/main/SystemConfig.h:
// WiFi Settings
const char* WIFI_SSID = "YourWiFiNetwork";
const char* WIFI_PASSWORD = "YourPassword";
// Server Settings
const char* SERVER_URL = "http://your-server.com/api/device/gps-data";
// Timing Settings
const unsigned long SEND_INTERVAL_MS = 5000; // GPS data interval
const unsigned long RFID_DEBOUNCE_MS = 1000; // RFID scan intervalPOST /api/device/gps-data
Content-Type: application/json
{
"deviceId": "ESP32-001",
"latitude": 41.0082,
"longitude": 28.9784,
"speed": 45.5,
"heading": 180.0,
"accuracy": 3.5,
"rfidCardId": "A1B2C3D4" // Optional
}GET /api/drivers- List all driversPOST /api/drivers- Create new driverGET /api/vehicles- List all vehiclesPOST /api/vehicles- Register new vehicleGET /api/analytics/sessions- Get session historyGET /api/analytics/daily-stats- Get daily statistics
locationUpdate- Real-time GPS updatessessionStarted- New session notificationssessionEnded- Session completiondriverChanged- Driver change events
- drivers: Driver information and RFID mapping
- vehicles: Vehicle registration with ESP32 device IDs
- driving_sessions: Trip sessions with start/end times
- location_logs: GPS coordinate history with timestamps
drivers 1:N driving_sessions
vehicles 1:N driving_sessions
driving_sessions 1:N location_logsvehicle-tracking/
βββ server/ # Backend API
β βββ src/
β β βββ controllers/ # Route handlers
β β βββ models/ # Database models
β β βββ routes/ # API routes
β β βββ services/ # Business logic
β β βββ config/ # Configuration files
β βββ package.json
βββ client/ # Frontend React app
β βββ src/
β β βββ components/ # Reusable components
β β βββ pages/ # Page components
β β βββ services/ # API services
β β βββ types/ # TypeScript types
β βββ package.json
βββ esp32/ # Hardware firmware
β βββ main/ # Arduino sketch files
βββ docker-compose.yml # Container orchestration
βββ README.md
# Backend development
cd server && npm run dev
# Frontend development
cd client && npm run dev
# Build for production
npm run build
# Database migrations
npm run db:migrate
# Run tests
npm test- Backend: Add routes in
server/src/routes/ - Frontend: Create components in
client/src/components/ - Hardware: Extend modules in
esp32/main/ - Database: Update models in
server/src/models/
- Rate Limiting: API endpoint protection
- Input Sanitization: SQL injection prevention
- CORS Configuration: Cross-origin request security
- Security Headers: Helmet.js implementation
- Authentication: JWT-based auth system
- Request Validation: Express-validator middleware
- Database Indexing: Optimized queries for location data
- Real-time Updates: Efficient WebSocket implementation
- Memory Management: ESP32 watchdog and cleanup
- Caching: Strategic data caching for analytics
- Lazy Loading: Component-based code splitting
- Server: Winston-based structured logging
- ESP32: Serial output with debug levels
- Client: Browser console with error boundaries
/healthendpoint for server status- ESP32 system health reporting
- Database connection monitoring
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- ESLint configuration for TypeScript
- Prettier for code formatting
- Conventional commits preferred
- Check WiFi credentials in
SystemConfig.h - Verify server URL accessibility
- Check serial monitor for error messages
- Verify PostgreSQL is running
- Check database credentials in
.env - Ensure database exists
- Check WebSocket connection in browser dev tools
- Verify server Socket.IO configuration
- Check firewall settings
- Verify GPS module wiring
- Check for clear sky view
- Monitor serial output for GPS data
For issues and questions:
- Check existing GitHub Issues
- Create new issue with detailed description
- Include logs and system information
- Mobile app for drivers
- Geofencing and alerts
- Advanced analytics with AI
- Multi-tenant support
- Advanced reporting system
- Integration with third-party APIs
- 4G/LTE module support
- OBD-II integration
- Fuel consumption tracking
- Temperature sensors
- Camera integration