Desktop application for managing RFID hardware terminals in the BarberKiosk system. This agent runs on workstations with connected RFID readers and handles card scanning for customer check-ins at barbershops.
The BarberKiosk Agent is a PyQt6-based desktop application that:
- Connects RFID readers to the BarberKiosk backend system
- Listens for scan requests via RabbitMQ
- Reads RFID cards and sends results back to the backend
- Provides a GUI for terminal registration and status monitoring
- Shop owner authentication via phone number and password
- Automatic terminal registration with unique device ID
- Secure credential storage for persistent sessions
- Automatic configuration sync from backend
- Serial port communication with RFID hardware
- Automatic card detection and UID reading
- Support for custom RFID protocols
- Real-time scan request consumption from backend
- Publish scan results to backend queue
- Automatic reconnection on connection loss
- Thread-safe message handling
- Login window for shop owner authentication
- Main window showing:
- Shop and terminal information
- Connection status (RFID, RabbitMQ)
- Real-time scan activity
- Visual feedback for successful/failed scans
- System tray integration for background operation
- Persian (RTL) language support
BarberKioskAgent/
βββ main.py # Application entry point
βββ config.py # Configuration management
βββ requirements.txt # Python dependencies
βββ gui/
β βββ login_window.py # Login/registration window
β βββ main_window.py # Main application window
βββ services/
βββ auth_service.py # Backend authentication
βββ rfid_reader.py # RFID hardware interface
βββ rabbitmq_client.py # RabbitMQ messaging
- Python 3.8 or higher
- RFID reader connected via USB/Serial port (or use mock mode)
- Access to BarberKiosk backend and RabbitMQ server
-
Clone the repository (if not already done):
cd /p/BarberKiosk/BarberKioskAgent -
Create a virtual environment:
python3 -m venv .venv source .venv/bin/activate # On Linux/Mac # or .venv\Scripts\activate # On Windows
-
Install dependencies:
pip install -r requirements.txt
-
Configure the application (optional):
Configuration is automatically fetched from the backend upon login, but you can create a manual config file at
~/.barber_agent/config.json:{ "backend_url": "http://localhost:8000", "rabbitmq_host": "localhost", "rabbitmq_port": 5672, "rabbitmq_user": "barber", "rabbitmq_pass": "barber123", "rfid_baudrate": 9600 }
This project ships as a macOS .app bundle and can be packaged into a simple drag-and-drop DMG.
- Build the
.app:
cd BarberKioskAgent
pyinstaller BarberAgent.spec- Create the DMG:
./scripts/build_macos_dmg.shOutput:
dist/BarberAgent.dmg
The DMG opens with a standard βdrag to Applicationsβ window (app icon + Applications shortcut).
python main.py- Launch the application - The login window will appear
- Enter credentials:
- Phone number (shop owner's registered phone)
- Password (shop owner's password)
- Terminal registration happens automatically
- Configuration is synced from backend
Once registered, the agent will:
- Auto-start with saved credentials
- Connect to RFID reader and RabbitMQ
- Display status in the main window
- Wait for scan requests from backend
- When a customer approaches the kiosk and triggers a scan:
- Backend sends scan request via RabbitMQ
- Agent activates RFID reader
- Customer taps their RFID card
- Card UID is read and sent to backend
- Visual feedback shown on screen
The application can be minimized to system tray for background operation. Right-click the tray icon to:
- Show/hide main window
- View connection status
- Logout/exit
All configuration is stored in ~/.barber_agent/:
config.json- Backend URL, RabbitMQ settings, RFID portcredentials.json- Terminal ID and authentication token (auto-generated)
You can override configuration with environment variables:
BACKEND_URL- Backend API URLRABBITMQ_HOST- RabbitMQ server hostRABBITMQ_PORT- RabbitMQ server portRFID_PORT- Serial port for RFID reader
For development without physical RFID hardware:
- The system automatically detects missing hardware
- A mock reader is used that simulates card scans
- Test card UIDs can be generated on-demand
- AgentApplication (
main.py): Main controller managing application flow - LoginWindow (
gui/login_window.py): Handles shop owner authentication - MainWindow (
gui/main_window.py): Displays agent status and scan activity - AuthService (
services/auth_service.py): Backend authentication and registration - RFIDReader (
services/rfid_reader.py): Serial communication with RFID hardware - RabbitMQClient (
services/rabbitmq_client.py): Message queue integration
Backend (Web) β RabbitMQ β Agent β RFID Reader
β
Customer Card β RFID Reader β Agent β RabbitMQ β Backend
- Check USB connection
- Verify correct serial port in config (
/dev/ttyUSB0on Linux,COM3on Windows) - Check permissions:
sudo usermod -a -G dialout $USER(Linux) - Verify baudrate matches your hardware (default: 9600)
- Ensure RabbitMQ server is running
- Verify host, port, username, and password in config
- Check firewall settings
- Review logs for connection errors
- Verify backend URL is correct
- Ensure backend server is running
- Check network connectivity
- Review authentication credentials
- Verify phone number and password are correct
- Ensure shop owner account exists in backend
- Check backend logs for authentication errors
- Try clearing credentials:
rm ~/.barber_agent/credentials.json
Logs are written to console with the following format:
%(asctime)s - %(name)s - %(levelname)s - %(message)s
For more detailed logging, edit main.py and set:
logging.basicConfig(level=logging.DEBUG, ...)- Credentials stored locally in
~/.barber_agent/credentials.json - Authentication tokens used for backend API calls
- Unique device ID generated from hardware information
- All sensitive data should be transmitted over HTTPS in production
- PyQt6 (β₯6.5.0) - GUI framework
- pika (β₯1.3.0) - RabbitMQ client
- pyserial (β₯3.5) - Serial port communication
- requests (β₯2.31.0) - HTTP client for backend API
Part of the BarberKiosk system.
For issues and questions, please refer to the main project documentation or contact the development team.