Git Product home page Git Product logo

postmates's Introduction

Postmates

This is the heart of a delivery service. Features include geo-indexing, order-dispatch, proximity-searching, ETA, trip estimates, etc
We use google maps for features such as distance-matrix and directions
Find more documentation here

Inbuilt Features

  • geo-indexing
  • geo-radius search
  • ETA
  • order creation
  • order dispatch
  • order acceptance
  • order order rejection
  • customer login/signup
  • customer ratings

Requirements

  • Postgres
  • Redis
  • Uber H3

Architecture

  • We use websocket connections for realtime communications with courier and customers. The ws connections are store in-memory in a concurrency safe manner.
  • Couriers are indexed using uber's h3 geo-indexing library and grouped in redis.
  • When you perform a radius search(closest couriers), we use h3 to calculate all indices 2 levels at resolution 8, see image below. Then we query our courier index, powered by redis to find all the couriers in those locations. Then, we make a request using their lng/lats and the customer's lng/lat to google maps to get the distance and duration from the customer, then we sort that result, and then dispatch the order to these couriers in order of those closest the origin of the request. (See image
  • The couriers send location updates every 3 seconds. This allows us to know their locations in almost realtime.
  • The dispatch logic gives a courier 5 seconds to accept an order, after which it is sent to the next closest/available courier. If none of the available couriers accept the request, the process starts all over again, till someone finally accepts it.

Project Setup

  1. Clone the repo and make a copy of .env.sample as .env & update the env vars.
git clone https://github.com/gwuah/postmates.git
cp .env.sample .env
  1. Run the app using either :
go run main.go
go build main.go
./main

Demo

  • cd demo and run yarn to install all required dependencies.
  • run node electrons.js to initiate 3 couriers instances that are constantly sending location updates every 3 seconds
  • run node customer__delivery_request.js to instantiate a customer that will create a delivery request.
  • pay attention to the logs.

postmates's People

Contributors

andyosei avatar dawkaka avatar gwuah avatar oneeyedsunday avatar yeboahnanaosei avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.