Skip to content

A Raspberry Pi-based meal registration system for fire departments, optimized for a 3.5-inch touchscreen.

Notifications You must be signed in to change notification settings

Brunsben/FoodBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

84 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš’ FoodBot - Feuerwehr Essensanmeldung

Ein modernes System zur Essensanmeldung fรผr die Feuerwehr, optimiert fรผr den Raspberry Pi mit 3,5" Touchscreen.

โœจ Features

Registrierung

  • ๐Ÿ†” RFID-Transponder: Automatische Anmeldung per ELATEC TWN4 HID Reader
  • ๐Ÿ“ฑ QR-Code: Persรถnlicher QR-Code fรผr jeden User zum Ausdrucken
  • ๐Ÿ”ข Personalnummer: Manuelle Eingabe am Touchscreen mit virtueller Tastatur (ausblendbar)
  • ๐Ÿ‘ฅ Gรคste: Schnelle +/- Buttons fรผr Besucher ohne Account

Menรผverwaltung

  • ๐Ÿฝ๏ธ Zwei-Menรผ-System: Optional zwei verschiedene Menรผs pro Tag
  • ๐Ÿ“ Menรผ-Auswahl: Benutzer wรคhlen bei Anmeldung ihr Wunschmenรผ (RFID + Personalnummer)
  • ๐Ÿ“Š Getrennte Zรคhlung: Separate Anzeige fรผr Menรผ 1 und Menรผ 2
  • โœ… Farbcodierte Bestรคtigung: Grรผn fรผr Anmeldung, Rot fรผr Abmeldung
  • โฐ Anmeldefrist: Konfigurierbarer Deadline-Zeitpunkt (Standard: 19:45)
  • ๐Ÿ“… Wochenplanung: 14-Tage-Vorausplanung mit Deadline-Einstellungen pro Tag

Interfaces

  • ๐Ÿ“ฑ Touch-Display (3,5" 320x480): Modernes Dark-Theme, optimiert fรผr kleine Displays
  • ๐Ÿฝ๏ธ Kรผchenansicht: Live-Statistiken, Menรผ-Eingabe, Druckansicht (Auto-Refresh 5s)
  • โš™๏ธ Admin-Panel: User-Verwaltung, CSV-Import, Preset-Menรผs, Deadline-Konfiguration
  • ๐Ÿ“Š Statistiken: 14-Tage-รœbersicht, CSV-Export
  • ๐Ÿ“ˆ Historie: Top-10-Esser, persรถnliche Statistiken, monatliche รœbersicht
  • ๐Ÿ–จ๏ธ Druckliste: Gruppiert nach Menรผ mit Checkboxen fรผr die Kรผche

Security & Performance

  • ๐Ÿ” Admin-Login: Session-basierte Authentifizierung (Standard-Passwort: feuerwehr2026)
  • โšก Rate Limiting: Schutz vor API-Missbrauch (200/Tag, 50/Stunde)
  • ๐Ÿ“ Logrotate: Automatische Log-Verwaltung (tรคglich, 14 Tage Retention)
  • ๐Ÿ”” Webhooks: Benachrichtigungen via Slack, Discord, etc.
  • ๐Ÿ”Œ REST-API: Integration mit externen Systemen

Automation

  • ๐Ÿ’พ Auto-Backup: Tรคgliches Datenbank-Backup (00:30 Uhr)
  • ๐ŸŒ™ Auto-Reset: Anmeldungen werden tรคglich gelรถscht (00:00 Uhr)
  • โฐ Cronjobs: Vollstรคndig konfigurierte automatische Aufgaben

Design

  • ๐ŸŽจ Modernes Dark-Theme: Gradient-Background (#1e1e1e โ†’ #2d2d2d), rote Akzente (#dc2626)
  • ๐Ÿ“ Touch-optimiert: GroรŸe Buttons, virtuelle Tastatur auf Abruf
  • ๐Ÿ“ฑ Responsive: Grid-Layout passt sich an alle BildschirmgrรถรŸen an
  • โšก Live-Updates: Menรผ-Aktualisierung alle 5 Sekunden (Touch + Kรผche)
  • ๐ŸŽญ Status-Popups: GroรŸe, farbcodierte Bestรคtigungen mit Icons

๐Ÿš€ Installation

Option 1: Automatisches Setup (empfohlen)

Fรผr Production-Deployment auf Raspberry Pi:

# Repository klonen
cd /home/pi
git clone https://github.com/Brunsben/FoodBot
cd FoodBot

# Automatisches Setup (als root)
sudo ./deployment/setup_production.sh

Das Skript installiert:

  • โœ… Python Virtual Environment + Dependencies
  • โœ… Systemd Service fรผr automatischen Start
  • โœ… Logrotate Konfiguration
  • โœ… Cronjobs fรผr Backup & Reset
  • โœ… Optional: Nginx Reverse Proxy

๐Ÿ“– Ausfรผhrliche Deployment-Anleitung: DEPLOYMENT.md

Option 2: Docker

git clone <repository-url> FoodBot
cd FoodBot
docker-compose up -d

Option 3: Manuelle Installation

# Virtual Environment
python3 -m venv venv
source venv/bin/activate

# Dependencies
pip install -r requirements.txt

# Datenbank initialisieren
python -c "from app import create_app, db; app = create_app(); app.app_context().push(); db.create_all()"

# Starten
gunicorn -c deployment/gunicorn.conf.py "app:create_app()"

๐Ÿ–ฅ๏ธ Interfaces

Nach der Installation erreichbar unter:

  • Touch-Display: http://<raspberry-pi>:5001/ - Hauptinterface fรผr Anmeldung
  • Kรผchenansicht: http://<raspberry-pi>:5001/kitchen - Fรผr Tablet/PC in der Kรผche
  • Admin-Panel: http://<raspberry-pi>:5001/admin - Benutzerverwaltung (Login erforderlich)
  • Statistiken: http://<raspberry-pi>:5001/stats - Auswertungen (Login erforderlich)
  • Historie: http://<raspberry-pi>:5001/history - Essenshistorie & Top-10 (Login erforderlich)

๐Ÿ” Standard-Login

  • Passwort: feuerwehr2026
  • ร„ndern via Environment-Variable: ADMIN_PASSWORD=dein-passwort

๐Ÿ”Œ REST-API

Die API ist erreichbar unter /api/ und bietet folgende Endpoints:

Status abrufen

GET /api/status

Gibt aktuelles Menรผ, Anzahl Anmeldungen und Gรคste zurรผck.

Rate Limit: 30 Requests/Minute

An-/Abmelden

POST /api/register
Content-Type: application/json

{
  "personal_number": "12345"
}

Rate Limit: 10 Requests/Minute

Statistiken

GET /api/stats?days=7

Benutzerliste

GET /api/users

โš™๏ธ Konfiguration

Environment-Variablen

Erstelle eine .env-Datei oder setze die Variablen im System:

# Admin-Passwort (Standard: feuerwehr2026)
ADMIN_PASSWORD=dein-sicheres-passwort

# Secret Key fรผr Sessions (WICHTIG in Production!)
SECRET_KEY=$(python3 -c 'import os; print(os.urandom(24).hex())')

# Flask Environment
FLASK_ENV=production

# RFID-Port (optional, Standard: /dev/ttyUSB0)
RFID_PORT=/dev/ttyUSB0

# Webhook fรผr Benachrichtigungen (optional)
WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL

Systemd Service verwalten

# Status prรผfen
sudo systemctl status foodbot

# Starten/Stoppen/Neustarten
sudo systemctl start foodbot
sudo systemctl stop foodbot
sudo systemctl restart foodbot

# Logs ansehen
journalctl -u foodbot -f

Beispiel:

curl http://localhost:5000/api/status
curl -X POST http://localhost:5000/api/register \
  -H "Content-Type: application/json" \
  -d '{"personal_number": "12345"}'

๐Ÿ“ Projektstruktur

FoodBot/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ __init__.py           # Flask App Factory
โ”‚   โ”œโ”€โ”€ models.py             # Datenbank-Modelle (User, Registration, Menu, AdminLog)
โ”‚   โ”œโ”€โ”€ routes.py             # Hauptrouten (Touch, Kitchen, Admin)
โ”‚   โ”œโ”€โ”€ api.py                # REST API mit Rate Limiting
โ”‚   โ”œโ”€โ”€ stats.py              # Statistik-Routes
โ”‚   โ”œโ”€โ”€ history.py            # Essenshistorie & Top-10
โ”‚   โ”œโ”€โ”€ auth.py               # Admin-Authentifizierung
โ”‚   โ”œโ”€โ”€ rfid.py               # RFID-Reader Integration (optional)
โ”‚   โ””โ”€โ”€ gunicorn_config.py    # Gunicorn fรผr Docker
โ”œโ”€โ”€ templates/
โ”‚   โ”œโ”€โ”€ touch.html            # 3,5" Touch-Interface (modernes Dark-Theme)
โ”‚   โ”œโ”€โ”€ kitchen.html          # Kรผchenansicht (Card-Layout)
โ”‚   โ”œโ”€โ”€ admin.html            # Admin-Panel (Drag & Drop CSV-Import)
โ”‚   โ”œโ”€โ”€ stats.html            # Statistiken
โ”‚   โ”œโ”€โ”€ history.html          # Historie-รœbersicht
โ”‚   โ”œโ”€โ”€ history_detail.html   # User-Detail-Historie
โ”‚   โ”œโ”€โ”€ *_modern.html         # Moderne Design-Varianten (Backup)
โ”‚   โ””โ”€โ”€ *_old.html            # Legacy-Templates (Backup)
โ”œโ”€โ”€ deployment/
โ”‚   โ”œโ”€โ”€ setup_production.sh   # Automatisches Production-Setup
โ”‚   โ”œโ”€โ”€ setup_cronjobs.sh     # Cronjob-Installation
โ”‚   โ”œโ”€โ”€ gunicorn.conf.py      # Gunicorn Konfiguration
โ”‚   โ”œโ”€โ”€ foodbot.service       # Systemd Service
โ”‚   โ”œโ”€โ”€ nginx-foodbot         # Nginx Reverse Proxy Config
โ”‚   โ”œโ”€โ”€ logrotate-foodbot     # Log-Rotation Config
โ”‚   โ””โ”€โ”€ DISPLAY_SETUP.md      # 3,5" Display Konfiguration (LCD-show)
โ”œโ”€โ”€ backup_db.py              # Automatisches Datenbank-Backup
โ”œโ”€โ”€ clear_registrations.py    # Tรคglich Anmeldungen lรถschen
โ”œโ”€โ”€ docker-compose.yml        # Docker Deployment
โ”œโ”€โ”€ Dockerfile                # Container-Image
โ”œโ”€โ”€ requirements.txt          # Python Dependencies
โ”œโ”€โ”€ README.md                 # Diese Datei
โ””โ”€โ”€ DEPLOYMENT.md             # Ausfรผhrliche Deployment-Anleitung

๐Ÿ› ๏ธ Wartung

Backups

Backups werden automatisch tรคglich um 00:30 Uhr erstellt:

  • Speicherort: /home/pi/FoodBot/backups/
  • Format: foodbot_backup_YYYYMMDD_HHMMSS.db
  • Manuell: python backup_db.py

Logs

# Application Logs
tail -f /var/log/foodbot/error.log
tail -f /var/log/foodbot/access.log

# Systemd Logs
journalctl -u foodbot -f

# Backup/Reset Logs
tail -f /var/log/foodbot/backup.log
tail -f /var/log/foodbot/reset.log

Datenbank zurรผcksetzen

# WARNUNG: Lรถscht alle Anmeldungen des heutigen Tages!
python clear_registrations.py

Updates installieren

cd /home/pi/FoodBot
git pull
source venv/bin/activate
pip install -r requirements.txt
sudo systemctl restart foodbot

๐Ÿ“Š CSV-Import

Im Admin-Panel kรถnnen Benutzer per CSV importiert werden.

Format:

Name,Personalnummer,Karte
Max Mustermann,12345,ABC1234
Erika Musterfrau,23456,XYZ5678

Oder englisch:

name,personal_number,card_id

Die Karten-ID (RFID) ist optional.

๐Ÿ”” Benachrichtigungen

FoodBot kann Webhooks senden (Slack, Discord, Teams):

Konfiguration:

NOTIFICATIONS_ENABLED=true
WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL

Events:

  • โœ… Neue Anmeldung
  • โš ๏ธ Niedrige Teilnehmerzahl (< 5)
  • ๐Ÿ”ฅ Hohe Teilnehmerzahl (> 30)

๐Ÿ› Troubleshooting

Service startet nicht

sudo systemctl status foodbot
journalctl -u foodbot -n 50

RFID funktioniert nicht

# Device prรผfen
ls -l /dev/ttyUSB*

# Berechtigungen
sudo usermod -a -G dialout pi
# Neu anmelden!

Nginx 502 Bad Gateway

# Service aktiv?
sudo systemctl status foodbot

# Port 5001 lauscht?
sudo netstat -tlnp | grep 5001

Mehr Hilfe: DEPLOYMENT.md - Troubleshooting

๐Ÿ“ Technische Details

Stack

  • Backend: Python 3.11+, Flask 3.1
  • Datenbank: SQLite mit SQLAlchemy 2.0
  • Server: Gunicorn mit 4 Workern (Production)
  • Reverse Proxy: Nginx (optional)
  • Hardware: Raspberry Pi 4, ELATEC TWN4 HID RFID Reader, 3,5" ILI9486 Touchscreen (320x480)
  • Display: LCD-show Treiber fรผr SPI-basierte Displays

Design System

  • CSS: CSS Custom Properties (Variablen)
  • Layout: CSS Grid & Flexbox
  • Theme: Dark Mode (#0f172a Base, #dc2626 Primary, #10b981 Success)
  • Typography: System Fonts (-apple-system, BlinkMacSystemFont, Segoe UI)
  • Components: Card-basiert, Gradients, Shadow-Effekte

Dependencies

  • flask - Web Framework
  • flask-sqlalchemy - ORM
  • flask-limiter - Rate Limiting
  • pyserial - RFID-Reader Kommunikation
  • qrcode[pil] - QR-Code Generierung
  • gunicorn - WSGI Server
  • python-dotenv - Environment Configuration

Security Features

  • โœ… Session-basierte Admin-Authentifizierung
  • โœ… Rate Limiting auf API-Endpoints
  • โœ… CSRF-Protection (Flask-WTF)
  • โœ… Prepared Statements (SQLAlchemy)
  • โœ… Input Validation

๐Ÿ“„ Lizenz

MIT License - Frei verwendbar fรผr private und kommerzielle Projekte.

๐Ÿค Beitragen

Pull Requests sind willkommen! Fรผr grรถรŸere ร„nderungen bitte zuerst ein Issue รถffnen.

๐Ÿ“ž Support

Bei Problemen:

  1. DEPLOYMENT.md lesen
  2. Logs prรผfen (siehe Wartung)
  3. GitHub Issue รถffnen

๐Ÿš’ Entwickelt fรผr die Feuerwehr - Mit โค๏ธ und Python ๐Ÿš’

About

A Raspberry Pi-based meal registration system for fire departments, optimized for a 3.5-inch touchscreen.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published