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

Selling groceries online using Postgres, Flask, Docker & Android by Petrus Janse van Rensburg

Pycon ZA
October 07, 2016

Selling groceries online using Postgres, Flask, Docker & Android by Petrus Janse van Rensburg

Startups are exciting. But choosing the right tech-stack can be a daunting task: You want to be able to move quickly right from the start, but also remain flexible as the technical requirements inevitably change.

In this talk I will describe my own experience of building out the tech stack for a mobile e-commerce startup. It will cover: • an overview of the main design challenges • the chosen architecture (database, server-side application layer, API and mobile client) • how I used Flask to build the API • how I used Flask-Admin to build a management console • deploying the backend application using docker-compose.

Pycon ZA

October 07, 2016
Tweet

More Decks by Pycon ZA

Other Decks in Programming

Transcript

  1. None
  2. THE OPPORTUNITY

  3. None
  4. Internet usage in Africa • 226 million smartphones (end 2015)

    • set to triple by 2020 http://www.gsma.com/mobileeconomy/africa/
  5. None
  6. THE CHALLENGE

  7. 1. Most smartphone users will still be stuck on slow

    / expensive connections for the foreseeable future.
  8. None
  9. 2. Only around 10 million fixed-line broadband subscriptions (for 1.2

    billion people).
  10. Existing e-commerce business models don’t do well in these conditions.

  11. Existing approach • Access to extremely large inventory. • Find

    an item by doing:
 Search + Filter + Scroll + Tap for details • Each step requires network
  12. Existing approach Example: Amazon’s Android app • 21 Mb data

    needed to buy 5 items • ~ 240 taps needed to place first order
  13. • We sell only groceries to people around Cape Town,

    through a dedicated Android app. • It’s the first step towards building a new kind of online retailer, that works well in emerging-market conditions. What do we do?
  14. None
  15. Our approach • Only the goods you need for solving

    a simple, everyday task (e.g. buying groceries for a household). • Dedicated app, with a simple UI that uses little data. • Only in a limited geographic area.
  16. Our approach How does it compare? • 21 Mb 0.25

    Mb data needed to buy 5 items • Works offline - you only need to be connected when proceeding to checkout. • ~ 240 taps 65 taps needed for first order
  17. None
  18. - Charles Eames “There is always a need for anyone

    that can do a simple job thoroughly.”
  19. Our approach

  20. None
  21. TECH STACK

  22. Postgres + PostGIS

  23. Flask + SQLAlchemy

  24. None
  25. None
  26. FlaskAdmin

  27. None
  28. None
  29. Docker + Docker- compose

  30. Vanilla Android

  31. Pitfalls

  32. 1. Android’s sheer complexity Pitfalls

  33. Blank app template starts with: • 48,3 MB on disk

    • 1 837 files & directories
  34. 1. Android’s sheer complexity Be patient with yourself Pitfalls

  35. 2. JSON handling in Android Pitfalls

  36. 2. JSON handling in Android
 
 use SQLite Pitfalls

  37. 3. Keeping sane with all the data models Pitfalls

  38. 1. Postgres tables 2. SQLAlchemy model classes 3. JSON API

    4. Client-side SQLite tables 5. Client-side Java model classes
  39. 3. Keeping sane with all the data models Keep it

    simple: de-normalise where possible Pitfalls
  40. 4. Slow upgrade cycle on Android Pitfalls

  41. 4. Slow upgrade cycle on Android Gracefully terminate support for

    old client versions Pitfalls
  42. Thank you! questions? Petrus Janse van Rensburg
 
 @petrusjvr
 


    petrus@timbuktu.io