🌐 Closet · Education · Subdomain Architecture

每間學校 · 獨立 Subdomain

demo.closet.persontees.com · kcl.closet.persontees.com · Cloudflare Pages wildcard DNS · 學生見到自己學校嘅 branding

🏗️ DNS Architecture

Wildcard Routing · 一個 CF Pages Project

唔需要每間學校一個獨立 deployment。我哋用 Cloudflare Pages wildcard DNS + tenant routing, 所有 tenant 共用同一份 code, 但係睇到自己嘅 branding。

1
Wildcard DNS Record (一次設定)
*.closet.persontees.com → CNAME → persontees-home.pages.dev
2
Tenant Routing Middleware
window.location.host → tenant_id = host.split('.')[0]
3
Per-Tenant Config (D1 / KV)
D1: tenants table · KV: tenant_config:{tenant_id}
4
Dynamic Brand Override
CSS custom properties from tenant.branding → :root --primary, --accent
5
Isolated Student Data (PDPO)
All queries: WHERE tenant_id = {tenant_id} · row-level isolation
🎓 Live Tenants · 預設 Subdomain 列表

每間學校 · 獨立 Branding · 共享 Platform

demo.closet.persontees.com
示範學院
Demo Academy · 26-27 季度
REFERENCE CUSTOMER
kcl.closet.persontees.com
九龍真光中學
Kowloon True Light School
K-12 · 制服
cdhk.closet.persontees.com
中大校友會
CUHK Alumni Association
大學 · 校友會
kln-tigers.closet.persontees.com
青衣商會小學
青衣商會小學家長教師會
PTA · K-6
bgsk.closet.persontees.com
拔萃男書院附屬小學
Diocesan Boys' School Primary
K-6 · 精英
skhmc.closet.persontees.com
聖嘉勒女書院
St. Clare's Girls' School
K-12 · 女校
hkfc.closet.persontees.com
香港足球會
Hong Kong Football Club
興趣班 · 體育
hksy.closet.persontees.com
香港管弦樂團
Hong Kong Sinfonietta
制服團體 · 興趣班

每校獨立 Color Palette · 學生見到自己學校

Closet Education 唔係 one-style-fits-all。每間學校 register 時提供 Pantone codes (校徽 / 班色), 系統 auto-generate per-tenant theme。

demo.closet.persontees.com
示範學院
制服團體 · navy + gold + red
  • Pantone 287C navy
  • Pantone 872C gold
  • Pantone 186C red
  • 26-27 季度 868 學生
kcl.closet.persontees.com
九龍真光中學
K-12 · maroon
  • 校徽: Pantone 4625C
  • maroon + gold accent
  • 全校約 800 學生
  • 2026-27 秋冬季度
cdhk.closet.persontees.com
中大校友會
大學 · purple
  • 校友紫 + 校徽金
  • 5,000+ 活躍校友
  • Reunion 限定版商品
  • 校友證 login
kln-tigers.closet.persontees.com
青衣商會小學
PTA · green
  • 校隊 green 配色
  • 500 K-6 學生
  • PTA 主理
  • 家長 QR login
⚙️ 技術架構

點樣令到 Subdomain 即開即用?

🌐 Wildcard DNS
一次設定 · 自動支援任何 subdomain · 唔需要逐間學校加 record
*.closet.persontees.com CNAME persontees-home.pages.dev
📦 Single Deployment
所有 tenant 共用同一份 code · 改一次全體受惠 · 維護簡單
CF Pages project: persontees-home
🔍 Tenant Detection
前端讀取 subdomain → 即時 load 對應 tenant config · 0 後端 roundtrip
host.split('.')[0] → tenant_id
💾 D1 Tenant Config
每個 tenant 一行 record · Pantone / logo / domain · 改 settings 即時生效
SELECT * FROM tenants WHERE subdomain = ?
🔒 Row-Level Isolation
所有 D1 query 強制 WHERE tenant_id · 唔可能跨 tenant 撈 data
SELECT ... WHERE tenant_id = :tid
🎨 Dynamic CSS Variables
Brand color 由 tenant config inject · 一份 code 自動變身
:root { --primary: ${tenant.primary} }

🎯 Subdomain Architecture 嘅 6 個好處

🏫
Brand Identity 學生見到自己學校 logo / Pantone · 信任感 + 專業感
🔒
Tenant Isolation 學校 A 永遠唔見 學校 B 嘅 student data · PDPO compliance
🚀
Fast Onboarding 新學校 register → 即刻有 subdomain · 唔需要 DNS setup
⚙️
Single Codebase 1 個 CF Pages project · bug fix 全體受惠 · 維護簡單
📊
Custom Domain 學校可以將 subdomain CNAME 到自己 domain (e.g. swag.school.edu.hk)
🌐
SSL 自動 Cloudflare Pages 自動 SSL · wildcard cert · 唔需要手動 renew

🚀 想你嘅學校拎獨立 Subdomain?

客戶經理 24 小時內回覆 · 由註冊到 setup 5-10 分鐘 · 永久 SSL

📝 Apply 5 分鐘 📱 睇 Student App Demo