🔆 UOP Light Sensor Dashboard

Data Structure & Architecture Diagram

Screen Layout Design
🛋️ Living
🛏️ Bedroom
🍳 Kitchen
🚿 Bathroom
💼 Office
🚗 Garage
👤 Profile
(Login / Logout)
0 lux
GAUGE (0-800)
SLIDER
800

0
📈 WEEKLY GRAPH
Feb 1 - 7
4h 15m
Sun → Sat
USER VIEW BOX
Month | Date | Room
room: living
date: 2026-03-30
onSeconds: 0
offSeconds: 86400
sensor_id: all-rooms
🌿 Eco Mode
🌙 Sleep Mode
TODAY
0h 37m
of 24 hours
DAILY USAGE ANALYTICS
Monthly Bar Chart
x-axis: Jan → Dec
⚙️
Customize
Data Flow Architecture
👤
User
Interactions
Button clicks, toggles
🖥️
Frontend
HTML/CSS/JS
Real-time updates
⚙️
Backend
Flask API
Python server
🗄️
MongoDB
Atlas Cloud
Persistent storage
💾
localStorage
Browser storage
Login session, preferences
MongoDB Database Schema
📊 daily_usage
_id ObjectId
date String "2026-02-05"
sensor_id String (e.g. "all-rooms")
onSeconds Number (0-86400)
offSeconds Number
lux Number (0-800) - latest embedded sensor reading
updatedAt DateTime ISO (server time)
luxUpdatedAt DateTime ISO (PST, last sensor update)
🛋️ room_living
_id ObjectId
date String "2026-02-05"
sensor_id String (e.g. "sensor-1")
onSeconds Number
avgLux Number (0-800)
updatedAt DateTime ISO
luxUpdatedAt DateTime ISO (PST, last sensor update for this room)
🛏️ room_bedroom
_idObjectId
dateString
sensor_idString (e.g. "sensor-2")
onSecondsNumber
avgLuxNumber
updatedAtDateTime ISO
luxUpdatedAtDateTime ISO (PST)
📱 devices
action_typeString (room_light_on / gauge_light_on)
room_idString
room_nameString
dateString
timeString
timestampDateTime ISO
ipString
userAgentString
createdAtDateTime ISO
👤 user_data
emailString
loggedInAtDateTime ISO
ipString
userAgentString
🔐 admin_access
usernameString
loginTypeString ("personal" or "organization")
organizationNameString (if loginType = "organization")
accessedAtDateTime ISO
ipString
userAgentString
pathString
⚠️ alerts
alert_idString (UUID)
room_idString
dateString
durationSecondsNumber
typeString (e.g. duration_over_40min)
createdAtDateTime ISO
🔑 users
emailString (unique)
passwordHashString (hashed password)
createdAtDateTime ISO
📝 Feedback
textString (reported issue)
dateString (PST)
timeString (PST)
timestampDateTime ISO (PST)
createdAtDateTime ISO
🏢 Organization
adminNameString
organizationNameString
dateString (PST)
timeString (PST)
timestampDateTime ISO (PST)
createdAtDateTime ISO
API Endpoints
Method Endpoint Description
GET / Dashboard page
GET /diagram Architecture diagram page
GET /api/docs Swagger UI (interactive API docs)
GET /api/sensor Simulated sensor reading
POST /api/v1/sensors/register Register sensor device
POST /api/v1/sensors/data Submit lux sensor reading
GET /api/v1/sensors/{sensor_id}/status Sensor status by ID
GET /api/v1/sensors/latest Latest lux from daily_usage
POST /api/usage/save Save daily usage
GET /api/usage/{date} Get usage for date
GET /api/usage/statistics Weekly and monthly stats
POST /api/room/{room}/save Save room usage
GET /api/room/{room}/{date} Get room data for date
GET /api/room/{room}/statistics Room weekly and monthly stats
GET /api/rooms/all/{date} All rooms for date
POST /api/admin/access Log admin access
POST /api/alerts Create long-on alert
POST /api/user/login User login (email and password)
POST /api/feedback Report an issue
POST /api/device/log Log device when lights turn on
Key Features
💡
6 Room Controls
Independent light controls for Living, Bedroom, Kitchen, Bathroom, Office, and Garage with individual lux levels (0-800).
📊
Weekly & Monthly Analytics
Weekly Sun-Sat line graph plus a Daily Usage analytics section that shows a vertical bar chart with months on the x-axis for the selected day across the year.
🌙
Screensaver Mode
Auto-activates after 30 seconds of inactivity. Shows time/date on starry background.
🎨
Customizable Wallpapers
Multiple background options including gradients, city scenes, and animated effects. Customize button, timezone, and info remain accessible even before login.
🌿
Eco & Sleep Modes
Eco mode fluctuates lux (e.g. 100-400) every 5s. Sleep mode dims lights for nighttime.
⚠️
Usage Warning
Alert notification when lights are on for 40+ minutes to promote energy saving.
👤
Profile Icon
Profile icon (top-right) shows logged-in email; click to open dropdown (logout). Login requires a valid email + password. First login stores hashed password; subsequent logins validate and show "Invalid password" if incorrect. Successful logins save user data (email, IP, userAgent) to user_data. Dashboard content is gated behind the login modal.
🕐
Timezone
Click clock icon to select from 8 timezones (PST, EST, CST, MST, AST, UTC, CET, IST). Defaults to UTC. Selected timezone updates time/date display and screensaver clock. Preference saved in localStorage.
📦
User View Box
Beside the weekly stats, a user-facing data view box shows MongoDB daily usage data based on selected month, date, and room dropdowns, with internal MongoDB _id hidden.
📝
Report an Issue & Feedback
Inside the Customize modal, a "Report an Issue" box lets users type up to ~600 words. Submissions are stored in the Feedback collection with PST date/time and are surfaced in the admin data-structure view.
🏢
Organization Admin Login
Admin access modal requires a username. An optional organization checkbox + textbox lets admins log in on behalf of an organization; these logins are written to both admin_access and Organization collections with date/time.