Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gett Delivery - Breaking the State Machine

Oren Kosto
January 30, 2019

Gett Delivery - Breaking the State Machine

Learn How Gett Delivery leveraged Firebase and RxSwift to break its state machine, creating an architecture suited for the delivery world.

Oren Kosto

January 30, 2019
Tweet

Other Decks in Technology

Transcript

  1. About Myself • Oren Kosto ! • Embarrassing Husband/Dad •

    Communication Systems Engineer • Writing code for a living for the last 5 years $ • iOS & Web Developer @ Gett for 1 year • Multi-disciplinary, Generalist • First time speaking in a tech meetup... orenk86 oren.kosto oren-kosto
  2. Gett Growth • Expanding Gett's capabilities and services beyond the

    world of taxis • Developing additional products on top of Gett’s existing infrastructure
  3. What are we going to talk about? • Gett Delivery

    Reboot • (Breaking) State machines
  4. The “Traditional” Taxi Ride • On demand ride • Each

    passenger needs a dedicated driver • Deterministic process: • Order • Find a driver • Pickup • Drop Off • Charge • Built with state machines
  5. Gett Delivery • On Demand deliveries • Every Package needs

    a dedicated courier • Same deterministic process as a taxi • Built using Gett’s existing taxi infrastructure • Taxi ride state machine
  6. Gett Delivery - DaaS • Delivery As A Service •

    Same hour, same day, next day • Parcels are delivered from a depot to multiple drop-off points during the day • Higher paying multi-point future jobs for couriers • Same supply, much higher capacity
  7. Gett Delivery - DaaS • Delivery As A Service •

    Same hour, same day, next day • Parcels are delivered from a depot to multiple drop-off points during the day • Higher paying multi-point future jobs for couriers • Same supply, much higher capacity
  8. Challenges Optimistic UI Offline Functionality Changes On The Fly Process

    Not Deterministic Conflict Resolution Event Management Connectivity & Sync Recovery
  9. Structure • Firebase Realtime Database & Cloud Functions • RxSwift:

    Firebase events wrapped in Observables • MVVM: View Model for every UI component - per action • Dependency Injection with Swinject • Protocol Oriented (action types, services) • (Almost) Stateless
  10. Implementation Map View Drive To Pickup VM Complete Action View

    MappableAction Presentable CompletableAction Presentable ContactableAction Presentable Call Recipient Component MappableAction ViewModeling CompletableAction ViewModeling ContactableAction ViewModeling Map View VM Complete Action VM Call Recipient VM Drive VC
  11. Implementation Firebase Service Driver Actions Service Analytics Manager Delivery Service

    GetTogether MultiPickup VM Delivery Collect VM Deliver VM Return VM Drive To Pickup VM Drive To Drop-Off VM
  12. Implementation Firebase Service Driver Actions Service Analytics Manager Delivery Service

    GetTogether MultiPickup VM Delivery Collect VM Deliver VM Return VM Drive To Pickup VM Drive To Drop-Off VM
  13. Our Experience • The Good • Firebase Realtime DB -

    Just works • Isolated the “problem” to one place, single source of truth • Extremely modular, highly reduced the cost of adding features • Minimized regression bugs • The Ugly • Firebase - Easy to abuse, expensive. Use it wisely • Multiple copies of the data on the server - must avoid conflicts • Hard learning curve, might seem like over-engineering at first • Cloud functions - hard to debug, hard to change, no version control