Git Product home page Git Product logo

vehicle-tracker-api's People

Contributors

cad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vehicle-tracker-api's Issues

Can't create vehicle

According to API documentation (version 1.1.4) you should be able to create a vehicle by POST'ing only plate_id and type data but when you try this It returns a bad request (400) error.

Write docs

Swagger based API docs would help client developers very much.
And also a README.md

Implement endpoint set /agent/

As we discussed it became clear that using PlateID as the identifier for the
agents would be such a burden to the agent devs since everytime an agent moves
from a vehicle to another vehicle they'd need to reflash the firmware with the
new PlateID.

That's why we've decided to use UUIDs for the agents that will be kept forever
on the agent(unless we need to change id). In order to provide this
we need to create a new endpoint set for /agents/.

Here is the endpoint stub for getting the position from the agent,
that we all have agreed.

HTTP POST https://api.vehicles.neu.edu.tr/agents/<uuid>/sync

{
  "lat": "",
  "lon": "",  
  "ts": "" 
}

We decided that we should keep /vehicles/ endpoint for query purposes.
That means we'll also need a way to map those agents with vehicles(UUID <-> PlateID).

agent filter

Would be nice to filter for assigned or unassigned agents.

CORS headers are missing

Currently CORS headers are miasing in the responses. We need CORS to work with browser so we should include those headers somehow.

agentless vehicle can not be created

When you try to create a vehicle without agent_uuid, in a system that has no agents in database (agents are never been created);

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer 23cc0605-a2fc-4cfc-a403-233054625d0c' -d '{ \ 
   "plate_id": "AA111", \ 
   "type": "SCHOOL-BUS" \ 
 }' 'http://localhost:5004/vehicle/'
{
  "updated_at": "2017-09-12T14:49:22.938391664+03:00",
  "plate_id": "AA111",
  "agent": {
    "uuid": "",
    "updated_at": "0001-01-01T00:00:00Z",
    "label": "",
    "lat": "",
    "lon": "",
    "gps_ts": ""
  },
  "groups": null,
  "type": "SCHOOL-BUS"
}

you are able to create a vehicle without an agent assigned to it, an agentless vehicle.

But what you can not do is; when you try to create a vehicle without agent_uuid, in a system that has at least one agent, you ending up with a vehicle that an agent assigned to it.

For testing, lets create an agent for the first time and call it firstagent;

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer 23cc0605-a2fc-4cfc-a403-233054625d0c' -d '{ \ 
   "lat": "1111", \ 
   "lon": "1111", \ 
   "ts": "1111" \ 
 }' 'http://localhost:5004/agent/firstagent/sync'

And now when we try to create a vehicle without an agent;

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Authorization: Bearer 23cc0605-a2fc-4cfc-a403-233054625d0c' -d '{ \ 
   "plate_id": "BB222", \ 
   "type": "SCHOOL-BUS" \ 
 }' 'http://localhost:5004/vehicle/'
{
  "updated_at": "2017-09-12T14:59:22.943486352+03:00",
  "plate_id": "BB222",
  "agent": {
    "uuid": "firstagent",
    "updated_at": "2017-09-12T14:59:22.941804212+03:00",
    "label": "",
    "lat": "1111",
    "lon": "1111",
    "gps_ts": "1111"
  },
  "groups": null,
  "type": "SCHOOL-BUS"
}

it created with the first agent already assigned to it.

PS.: It doesn't matter how many agents you have in the system, you always ending up assigned to the first agent ever created.

empty input causes random entry from db to be deleted

When the argument value does not supplied to deleting endpoints, it causes delete a random entry instead since GORM scans the first element from the db that satisfies the filter, which is everything since the filter is empty.

set vehicle's groups

It's requested for clients to be able to set vehicle groups. Right now when a vehicle is created with any groups it's forever.

The preferred way is a PUT request.

Override swagger spec

We can load swagger.json specfile and override some of it's fields, such as
version or host fields dynamically.

Rewrite /vehicle/ endpoint set

Since we have separated vehicle tracking agent specific business layer from
/vehicle/ endpoint set. Now it can be rewritten in a way that query aspect
of the endpoint set will be in the spotlight.

Main features of this endpoint set would be:

  • Create a new vehicle
  • Setting meta-data for the vehicle
  • Setting which tracker the vehicle gets its location source
  • Querying vehicles based on:
    • vehicle type
    • vehicle group
    • vehicle unique identifier (PlateID)
    • vehicle geo location

Implement Authentication

Right now this project does not enjoy a full feature authentication mechanism.
This is needed before going into production.

All methods but 'GET' should be private.

Write event subsystem

The Project started as REST API only. But for the sake of keeping it real-time, we needed a WebSocket endpoint (see #10 ). In order to achieve this cleanly, we need an event subsystem that's easy and robust at the same time.

Replicate to a time series db

Currently, our server keeps only the last known position of an agent. It's better to replicate this data in the background to a time series database. Preferablly, to some Prometheus instance.

User can remove himself

User can remove himself successfully. It would be nice to return an error when you try to remove yourself as user.

Authenticated user credentials

It would be nice to return user credentials ( user's uuid, email etc.) on successful user authentication. Because at this moment there is no way to get uuid of the user who is signed in on the client-side.

return empty json values as null

We need to return empty json values as null. Right now they are retunred as the fiedl's zero value. e.g. "" for empty string.

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.