NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Middle1 view

Design a system for managing access to office buildings, including guests, parking, and calendar integrations.

Practice

Asked at

AI answer

Architecture

Separate the system into a cloud control plane and a local access environment:

  • API and web interface for employees, administrators, and security staff.
  • Identity and policy service: users, roles, zones, schedules, and access rules.
  • Visitor and parking service: invitations, reception check-in, passes, and parking spaces.
  • Calendar adapters (for example, Microsoft 365 and Google Calendar), operating through OAuth and webhooks.
  • Database for current state and an event queue for integrations, auditing, and notifications.
  • Local door and gate controllers: receive signed permission updates, cache them to keep working if connectivity is lost, and forward access events when the connection is restored.

Core entities

Person, Building, Zone, Credential, AccessPolicy, Visit, ParkingReservation, CalendarConnection, AccessEvent. Access rights are defined by a combination of subject, zone, time interval, and conditions; for a guest, they are limited to a specific visit.

Core workflows

  1. An employee creates an invitation with a date, time, building, zones, and parking if needed.
  2. The system checks limits and availability, creates a visit, and sends the guest a link or QR code with a short expiration period.
  3. At the entrance, reception confirms the visit and issues a temporary pass; the controller checks the authorization locally or through a secure service.
  4. When the visit ends, the pass is revoked, the parking space is released, and events are recorded in the audit log.

Calendar integration

A calendar event may offer to create a visit, but must not by itself grant physical access. Use minimal OAuth permissions, verify webhook signatures, and process duplicate and out-of-order notifications idempotently. Changes to or cancellation of an event update the visit according to predefined rules; store the source event ID and a change log.

Security and operations

Use SSO/MFA, RBAC, encryption for data and secrets, short-lived and revocable credentials, protection against QR code reuse, and a complete audit trail of administrative operations. Limit the retention of personal data and define a deletion period for guest data. During a network outage, controllers use a time-limited local cache; define the fail-open/fail-closed policy separately for each zone, while ensuring emergency exits always meet fire safety requirements. Monitor synchronization latency, controller status, calendar integration errors, and the queue of unsynchronized events.