A comprehensive smart battery swapping station system built with modern web technologies, featuring real-time MQTT communication, IoT integration, and administrative dashboards.
The BSS Management System is designed to automate and monitor electric vehicle battery swapping operations. It provides a complete solution for station management, user authentication, battery health monitoring, and swap activity tracking.
- Backend API: Flask-based REST API with MySQL database
- Admin Dashboard: React-based admin interface for system management
- Frontend Dashboard: User-facing interface for battery swap operations
- MQTT Communication: Real-time IoT communication for station hardware
- Simulated Hardware: Testing tools for development and demonstration
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ Admin Panel โ โ Frontend Dash โ โ MQTT Devices โ
โ (React/TS) โ โ (React/TS) โ โ (Python) โ
โโโโโโโโโโโฌโโโโโโโโ โโโโโโโโโโโฌโโโโโโโโ โโโโโโโโโโโฌโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โ Backend API โ
โ (Flask + SQLAlchemy) โ
โ + SocketIO + MQTT โ
โโโโโโโโโโโโโโฌโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โ MySQL Database โ
โ (Users, Batteries, โ
โ Stations, Swaps) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ
bss/
โโโ AdminBoard/ # Admin Dashboard (React + TypeScript)
โ โโโ src/
โ โ โโโ pages/ # Dashboard pages
โ โ โโโ components/ # Reusable UI components
โ โ โโโ hooks/ # Custom React hooks
โ โ โโโ context/ # React context providers
โ โ โโโ utils/ # Utility functions
โ โโโ package.json
โโโ frontendDashboard/ # User Dashboard (React + TypeScript)
โ โโโ src/
โ โ โโโ components/ # UI components
โ โ โโโ types/ # TypeScript type definitions
โ โ โโโ Hooks/ # Custom hooks
โ โโโ package.json
โโโ backend/ # Flask API Server
โ โโโ routes/ # API route handlers
โ โโโ mqtt/ # MQTT communication handlers
โ โโโ models.py # Database models
โ โโโ app.py # Main Flask application
โ โโโ requirements.txt
โโโ mqtt_comm/ # MQTT simulation tools
โโโ bss_simulated_card.py # RFID card simulator
- Flask - Web framework
- SQLAlchemy - ORM for database operations
- Flask-SocketIO - Real-time WebSocket communication
- paho-mqtt - MQTT client for IoT communication
- MySQL - Primary database
- eventlet - Asynchronous networking
- React 18 - UI framework
- TypeScript - Type-safe JavaScript
- Vite - Build tool and dev server
- TailwindCSS - Utility-first CSS framework
- Framer Motion - Animation library
- React Query - Data fetching and caching
- Axios - HTTP client
- ESLint - Code linting
- PostCSS - CSS processing
- Lucide React - Icon library
- Node.js 18+ and npm
- Python 3.8+
- MySQL 8.0+
- Git
git clone https://github.com/iness000/bss.git
cd bss# Create MySQL database
mysql -u root -p
CREATE DATABASE bss_db;cd backend
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your MySQL credentials
# Run the Flask application
python app.pyThe backend will start on http://localhost:5000
cd AdminBoard
npm install
npm run devThe admin dashboard will start on http://localhost:5173
cd frontendDashboard
npm install
npm run devThe user dashboard will start on http://localhost:5174
cd mqtt_comm
python bss_simulated_card.py- User Management - Create, update, and manage user accounts
- Battery Management - Monitor battery health, status, and assignments
- Station Management - Configure and monitor swap stations
- Swap Activity Monitoring - Track all battery swap transactions
- Real-time Analytics - Live system statistics and health metrics
- Weather Integration - Real-time weather data display
- Battery Swap Flow - Step-by-step swap process guidance
- RFID Authentication - Secure user authentication via RFID cards
- Battery Health Monitoring - Real-time battery status information
- Session Management - Complete swap session tracking
- RESTful APIs - Comprehensive CRUD operations
- Real-time Communication - WebSocket support for live updates
- MQTT Integration - IoT device communication
- Authentication - Secure user authentication system
- Health Monitoring - Battery and system health tracking
GET /api/users- List all usersPOST /api/users- Create new userPUT /api/users/{id}- Update userDELETE /api/users/{id}- Delete user
GET /api/batteries- List all batteriesPOST /api/batteries- Add new batteryPUT /api/batteries/{id}- Update batteryGET /api/batteries/{id}/health-logs- Battery health history
GET /api/stations- List all stationsPOST /api/stations- Create new stationGET /api/stations/{id}/batteries- Station batteries
GET /api/swaps- List all swapsPOST /api/swaps- Create new swap recordPUT /api/swaps/{id}- Update swap record
The system uses MQTT for real-time communication with IoT devices:
bss/{station_id}/auth/request- RFID authentication requestsbss/{station_id}/auth/response- Authentication responsesbss/{station_id}/swap/initiate- Battery swap initiationbss/{station_id}/swap/result- Swap completion resultsbss/{station_id}/swap/refused- Swap refusal notifications
{
"user_id": 123,
"battery_in_id": "BAT001",
"battery_out_id": "BAT002",
"timestamp": "2025-07-14T10:30:00Z",
"station_id": 1,
"status": "success"
}# Backend tests
cd backend
python -m pytest
# Frontend tests
cd AdminBoard
npm test
cd frontendDashboard
npm testUse the provided simulator to test MQTT communication:
cd mqtt_comm
python bss_simulated_card.py- Responsive Design - Works on desktop, tablet, and mobile
- Real-time Updates - Live data refresh via WebSockets
- Intuitive Navigation - Easy-to-use interface design
- Data Visualization - Charts and graphs for system metrics
- Glassmorphism Design - Modern, translucent UI elements
- Smooth Animations - Framer Motion powered transitions
- Weather Integration - Real-time weather information
- Step-by-step Guidance - Clear battery swap process flow
- RFID Authentication - Secure user identification
- Session Management - Secure session handling
- Input Validation - Comprehensive data validation
- CORS Configuration - Secure cross-origin requests
- SSL/TLS Support - Encrypted MQTT communication
The backend includes a Dockerfile for containerized deployment:
cd backend
docker build -t bss-backend .
docker run -p 5000:5000 bss-backendConfigure the following environment variables:
DATABASE_URL=mysql+mysqlconnector://user:password@host:port/database
MQTT_BROKER_HOST=localhost
MQTT_BROKER_PORT=1883
SECRET_KEY=your-secret-key- Battery health monitoring with SOH (State of Health) tracking
- Station connectivity status
- System performance metrics
- Real-time error logging
- Swap frequency analysis
- Battery usage patterns
- User behavior insights
- Station utilization metrics
We welcome contributions! See the CONTRIBUTING file for details.
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue on GitHub
- Contact the development team
- Check the documentation wiki
- Mobile App - Native iOS and Android applications
- AI Integration - Predictive maintenance and optimization
- Payment Integration - Multiple payment gateway support
- Multi-language Support - Internationalization
- Advanced Analytics - Machine learning insights
- Blockchain Integration - Decentralized transaction logging
Built with โค๏ธ by Ines Bourouissi