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

Design a system for managing access to a sports complex, with memberships and offline access control.

Practice

AI answer

I would divide the system into subscription management and a fast path for turnstile checks.

  • Services: an API and administrative interface for customers, plans, and subscriptions; an access service to check entry privileges; and integrations for payments and notifications.
  • Data: subscription, validity period, zone and time restrictions, suspension status, and pass ID. Changes are recorded in an audit log. Use a transactional database and idempotent commands for concurrent operations.
  • Access control: the reader sends the pass ID and access point to a local controller. The controller checks a signed local cache of rules and validity periods, opens the turnstile, and records the event. When connectivity is restored, events are synchronized with the server, with deduplication.
  • Offline mode: synchronize the minimum required data in advance, define how long it remains valid, and set rules for unknown or recently revoked passes. Choose fail-closed for sensitive areas; for ordinary entry, use an explicitly agreed availability policy. Limit how long the system can operate autonomously and alert the operator when connectivity is lost.
  • Security and operations: secure communications and key storage, minimize personal data, use role-based access, maintain logs, provide server redundancy, and monitor check latency, synchronization errors, and controller status.

I would test scenarios involving subscription expiration and revocation, repeated presentation of a pass, network outages, controller restarts, and connectivity recovery.