Extending Groser iOS and Rails apps to support grocery delivery in multiple cities - Part 2
Nov 30, 2015
This is Part 2 of multi part series about how I re-architect Rails and iOS apps to support grocery delivery in multiple cities to enable our new business model of selling SaaS solution to independent entrepreneurs wanting to create their own grocery delivery service. To understand rationale behind my decisions please read Part 1
Upgrading Client app search API
I use pg_search with scopes to search products by name. With ProductVariant I will need to narrow down Product search to specific store by ProductVariant. I will add Product.search scope, cause it will be used in multiple places.
I’m sure it can be optimized further, but I want to get it done in shortest time possible, so querying Product ids and then selecting ProductVariant will do for now.
Upgrading Shopper app search API
Next I need to upgrade shopper API which can search by Product name or barcode.
Since barcode can be universal as well as store specific (for bulk products), I query both Product.barcode and ProductVariant.barcode
Upgrading Order Dispatcher
Order dispatcher assigns incoming orders to available shoppers according to schedule set by shoppers. First, I need to query all active and available shoppers for the client’s city. I’ll delegate Order.city to associated User.
Next, I’ll add city query into shopper scopes, extracted into mixin.
Now I can begin working on OrderDispatcher. First I’ll handle easy case of admin customer placing an order, and then general case.
In Part 3 I will extend iOS app so that customers can change which city they are interested in and app will dynamically load Store with Shelves and Departments.