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.

This diagram shows only the main data path. It omits supporting mechanisms like the scheduled sweep and background event queue.

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.

The door-access interface is designed to be vendor-neutral, so different hardware vendors can be connected in the future. Honestly, as of today: only an internal simulated device is connected, to validate the full booking-to-access flow. No real door-hardware vendor is connected yet.

Design priorities

When design decisions conflict, they are resolved in this order:

  1. Data correctness: a booking must never be duplicated, lost, or corrupted
  2. Server-side authorization: every permission check happens in the backend; what the frontend shows or hides is never the authorization mechanism
  3. Single source of truth: spaces, bookings, access grants, credentials, and policies each have exactly one authoritative record, never two that could disagree
  4. Minimal, time-bounded privilege: door access is expressed as a time window, never a permanent grant
  5. Privacy by design: audit logs and de-identified usage analytics are kept separate and are never queried together
  6. Vendor neutrality: core business logic is never tied to one door-hardware vendor's interface
  7. Auditability: administrative actions always leave a tamper-evident record
  8. Usability and bilingual parity: the Chinese and English interfaces map to the exact same data and functionality

In practice: a system that responds more slowly but computes correctly and leaves an auditable trail takes priority over one that responds quickly but may compute incorrectly or leave no record afterward.

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