Mermaid zdroj
Diagram je ponechany ako zdrojovy text, ale otvoren v plnohodnotnom HTML obale, ktory sedàs overview dizajnom.
flowchart TD
subgraph Triggers["Event Triggers"]
EV1["User Registers"]
EV2["Group Admin Sends Invite"]
EV3["Scheduled Job\n(every minute)"]
EV4["Match status → postponed"]
EV5["is_final = true\n(result entered)"]
EV6["Score Recalculated\n(result corrected)"]
EV7["Tournament status → finished"]
EV8["Postponed match rescheduled\n(new scheduled_at set)"]
end
subgraph Jobs["pg_cron / VPS Scheduled Jobs"]
JOB1{"Match deadline\n- 60 min?\nPlayer has no tip?"}
JOB2{"Match deadline\n- 15 min?\nPlayer has no tip?"}
JOB3{"scheduled_at +\nmatch_duration + 30 min?\nis_final = false?"}
end
subgraph EmailTargets["Email Notifications"]
EM1["📧 Player — Registration Confirm"]
EM2["📧 Invited User — Group Invitation"]
EM3["📧 Player — Reminder (60 min)"]
EM4["📧 Player — Reminder (15 min)"]
EM5["📧 System Admin — Missing Result Alert"]
EM6["📧 All Group Players — Match Result + Points"]
EM7["📧 All Group Players — Result Corrected"]
EM8a["📧 All Group Players — Match Postponed\n(new time: [date])"]
EM8b["📧 All Group Players — Match Postponed\n(new time TBD)"]
EM8c["📧 All Group Players — Match Rescheduled\n(new time confirmed)"]
EM9["📧 All Group Players — Tournament Ended"]
end
subgraph PushTargets["Push Notifications — Phase 2 (Web Push / VAPID)"]
PU1["🔔 Player — Reminder (60 min)"]
PU2["🔔 Player — Reminder (15 min)"]
PU3["🔔 Player — Result + Points Earned"]
PU4["🔔 Player — Leaderboard Position Changed"]
PU5["🔔 Player — Match Postponed"]
end
EV1 --> EM1
EV2 --> EM2
EV3 --> JOB1
EV3 --> JOB2
EV3 --> JOB3
JOB1 -->|"Yes"| EM3
JOB1 -->|"Yes"| PU1
JOB2 -->|"Yes"| EM4
JOB2 -->|"Yes"| PU2
JOB3 -->|"Yes"| EM5
EV4 --> PST_DEC{"scheduled_at\nprovided?"}
PST_DEC -->|"Yes"| EM8a
PST_DEC -->|"No"| EM8b
EV4 --> PU5
EV8 --> EM8c
EV5 --> EM6
EV5 --> PU3
EV5 --> PU4
EV6 --> EM7
EV6 --> PU3
EV6 --> PU4
EV7 --> EM9
subgraph Fallback["Fallback Logic — Phase 2"]
FB["Push fails?\n(e.g. iOS < 16.4)"]
FB --> EM3
FB --> EM4
end
PU1 -.->|"if push unavailable"| FB
PU2 -.->|"if push unavailable"| FB
style Triggers fill:#dbeafe,stroke:#3b82f6
style Jobs fill:#fef9c3,stroke:#eab308
style EmailTargets fill:#dcfce7,stroke:#16a34a
style PushTargets fill:#fce7f3,stroke:#ec4899
style Fallback fill:#f1f5f9,stroke:#64748b