How erdhyernando/flask-auth works
Project type and purpose
• This is a full-stack, Flask‐SocketIO web application running on a Raspberry Pi.
• Purpose: Provide a GUI for user authentication, file management, real-time execution and monitoring of “orthosis” control scripts, data logging, and chart-based visualization.
Main components to include as distinct blocks
a. Client / Browser Layer
• Static assets (CSS, JS) and HTML templates (under templates/)
• Chart.js for data visualization
• GUI pages: login/signup, script browser, real-time output console
b. Web Server / Application Layer
• Flask app (app.py + run.py)
• Flask-SocketIO event handlers (routes.py)
• Utility module (utils.py) for argument parsing, admin checks, directory pointers
• Script management subsystem (“orthosis-scripts” directory)
c. Database Layer
• SQLAlchemy models (models.py)
• Alembic migrations (migrations/…)
• User table, script_labels table, data logging tables
d. Script Execution Engine & Hardware Interface
• Python subprocess or direct module import to launch scripts from the orthosis-scripts folder
• Real-time stdout/stderr forwarded over WebSocket
• Optional Shellinabox CLI for advanced command-line interactions
• Interaction with orthosis hardware (GPIO or external API calls)
e. External Services & Host
• Raspberry Pi OS startup (bashrc entry → run.py)
• Possible external IP link / sudo commands for hardware networking
Relationships and data flows
• HTTP(S) requests (GET/POST) from Client → Flask routes (login, signup, page loads)
• WebSocket (Socket.IO) bidirectional channel:
• Client emits “run_script” → Server spawns script → streams real-time output events back
• Server pushes data-logging updates and chart points to Client
• ORM/SQL queries: application CRUD on User, ScriptLabels, Logs → Database file (e.g., SQLite or other URI)
• Server invokes system calls (Shellinabox, sudo IP link) to prepare hardware or open CLI
Architectural patterns and design principles
• MVC-style separation:
• Models: models.py + migrations
• Views: HTML templates + static JS/CSS
• Controllers: Flask routes + SocketIO handlers
• Event-driven, real-time pipeline via WebSockets
• Modular script plug-in structure under orthosis-scripts for extensibility
• Configuration-driven startup (utils.py / bashrc)