7. Live System Status Dashboard
Repository:
Webpage (planovi-webpage)• Rule Prefix:BR-STS• Documented Rules: 6 • Open[TEAM_WHY_NEEDED]Questions: 2
1. Business Purpose & Actors
- Problem solved: Displays public real-time operational health and active maintenance windows for core PLANOVI platform modules (Dashboard, AI Agent, Modbus Gateway, Billing, Database) to customers and stakeholders.
- Actors: Cooperative administrators, end users checking service availability (
/statusor/status.php), Supabasepublicschema tables managed byplanovi-backend/ ops.
2. All Features & End-to-End Flows
- Flow A — Status Fetch & Rendering (
status.php:1-252):- Trigger:
GET /status(or/status.php). - Data Fetch: Calls
GET {supabase.url}/rest/v1/app_modules?select=*,app_modules_maintenance(*)withsupabase.key(10stimeout, noAccept-Profileheader → targetspublicschema). - Fallback: If
empty($modules) && !$fetchError(unconfigured Supabase or empty200 []table), populates 5 hardcoded Polish mock modules (DASHBOARD,AI_AGENT,MODBUS_GATEWAY,BILLING,DATABASE) with empty maintenance arrays. - Status Aggregation (
status.php:79-99): Iterates all modules and their nestedapp_modules_maintenancerows; any row with truthyis_under_maintenancesets$hasMaintenance = trueand appends to$activeMaintenances.$allOperational = !$hasMaintenance. - Render: Global status banner (
role="status",aria-live="polite", green operational vs amber#f59e0bmaintenance), responsive.status-gridof module cards (each showing first active maintenance message + formattedstart_time/end_timeind.m.Y H:i), and bottom section listing either active maintenance details or a static 90-day “no incidents” message.
- Trigger:
3. Hard Business Rules, Validations, Calculations & Edge Cases
- BR-STS-01 (False-Operational Bug on Upstream API Failure): When Supabase returns non-2xx or times out,
status.php:33sets$fetchError = truewhile$modulesremains[]. Line 38 skips mock fallback (!$fetchErroris false), lines 79-99 compute$hasMaintenance = false→$allOperational = true, and the page renders “All Systems Operational” with zero component cards and no error notice! - BR-STS-02 (Public Schema Coupling): Unlike all other queries in this repo (
websiteschema),status.php:13-21omitsAccept-Profile: websiteand relies onpublic.app_modulesandpublic.app_modules_maintenance(with a PostgREST foreign-key join) being readable bysupabase.key. - BR-STS-03 (Single Active Maintenance Display per Module Card): Each module card
breaks on the first maintenance record where!empty($m['is_under_maintenance'])(status.php:156-164), whereas the global$activeMaintenanceslist collects all active records across all modules (status.php:84-95). - BR-STS-04 (Static 90-Day Incident History): When
$activeMaintenancesis empty,status.php:228-234unconditionally displays"No recent incidents or maintenance events reported in the last 90 days."— it does not query historical closed maintenance windows. - BR-STS-05 (Hardcoded Polish Strings in EN View): Fallback module names (
status.php:42-73), default fallback title'Moduł'(line 166), and active maintenance timestamps'Początek:'/'Szacowany koniec:'(lines 221-222) remain in Polish even when$current_lang === 'en'. - BR-STS-06 (Non-Canonical URL & Back Link):
<link rel="canonical">points tohttps://planovi.app/status.php(status.php:110) rather than/status, and the back button links toindex.php(line 238).
4. State Machines & Data Lifecycle
Per-module binary display state derived from app_modules_maintenance[].is_under_maintenance:
operational(!isMaint→ green badge#32CA42/#22A830)under_maintenance(isMaint === true→ amber badge#f59e0b) Global banner state:operationaliff zero modules areunder_maintenance; otherwisemaintenance.
5. Technical Contract (Inputs → Processing → Side Effects)
- Endpoint:
GET /status(or/status.php). - DB Tables Read (owned by
planovi-backend,publicschema):public.app_modules(id,display_name,module_name,internal_module_code) joined withpublic.app_modules_maintenance(is_under_maintenance,maintenance_message,start_time,end_time,updated_at). - Side Effects: Read-only HTTP GET to Supabase PostgREST (
10stimeout); no writes or caching.
6. Cross-Repository Dependencies
| Caller → Callee | Protocol & Auth | Exact Endpoint / Contract |
|---|---|---|
planovi-webpage (status.php) → planovi-backend Supabase | HTTPS PostgREST (apikey + Authorization: Bearer, public schema) | GET /rest/v1/app_modules?select=*,app_modules_maintenance(*) |
7. Why It Works This Way (Decisions, Trade-offs & Workarounds)
- Direct reuse of
public.app_modules: Mirrors the exact maintenance gate tables used by the Flutter application so operators toggle maintenance in one database table and both app gates and the public status page reflect it immediately. [TEAM_WHY_NEEDED: When Supabase is unreachable ($fetchError === true), should status.php display a "Status temporarily unavailable / Degraded" banner and HTTP 503 instead of falsely reporting "All Systems Operational"?][TEAM_WHY_NEEDED: Does public.app_modules_maintenance store historical closed records (is_under_maintenance = false) that status.php should display in the 90-day incident history box?]
8. Debugging, Logs & Common Failure Modes
| Symptom / Error Message | Root Cause in Code | How to Verify | Fix |
|---|---|---|---|
| Page says “All Systems Operational” but component grid is completely empty | $fetchError = true (Supabase 401/403 RLS denial, missing FK relationship, or timeout >10s) (status.php:27-38) | curl -i -H "apikey: <key>" "<url>/rest/v1/app_modules?select=*,app_modules_maintenance(*)" | Verify RLS SELECT policy for anon on both public.app_modules and public.app_modules_maintenance and FK constraint |
| Page always shows 5 hardcoded Polish modules even when DB has different modules | supabase.url contains YOUR_PROJECT_ID, is empty, or public.app_modules has 0 rows (status.php:12,38) | Query SELECT count(*) FROM public.app_modules | Populate public.app_modules and verify supabase.url/key |