#75 Aggregate Documents/Sync
Itinerary Management
Keep one up-to-date trip plan that combines flights, hotels, cars and activities, even when bookings change or come from email.
What is being asked
Design itinerary management: the "My Trips" screen. A trip groups many bookings, some made on the site, some forwarded from email confirmations, plus notes the traveller adds. It must reflect schedule changes and work offline on a phone.
Requirements
Functional
- Create a trip; add bookings automatically and items manually.
- Show a day-by-day timeline in local times.
- Share the trip with fellow travellers; export to calendar.
Non-functional
- Changes from suppliers (new departure time) appear within minutes.
- Works offline on mobile and syncs later.
- Read-heavy around travel dates.
Design
- A trip is stored as one document (trip header + a list of segments), which matches how it is read: always as a whole.
- Segments reference their source booking; when a booking event arrives (flight retimed), the matching segment is updated.
- The email parser turns forwarded confirmations into structured segments.
- The mobile app keeps a local copy; the sync service exchanges changes using per-segment versions.
Key decisions and trade-offs
- Document vs relational. Reading a trip is one fetch from a document store; relational tables need joins but make cross-trip queries ("all trips to Goa") easier. Many systems keep both.
- Conflict handling. If a traveller edits a note offline while a booking update arrives, merge per field; system fields (times) win over user fields only for booking data.
- Store times with time zones. A flight that departs 23:30 in Delhi and lands 05:00 in Dubai crosses dates; always store UTC + the local zone.
- Sharing means access control per trip, not per user.
Follow-up questions
- How do you match a forwarded email to an existing trip?
- How do you notify a shared traveller about a change?
- How would you support "move my whole trip by one day"?
- What happens to the itinerary when a booking is cancelled?