System architecture
How this system is built, from concept to implementation detail, for readers interested in the technical background. This page is updated as the system evolves.
System overview
The web frontend and the API are served by the same Cloudflare Worker, from the same origin. Every authoritative decision (whether a booking is allowed, whether it needs approval, whether access should be granted, whether an admin action is permitted) is made server-side; what the frontend shows or hides is never the authorization mechanism.
The system's authoritative records (spaces, bookings, access grants, credentials, policies) each have exactly one source-of-truth table; there is no second copy that could drift out of sync.
Request flow
A typical action (searching for a space, creating a booking, getting through a door) passes through these layers in order:
Browser
The web interface a user operates
Bilingual (Chinese/English) interface with a dark mode.
Cloudflare Worker
Web app + API, same origin
The sole point where identity and authorization are decided; sign-in state is tracked as a real server-side session.
Database
Cloudflare D1
Structured records: users, bookings, access grants, audit logs.
File storage
Cloudflare R2
Resource photos and similar files; the frontend reads them directly from a public URL, never proxied through the Worker.
Tech stack
Everything below is running in production today, not a proposal under evaluation.
Frontend
The web interface a user operates
React + TypeScript, built into static assets and served by the same backend Worker.
Backend
Business logic and authorization
Hono (a lightweight web framework), running on Cloudflare Workers, answering requests from the nearest edge location worldwide; sign-in supports both Google accounts and email/password.
Database
The system's authoritative data
Cloudflare D1 (a SQLite-compatible cloud database). Every schema change is applied through a version-controlled migration file; the schema is never mutated at startup.
File storage
Resource photos and similar files
Cloudflare R2 object storage.
State coordination
Consistency when multiple parties act on the same resource
Cloudflare Durable Objects, used to serialize booking-conflict checks for the same space, count login rate limits, and cache/revoke sessions in real time.
Design priorities
When design decisions conflict, they are resolved in this order:
- Data correctness: a booking must never be duplicated, lost, or corrupted
- Server-side authorization: every permission check happens in the backend; what the frontend shows or hides is never the authorization mechanism
- Single source of truth: spaces, bookings, access grants, credentials, and policies each have exactly one authoritative record, never two that could disagree
- Minimal, time-bounded privilege: door access is expressed as a time window, never a permanent grant
- Privacy by design: audit logs and de-identified usage analytics are kept separate and are never queried together
- Vendor neutrality: core business logic is never tied to one door-hardware vendor's interface
- Auditability: administrative actions always leave a tamper-evident record
- Usability and bilingual parity: the Chinese and English interfaces map to the exact same data and functionality
Security & data protection
The system includes cross-site request forgery (CSRF) protection, rate limiting on high-risk actions (such as login and booking creation), role-based least-privilege access control, and audit logging of administrative actions. Suspicious door-related activity (such as a burst of remote-unlock requests or sustained device sync failures in a short period) automatically triggers an alert to the operations team, which also maintains written incident-response procedures to follow.
For the full security and privacy details, see: Security ยท Privacy