Architecture & Stack:
The application uses Flask 3.1.0 with Flask-SocketIO 5.4.1 running in eventlet async mode for reliable real-time communication. After initial development with threading mode, I discovered limitations in socket-based notifications and migrated to eventlet for proper bidirectional WebSocket support.
Backend Technologies:
- Flask 3.1.0: Web framework and routing
- Flask-SocketIO 5.4.1: Real-time bidirectional communication
- Eventlet: Async mode for WebSocket reliability
- SQLite with WAL mode: Database with concurrent access support
- Python 3.8+: Core language
Frontend Technologies:
- Tailwind CSS: Utility-first styling with CDN delivery
- Alpine.js: Reactive components without build tools
- Socket.IO client: WebSocket client library
- Jitsi Meet: Embedded video conferencing
Database Schema:
The SQLite database uses five core tables:
- availability - Current status and custom messages
- messages - Guest book entries with read tracking
- visits - Session logs with duration calculation
- pending_visitors - Access requests with approval workflow
- chat_messages - Persistent chat history with sender attribution
Game Implementations:
Word Search: Python-based grid generator with 10 themed word lists (Animals, Food, Travel, Tech, Nature, Music, Sports, Movies, Space, Christmas). Client-side JavaScript handles cell selection, word validation, and progress tracking.
Sudoku: Server-side puzzle generation with backtracking algorithm. Three difficulty levels (easy: 30 cells removed, medium: 40, hard: 50). Client validates solutions and highlights errors in real-time.
Trivia: Integration with Open Trivia Database API. Supports category filtering, difficulty selection, and configurable question count. Client-side timer with point scoring based on response speed.
Real-time Communication:
Socket.IO events handle all real-time updates:
- Admin joins dedicated "admin" room via join_admin event
- Visitor connections tracked in active_connections dictionary
- Chat messages broadcast to all connected sockets via send_message event
- Approval notifications sent via approval_granted/approval_rejected
- Forced disconnections handled via force_disconnect event
- Polling fallbacks implemented for reliability (2-3 second intervals)
Session Management:
Visitor sessions use server-side Flask sessions with 16-byte random identifiers. Admin authentication uses session-based login with configurable credentials via environment variables. **Deployment Configuration:** Production deployment on Ubuntu VPS:
- Caddy: Reverse proxy with automatic SSL via Let's Encrypt
- systemd: Process management with auto-restart on failure
- SQLite WAL mode: Concurrent read access for multiple connections
- Environment variables: Secret key, admin credentials, feature flags