Coder Social home page Coder Social logo

oye-rickshaw-assignment's Introduction

Driver location Tracker

#Explanation Currently this project contains two rest endpoints. The first endpoint return all the drivers near to given location and other endpoint allow us to update drivers locations. All the data is stored in mongodb.

You can checkout deployed api at https://or-demo.herokuapp.com/

Try out https://or-demo.herokuapp.com/api/v1/drivers/77.054411/28.643839 it will return all the drivers within 200 meter of the given location

If you want to update the location of one the drivers make post request to https://or-demo.herokuapp.com/api/v1/drivers/location with following json data

{
    "id": "string",
    "lng": "string",
    "lat": "string"
}

Please don't forgot to use content-type: application/json on headers. I am sharing all the drivers ids so you can try out and change driver locations

Driver IDS

6082d33e409f9fdcaaae741e
60840890e136e7e1e8be4fc5
6085730fda7e60533c098a94

Things can we improved

Currently this demo application does not have complete data validation. If you send some random data it may crash. This can be easily avoided by adding more validations.

API Reference

Get all the drivers within 200 meters

  GET /api/v1/drivers/lng/lat
Parameter Type Description
lng string Required. longitude of the pessanger
lat string Required. Latitude of the pessanger

Update drivers location

  POST /api/v1/drivers/location
Parameter Type Description
id string Required. Id of the driver
lng string Required. longitude of the Driver
lat string Required. Latitude of the Driver

API Reference

Get all the drivers within 200 meters

  GET /api/v1/drivers/[lng]/[lat]
Parameter Type Description
lng string Required. longitude of the pessanger
lat string Required. Latitude of the pessanger

Update drivers location

  POST /api/v1/drivers/location
Parameter Type Description
id string Required. Id of the driver
lng string Required. longitude of the Driver
lat string Required. Latitude of the Driver

make sure post request contains content-type: application/json header

Deployment

Prerequisite

  1. Python3
  2. Mongodb

Installation backend

  1. Git clone current project
  2. Run pip install pipenv
  3. run pipenv install
  4. run export FLASK_APP=app.py
  5. run export FLASK_ENV=[development|production|testing]
  6. run export FLASK_DEBUG=[1|0]
  7. run export DATABASE_URL=[mongodb connection url]
  8. run flask run to start server

Database

  1. Create mongodb database with or name
  2. Create drivers collection
  3. Add 2dsphere index on loc field by running db.createIndex({"loc": "2dsphere"})
  4. drivers collections schema
{
    "name": "string",
    "license": "string"
    "loc": {
        "type": "Point",
        "coordinates": ["longitude", "latitude"]
    }
}

The loc field is GeoJson format you can read about it here https://docs.mongodb.com/manual/reference/geojson/

oye-rickshaw-assignment's People

Contributors

sagarkaurav avatar

Watchers

James Cloos avatar  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.