A comprehensive energy management system with secure lecturer authentication and IoT board integration.
- ๐ Simple Authentication: JWT-based authentication for user management
- ๐ CoreAPI Integration: Manages IoT boards and energy data
- โก Real-time Monitoring: Track power generation and consumption
- ๐ฎ Game Management: Control rounds and scoring for educational purposes
- ๐ฑ Mobile Friendly: Responsive design for all devices
- Frontend: Angular 17 application
- CoreAPI: Flask-based API for IoT board management with simple authentication
- Reverse Proxy: Nginx for routing and CORS handling
The system includes predefined user accounts for testing:
- lecturer1 / lecturer123 (Dr. John Smith, Computer Science)
- lecturer2 / lecturer456 (Prof. Maria Garcia, Physics)
- board1 / board123 (Solar Panel Board #1)
- board2 / board456 (Wind Turbine Board #2)
- board3 / board789 (Battery Storage Board #3)
-
Start all services:
docker-compose up --build -d
-
Visit: http://localhost (users are created automatically on first start)
-
Start services:
docker-compose up --build
-
Test with simulation:
python3 esp32_board_simulation.py
For debugging with detailed logs and hot reloading:
-
Start services in debug mode:
docker-compose -f docker-compose.debug.yml up --build
-
Debug mode features:
- Frontend hot reloading enabled
- Detailed logging in CoreAPI (DEBUG=true)
- Source maps for easier debugging
- Development server ports exposed
-
Toggle debug logging in production:
# Edit docker-compose.yml and change: # - DEBUG=false # Set to 'true' for verbose logging # to: # - DEBUG=true # Enable verbose logging # Then restart: docker-compose down && docker-compose up --build -d
-
Debug mode logging includes:
- Game statistics and round details
- Authentication attempts (including passwords)
- Binary protocol data exchanges
- Detailed error traces
-
Stop all services:
docker-compose down
-
Remove CoreAPI image and cache:
docker rmi webcontrol-coreapi-1 || true docker builder prune -f
-
Rebuild and start with fresh cache:
docker-compose up --build --force-recreate
If you're still seeing old code after changes:
# Nuclear option - removes ALL Docker cache
docker-compose down
docker system prune -a -f
docker-compose up --build# After making changes to CoreAPI code:
docker-compose down
docker rmi webcontrol-coreapi-1
docker-compose up --buildThe project includes a Python script for testing:
esp32_board_simulation.py- Simulates multiple ESP32 boards using the binary protocol
# Test with board simulation
python3 esp32_board_simulation.py
# Test CoreAPI health
curl http://localhost/coreapi/health
# Test with authentication
curl -X POST http://localhost/coreapi/login \
-H "Content-Type: application/json" \
-d '{"username": "lecturer1", "password": "lecturer123"}'WebControl/
โโโ CoreAPI/ # Flask-based API backend
โโโ frontend/ # Angular frontend application
โโโ docker-compose.yml # Docker setup for production
โโโ docker-compose.debug.yml # Docker setup for debug mode
โโโ nginx.conf # Nginx configuration
โโโ esp32_board_simulation.py # Multi-board simulation
See COREAPI_INTEGRATION.md for detailed API documentation.
ESP32 devices can use an optimized binary protocol. See ESP32_BINARY_PROTOCOL.md for details.
The system is designed for educational energy management games where:
- Lecturers can control game rounds and monitor all boards
- IoT boards (ESP32) can register and submit power data
- Real-time dashboard shows power generation/consumption
- Simple JWT-based authentication
- CORS properly configured for frontend integration
- Board endpoints are public for ESP32 device access
- User endpoints require authentication
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
For issues and questions, please use the GitHub issue tracker. โ โ โโโ dashboard/ # Protected dashboard โ โโโ package.json โโโ CoreAPI/ โโโ Dockerfile โโโ src/ โ โโโ main.py # Flask application โ โโโ state.py # Game state management โ โโโ simple_auth.py # Simple JWT authentication โโโ requirements.txt
## Troubleshooting
### Users Not Created
If users are not created automatically:
1. Check CoreAPI logs: `docker-compose logs coreapi`
2. Ensure the database file is writable
3. Restart the CoreAPI service: `docker-compose restart coreapi`
### CoreAPI Authentication Issues
1. Verify CoreAPI is running: `curl http://localhost/coreapi/health`
2. Check nginx routing: `docker-compose logs nginx`
3. Test with proper authentication headers
### CoreAPI Code Changes Not Reflected
**This is the most common issue!**
1. **Stop services:**
```bash
docker-compose down
-
Remove CoreAPI image:
docker rmi webcontrol-coreapi-1
-
Rebuild:
docker-compose up --build
- For debug mode: Changes should auto-reload
- For production mode: Rebuild frontend container:
docker-compose down docker rmi webcontrol-nginx-1 docker-compose up --build
# View all logs
docker-compose logs
# View specific service logs
docker-compose logs coreapi
docker-compose logs nginx
# Follow logs in real-time
docker-compose logs -f coreapiThis application uses simple JWT authentication with a Flask-based IoT management system for educational energy monitoring scenarios.