How hinnuryuu/ujn-temperature-reporter works
Project Type and Purpose
• This is an automation + monitoring script (Python) with an optional web UI.
• Purpose: Log in to UJN SSO daily, submit the user’s body-temperature form automatically, manage multiple users, and optionally display status via a Flask dashboard.
File Structure
• Top-level scripts:
• app.py – Flask web UI entry point
• start.py – long-running scheduler that triggers the daily task
• task.py – orchestrates “fetch users → encrypt → login → submit form”
• database_manager.py – handles user credentials storage and retrieval
• des.py – RSA/JS encryption logic via pyexecjs (des.js wrapper)
• report.py – HTTP POST/GET wrapper for the report endpoints
• templates/index.html – HTML template for the Flask dashboard
README Insights
• Key libraries: pyexecjs (DES/RSA encryption), requests (HTTP), apschedule (scheduling), flask (monitoring UI)
• Usage patterns: daily 6 PM trigger, credentials stored via database_manager, encryption via des.js
a. Scheduler Component (APScheduler in start.py)
b. Task Controller (task.py)
c. User Store (database_manager.py)
d. Encryption Module (des.py + pyexecjs + des.js)
e. HTTP Client (report.py + requests)
f. External Services:
• UJN SSO (login endpoint)
• UJN Temperature Submission API
g. Optional Dashboard (app.py + Flask + templates/index.html)
Relationships & Data Flows
1. Scheduler triggers Task Controller once per day.
2. Task Controller queries User Store for all user credentials.
3. For each user:
– Pass credentials into Encryption Module → obtain encrypted payload.
– Use HTTP Client to POST login → receive Session token.
– Use HTTP Client to POST temperature report with Session.
4. Task Controller logs success/failure back to User Store or a log.
5. Dashboard (Flask) queries User Store or logs to display current status.
Architectural Patterns & Principles
• Modular separation:
• Data layer (database_manager.py)
• Business logic (task.py, report.py)
• Crypto layer (des.py)
• Orchestration/scheduling (start.py)
• Presentation (Flask UI)
• Single responsibility per module
• Asynchronous/periodic execution via APScheduler
• Clear external system boundary: UJN SSO & reporting API
Technologies & Libraries to Annotate
• Python 3.9
• pyexecjs + des.js (RSA encryption)
• requests (HTTP)
• APScheduler (job scheduling)
• Flask + Jinja2 templates