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

Design a service for collaboratively planning trips, with bookings and changes.

Practice

AI answer

I would divide the system into services for trips, participants and access permissions, bookings, notifications, and supplier integrations. A trip stores the itinerary, dates, and participants; each change is a versioned event or record with its author and timestamp, so we can view the history and resolve conflicts. For concurrent editing, I would use optimistic locking based on the version: the client sends the expected version, and in case of a conflict receives the latest data and is offered the option to merge the changes.

A booking is a separate entity with states such as pending, confirmed, cancelled, and failed. Creation and modification are handled as a durable process: we record the request, call the supplier with an idempotency key, save the result, and handle retries. An external booking cannot be considered part of a single database transaction; timeouts, compensating actions, and status reconciliation are needed. I would publish notification events through a transactional outbox so they are not lost in case of a failure.

For DevOps: containerization, infrastructure as code, CI/CD with tests and migrations, gradual rollout, and the ability to roll back. Metrics and alerts should cover integration errors, latency, failed bookings, and queues; logs and traces should be correlated using an end-to-end correlation ID. Secrets should be stored in a secrets manager, and personal and payment data should be minimized and protected. Initially, a modular application and a queue are sufficient; services should be split out as load and team size grow.