# Photomaton - Architecture du projet Association: Les Sapins Du Web (LSDW) Events: Hop'N Bloc, anniversaires, etc. ## Hardware | Composant | Modele | Notes | |-----------|--------|-------| | SBC | Raspberry Pi 4 (2 Go RAM) | Contrainte memoire forte | | Camera | Camera Module 3 officielle | Backend picamera2, ratio 3:2 natif | | Ecran | HDMI (moniteur/TV) | Interface photobooth-app + Chromium kiosk | | Bouton | Bouton lumineux 12V + relay | GPIO23 (input) + GPIO12 (relay ON/OFF) | | LED Strip | NeoPixels 35 LEDs | GPIO18, feedback visuel pendant capture | | Imprimante 1 | Canon Selphy CP1300 (blanche) | USB, CUPS: Canon_SELPHY_CP1300_usb_blanche | | Imprimante 2 | Canon Selphy CP1300 (noire) | USB, CUPS: Canon_SELPHY_CP1300_usb_noire | | WiFi | RaspAP (hotspot dedie) | Pour distribution photos via QR code | ## Software Stack ``` +----------------------------------------------------------+ | Navigateur Web | | (Chromium kiosk mode, ecran HDMI) | +----------------------------------------------------------+ | | | photobooth-app (:8083) Node-RED (:1880) | | - Capture camera - Bouton GPIO23 (multi-clic) | | - Post-traitement - Relay bouton GPIO12 | | - Galerie + QR share - NeoPixels GPIO18 | | - Interface utilisateur - Dashboard admin impression | | - File attente SQLite | | - Gestion CUPS (enable/ | | disable, cancel jobs) | +----------------------------------------------------------+ | Zoraxy (reverse proxy + TLS :443) | +----------------------------------------------------------+ | CUPS + Gutenprint | RaspAP (hotspot WiFi) | | (impression Selphy x2) | (reseau dedie QR code) | +----------------------------------------------------------+ | Raspberry Pi OS (Trixie) | +----------------------------------------------------------+ ``` ## Flux utilisateur (prise de photo) ``` Bouton physique (GPIO23) | v Node-RED (button-events: clic/double/triple/quadruple) | +--> Desactive relay bouton (GPIO12 = OFF) +--> NeoPixels: vert (countdown) +--> Appel API photobooth-app: GET /api/actions/image/{N} | v photobooth-app 1. Countdown (5s) affiche sur ecran 2. NeoPixels: blanc (flash) <-- via webhook -> Node-RED 3. Capture Camera Module 3 (picamera2) 4. NeoPixels: violet (captured) 5. Post-traitement (cadre, remove_background si active) 6. Photo ajoutee a la galerie 7. NeoPixels: bleu (finished) puis vert apres 2s 8. Reactive relay bouton (GPIO12 = ON) 9. QR code affiche pour telecharger via WiFi ``` ## Flux impression ``` Utilisateur: clic "Demander l'impression" dans galerie photobooth-app | v photobooth-app: share_command = curl Node-RED /api/photobooth-custom/ask_print | v Node-RED: 1. Recupere l'UID de la photo via API photobooth /api/mediacollection 2. Insere dans SQLite (photo-to-print.sqlite) 3. Affiche dans le dashboard admin (/dashboard) | v Admin (sur telephone via WiFi): - Voit la demande dans le tableau avec preview - Clic "OK" = lance impression via script_print.sh (crop 3:2 + lp) - Clic "x" = annule la demande - Peut aussi cancel/clear les jobs CUPS, enable/disable imprimantes ``` ## GPIO | GPIO | Pin physique | Fonction | Controle par | |------|-------------|----------|--------------| | 12 | 32 | Relay bouton 12V (output) | Node-RED | | 17 | 11 | Shutdown (hold 2s) | photobooth-app | | 18 | 12 | NeoPixels 35 LEDs (output) | Node-RED (rpi-neopixels) | | 20 | 38 | Job abort | photobooth-app | | 22 | 15 | Job reject / Collage GPIO | photobooth-app | | 23 | 16 | Bouton physique (input, pull-up) | Node-RED (button-events) | | 27 | 13 | Job next | photobooth-app | ## Modes photo (bouton multi-clic) | Clics | Mode | Action photobooth-app | remove_background | |-------|------|----------------------|-------------------| | 1 | HnB normal | /api/actions/image/0 | Non | | 2 | HnB etoile | /api/actions/image/1 | Oui | | 3 | HnB cailloux | /api/actions/image/2 | Oui | | 4 | HnB light | /api/actions/image/3 | Oui | | Long press | Demande impression | /api/share/actions/latest/0 | - | ## Ports reseau | Service | Port | Process | Notes | |---------|------|---------|-------| | SSH | 22 | sshd | Acces distant | | DNS | 53 | dnsmasq | RaspAP, resolution domaines locaux | | HTTP | 80 | zoraxy | Redirect -> HTTPS | | HTTPS | 443 | zoraxy | Reverse proxy principal | | CUPS | 631 | cupsd | Administration imprimantes | | Node-RED | 1880 | node-red | Dashboard admin + GPIO + NeoPixels | | Zoraxy admin | 5487 | zoraxy | Panel admin (localhost only) | | Zoraxy admin | 8001 | zoraxy | Panel admin (expose via sous-domaine) | | RaspAP API | 8081 | uvicorn/python3 | API backend RaspAP (/etc/raspap/api/) | | RaspAP | 8082 | lighttpd | Interface admin WiFi | | photobooth-app | 8083 | python | Interface web principale | | ~~rpcbind~~ | ~~111~~ | ~~rpcbind~~ | **INUTILE - a desactiver** | ## Domaines (Zoraxy reverse proxy) | Sous-domaine | Upstream | Service | |-------------|----------|---------| | `photomaton.lessapinsduweb.com` | 127.0.0.1:8083 | photobooth-app (WebSocket ON) | | `photomaton-nodered.lessapinsduweb.com` | 127.0.0.1:1880 | Node-RED dashboard | | `photomaton-raspap.lessapinsduweb.com` | 127.0.0.1:8082 | RaspAP admin | | `photomaton-zoraxy.lessapinsduweb.com` | 127.0.0.1:8001 | Zoraxy admin | - Certificats TLS geres par Zoraxy - QR share: `https://photomaton.lessapinsduweb.com/sharepage/#?url=...` - Chaque service gere sa propre authentification ## Reseau WiFi (RaspAP) | Element | Valeur | |---------|--------| | Interface | wlan0 | | IP du Pi | 10.3.141.1 | | Plage DHCP | 10.3.141.50 - 10.3.141.254 (~200 clients) | | Masque | 255.255.255.0 | | Bail DHCP | 12h | | DNS | dnsmasq sur le Pi (port 53) | | Internet | AUCUN (captive portal) | ### Resolution DNS (dnsmasq) ``` # /etc/dnsmasq.d/090_custom_local_hotspot.conf address=/lessapinsduweb.com/10.3.141.1 # *.lessapinsduweb.com -> Pi address=/photomaton.lessapinsduweb.com/10.3.141.1 # explicite address=/#/127.0.0.1 # tout le reste -> null (pas d'internet) ``` Flux QR code : 1. Telephone se connecte au WiFi "Photomaton" 2. Recoit IP en 10.3.141.x via DHCP, DNS = 10.3.141.1 3. Scan QR code -> `https://photomaton.lessapinsduweb.com/sharepage/...` 4. dnsmasq resout vers 10.3.141.1 (le Pi) 5. Zoraxy (:443) sert la page via HTTPS 6. photobooth-app (:8083) fournit la photo ## Fichiers sur le Pi ``` /home/pi/ photobooth-data/ media/ processed_full/ # Photos traitees (pleine resolution) script/ script_print.sh # Script d'impression avec load-balancing log/ # Logs quotidiens photo-to-print.sqlite # File d'attente d'impression (Node-RED) userdata/ hopnbloc/ frames/ # Cadres PNG 2000x1333 (ratio 3:2) backgrounds/ # Fonds pour remove_background LSDW/ lulu-versaire2.png # Cadre anniversaire logo/logo.jpeg # Logo LSDW demoassets/ backgrounds/ # Fonds demo (etoiles, etc.) frames/ # Cadres demo ``` ## Fichiers du projet (ce repo) ``` photomaton/ scripts/ optimize-system.sh # Optimisation OS pour 2Go RAM setup-printer.sh # Configuration CUPS + Selphy CP1300 setup-photobooth.sh # Installation complete script_print.sh # Script d'impression optimise health-check.sh # Surveillance sante du systeme maintenance.sh # Nettoyage automatique quotidien config/ photobooth-config-backup.json # Config originale (sauvegarde) photobooth-config-optimized.json # Config optimisee gpio-notes.conf # Documentation GPIO zoraxy-notes.conf # Notes Zoraxy nodered-flows-backup.json # Backup flows Node-RED systemd/ photobooth-app.service # Service robuste avec auto-restart photobooth-watchdog.service # Health check photobooth-watchdog.timer # Toutes les 2 minutes photobooth-maintenance.service # Nettoyage photobooth-maintenance.timer # Quotidien a 4h docs/ ARCHITECTURE.md # Ce fichier ANALYSE-CONFIG.md # Analyse detaillee des problemes ```