A Raspberry Pi-based interactive donation system with real-time voting capabilities, GPIO hardware control, and a modern web interface.
DonationBox is a full-stack application designed for physical donation boxes that allow donors to vote on different categories while making their donations. The system features:
- Interactive Voting: Donors can choose between multiple categories when donating
- Real-time Updates: WebSocket-based communication for instant feedback
- Hardware Integration: GPIO control for physical buttons, sensors, and displays
- Visual Dashboard: Modern React-based frontend displaying voting results and donation statistics
- Mock Mode: Full development support without physical hardware
This project is designed with reproducability in mind. A detailed, step-by-step guide for rebuilding the physical dontation box is available on Hackster.
The Hackster project documents the complete hardware setup, including required components, wiring diagram, enclosure construction and assembly instructions.
To reproduce the hardware setup pf this project, please follow the instructions provided in this guide:
โก๏ธHardware build guide on Hackster
This separation allows the GitHub repository to focus on software development and deployment, while all hardware-related documentation is maintained in a dedicated and easily accessible format.
The project consists of two main components:
- RESTful API for managing votes, categories, and donations
- WebSocket server for real-time communication
- GPIO service for Raspberry Pi hardware control
- SQLite database with Alembic migrations
- Async/await architecture for optimal performance
- Modern, responsive UI built with React 19
- Real-time data visualization
- QR code integration for charity information
- Animated voting results display
- โ Create and manage voting campaigns with multiple categories
- โ Track donations in real-time with category association
- โ Display voting results as they happen
- โ WebSocket support for live updates across all connected clients
- โ GPIO integration for physical buttons and sensors
- โ Mock GPIO mode for development without hardware
- โ Debug endpoints for testing and development
- โ Database migrations with Alembic
- โ CORS support for frontend-backend communication
- โ Comprehensive logging system
-
Backend:
- Python 3.10 or higher (tested with Python 3.14)
- pip package manager
- Raspberry Pi with GPIO pins (for production) or any system (for development)
-
Frontend:
- Node.js 16+ and npm/yarn
- Modern web browser
The full installation and deployment process is documented in the dedicated README inside the deploy/ directory.
This includes instructions for configuring the Raspberry Pi environment, installing dependencies, setting environment variables, and running the required deployment scripts.
Please follow the steps described in the deployment README and execute the provided scripts as outlined to ensure a correct and reproducible installation.
Once the backend is running, visit:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
Once the frontend is running, visit:
http://localhost:5173/management
This leads to a management site, where active votes can be started and managed.
For Raspberry Pi deployment:
- Set
ENABLE_GPIO=truein your.envfile - Set
PIN_FACTORY=nativefor production hardware - Configure GPIO pins in the
GPIOService.py - Connect physical buttons/sensors to the configured pins
The system includes a mock GPIO mode that allows full development and testing without physical hardware:
- Set
ENABLE_GPIO=falseorPIN_FACTORY=mock - Use debug endpoints to simulate GPIO events
- WebSocket connections work identically to production
DonationBox/
โโโ backend/ # FastAPI backend
โ โโโ alembic/ # Database migrations (Alembic)
โ โ โโโ versions/ # Migration versions (schema history)
โ โโโ core/ # Core infrastructure (config, DI, lifecycle, logging)
โ โโโ gpio/ # Raspberry Pi GPIO integration
โ โ โโโ components/ # GPIO hardware components (button, coin validator, etc.)
โ โโโ models/ # SQLAlchemy ORM models
โ โโโ repositories/ # Data access layer (CRUD + queries)
โ โโโ routes/ # API endpoints (REST + WebSocket)
โ โโโ schemas/ # Pydantic schemas (request/response DTOs)
โ โโโ services/ # Business logic layer
โ โ โโโ category/ # Category management logic
โ โ โโโ donation/ # Donation creation + aggregation + events
โ โ โโโ voting/ # Voting logic + result aggregation
โ โ โโโ websocket/ # WebSocket connections + broadcasting
โ โโโ app.py # Application entry point (FastAPI app)
โ โโโ requirements.txt # Python dependencies
โ
โโโ deploy/ # Deployment assets
โโโ frontend/ # React frontend (Vite)
โโโ public/ # Public static files
โโโ src/ # Frontend source code
โ โโโ assets/ # Images, icons, etc.
โ โโโ components/ # UI components
โ โโโ services/ # REST + WebSocket clients
โ โโโ state/ # Global state management
โ โโโ App.jsx # Main application component
โ โโโ AppRouter.jsx # Client-side routing
โ โโโ main.jsx # Application entry point
โโโ package.json # Node.js dependencies & scripts
โโโ vite.config.js # Vite configuration
| Variable | Default | Description |
|---|---|---|
APP_NAME |
"FastAPI" |
Application name |
ENV |
"production" |
Environment (development/production) |
DEBUG |
false |
Enable debug mode |
LOG_LEVEL |
"INFO" |
Logging level (DEBUG/INFO/WARNING/ERROR) |
DATABASE_URL |
"sqlite:///./backend/database.db" |
Database connection string |
ALLOWED_ORIGINS |
[] |
CORS allowed origins |
ENABLE_GPIO |
false |
Enable GPIO hardware control |
PIN_FACTORY |
"mock" |
GPIO pin factory (mock/native) |
cd backend
# Activate virtual environment
source .venv/bin/activate
# Run with auto-reload
python -m uvicorn backend.app:app --reload --host 0.0.0.0 --port 8000
# Create a new migration
alembic revision --autogenerate -m "Description of changes"
# Apply migrations
alembic upgrade head
# Run linting (if configured)
pylint backend/cd frontend
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Run linter
npm run lintThis project is licensed under the MIT License. You are free to use, modify, and distribute this software under the conditions stated in the LICENSE file.
This project is part of a university group project at the University of Cologne and the Cologne Institute for Information Systems (CIIS), conducted within the course Sustainable Digital Innovation Lab (SDIL) by the following contributors:
- Immanuel Sohn:
๐ง isohn1@smail.uni-koeln.de - Chiara Dรถring:
๐ง cdoerin1@smail.uni-koeln.de - Luca Schrรถder:
๐ง lschro34@smail.uni-koeln.de - Marlon Spiess:
๐ง mspiess1@smail.uni-koeln.de
- Built with FastAPI
- Frontend powered by React and Vite
- GPIO control via gpiozero
- Database management with SQLAlchemy and Alembic
Made with โค๏ธ for interactive charitable giving