SlideShare a Scribd company logo
1 of 70
Download to read offline
Architecting    
E-­‐‑Commerce	
David Henner
github.com/drhenner
@drhenner
www.ror-e.com
Thank You to
the
Organizers
Architecting    
E-­‐‑Commerce	
DRH
Not
DHH
ror-­‐‑e.com
Google  Search
Key  to  Success
Your  Business  Guy
Options	
Spree
RoR_ecommerce
piggybak
Options	
Do it Yourself
Options	
Do it Yourself
Make  it  work  as  one	
Inventory
Merchandising
Cart
Orders
Shipping
Returns
Your  Business  Guy
Truth is I just like Tom Cruise
NOT
This is the time you need to
ask and educate.
Talking  Points	
•  Time Frame
•  Admin Areas
•  Expectations
•  What is MVP
•  How much are you going to Pay me?
•  …
•  Educate
Make  it  work  as  one	
Don’t Over Engineer
This slogan does not
give you an excuse!
Common  Issues	
Everything is an
after-thought
Shipping Returns
Coupons buy one get one
Marketing Low-stock
Security Password Reset
Common  Issues	
Cart knows too much
about the Order
Common  Issues	
Order doesn’t model
correctly to take
Shipping or returns into
account
Common  Issues	
Order needs to be
immutable at the time
of purchase
Inventory	
Good Starting point
Solution depends on
your business model
Your  Business  Guy
Inventory	
Good Practices
Inventory	
• Transactional
• Quantity determined in SQL
• NOT just Quantity available
• Inventory is its own model
(NOT just a number)
Inventory  
Option  1	
• id
• count_on_hand
• count_pending_to_customer
• count_pending_from_supplier
Inventory  
Option  1  (checkout)
Inventory  
Option  1  (&shipping)
Inventory  Lifecycle	
•  @ authorization =>
o  Add count_pending_to_customer
•  @ Shipment (payment)
o  Subtract count_on_hand
o  Subtract count_pending_to_customer
•  @ Return & restock
o  Add count_on_hand
•  @ Return & no restock
o  Do Nothing
•  Purchase Order (not discussed)
o  Add count on hand
•  Manual adjustments
o  Need a system that allows count_on_hand to be adjusted (things in stock
break)
Inventory  
Option  1	
• DO NOT USE MATH IN
RUBY
• SQL MATH!!!
Inventory  
Option  1  (advantages)	
• Easy to implement
• No need to “cleanup”
Inventory  
Option  1  (disadvantages)	
• Best to have a safety low
stock buffer
• Possible to be in checkout
and customer loses the item
Inventory  
Option  2	
• id
• Product_id (or variant)
• cart_item_id
• order_item_id
• status
• locked_at
Inventory  
Option  2
Inventory  
Option  2  (advantages)	
• Great for FLASH sale sites
• Can ensure you do NOT sell
more items than you have
• Great for etsy style sites
Inventory  
Option  2  (disadvantages)	
• Rescue if locking fails
• Free up inventory if
customer goes away
• One row in DB per item in
inventory
The  CART	
Good Practices
Your  Business  Guy
The  CART	
The Cart and your
Order are two different
Objects!
The  CART	
The Cart and your
Order are two different
Objects!!!!!!!!!!!!!!!!!!!!!!
The  CART	
• Is Stupid
• Is Simple
• Is non-deletable (martketing)
• Can be archived
The  CART  Items	
•  Id
•  User_id (not required)
•  Cart_id (in session)
•  Product_id (variant_id)
•  Quantity
•  Status (wish_list, cart, deleted…)
The  CART
The  CART	
NOTE:
add_product method
•  Make sure you have enough
Inventory to add to the cart
The  Checkout	
• SECURITY!
• 20 minute auto-logout
• SSL
• Encrypt Secure Data
• Do NOT store CC’s
The  Checkout	
• At the start of the
Checkout is when the
“cart” => “order”
The  Checkout
The  CART
The  Checkout	
Order Item
DOES NOT HAVE
QUANTITY!
The  Checkout
The  Checkout
The  Checkout
The  Checkout
The  Checkout
The  Checkout  
Out  of  context  of  talk
The  Checkout
The  Checkout
The  Checkout	
Payment
==
Authorized
Most  of  the  time
Your  Business  Guy
The  Checkout	
The Order is now
Immutable!
(only status can change)
Shipping	
Shipment
==
Capture Payment
Shipping
Shipping
Shipping
Returns	
• RMA (Return Merchandise Authorization)
• Return Item
o Condition
o Reason
Returns
Your  Business  Guy
More	
•  Accounting
•  Addresses (immutable)
•  Coupons
•  Deals (bye one get one free)
•  Sales
•  Marketing
o  Retargeting pixels
o  Track users progression
o  Upsell with recommendation Engines
•  All CC processors are not ===
Accounting	
•  dwmbeancounter.com/tutorial/Tutorial.html
Marketing	
• Recommendation Engines
o GEM - Recommendable
o GEM - Recommendify
• Track Users
o GEM - Ahoy
o Google analytics
o Mixpanel
o kissmetrics
Architecting    
E-­‐‑Commerce	
David Henner
github.com/drhenner
@drhenner
www.ror-e.com

More Related Content

Viewers also liked

I am not going to get up today!
I am not going to get up today!I am not going to get up today!
I am not going to get up today!
gracielazamora
 

Viewers also liked (7)

Explore and Prepare for YOUR Future
Explore and Prepare for YOUR FutureExplore and Prepare for YOUR Future
Explore and Prepare for YOUR Future
 
Internet 2
Internet 2Internet 2
Internet 2
 
The sprint goal as a business test
The sprint goal as a business testThe sprint goal as a business test
The sprint goal as a business test
 
I am not going to get up today!
I am not going to get up today!I am not going to get up today!
I am not going to get up today!
 
Testing in a continuous delivery world
Testing in a continuous delivery worldTesting in a continuous delivery world
Testing in a continuous delivery world
 
Coding Dojo In 5 minutes
Coding Dojo In 5 minutesCoding Dojo In 5 minutes
Coding Dojo In 5 minutes
 
Kanban
KanbanKanban
Kanban
 

Architecting ecommerce