NanSOS Docs
Architecture
สถาปัตยกรรมแบบ Next.js full-stack บน Vercel + Supabase เป็นระบบข้อมูล ความปลอดภัย และ realtime
ภาพรวมชั้นระบบ
┌─────────────────────────────────────────────┐
│ Clients │
│ Citizen PWA · Operator Console · Team App │
└──────────────────┬──────────────────────────┘
│ HTTPS
┌──────────────────▼──────────────────────────┐
│ Next.js (Vercel) │
│ App Router · API Routes · Middleware RBAC │
│ AI proxy · Media upload · Push / Notify │
└──────────────────┬──────────────────────────┘
│
┌──────────────────▼──────────────────────────┐
│ Supabase │
│ Postgres + RLS · Auth · Realtime │
│ Storage (incident-media, hero-banners) │
└────────────────────────────────────────────┘สัญญาโดเมน (Domain Contract)
เอนทิตีหลักถูกนิยามใน src/lib/types.ts ให้สอดคล้องกับตารางใน supabase/schema.sql — UI อ่านจาก store ที่ซิงก์กับ Supabase ไม่ผูก UI กับ SQL โดยตรง
- incidents + locations / people / media / voice / status_history
- rescue_teams + rescue_assignments
- profiles (role: admin | operator | viewer | rescue)
- hero_slides, push_subscriptions, integration_secrets, audit_logs
หลักการออกแบบสำคัญ
- Single store seam (src/lib/store.tsx) — จุดแทนที่ mock → live data
- Semantic colors: critical / urgent / safe / info
- Thai UI, touch targets ≥ 48px บนหน้าประชาชน/ทีม
- Config แยกจาก secrets (system_config vs integration_secrets)