Skip to content

Collection of (PoC) services to manage/monitor city public transport fleet.

Notifications You must be signed in to change notification settings

gmsecrieru/transport-monitor

Repository files navigation

transport-monitor

This is an application suite simulating distributed microservices that track and persist GPS emission from vehicles. In a real world scenario this would probably be splitted in different projects, but for simplicity's sake this is a single project with all solutions.

All configuration is currently based on a development environment (which is defined in src/config/dev.js) and assumes every transport-monitor service (and their dependencies) are running in containers in a single docker-machine (IP 192.168.99.100). Make sure to set it up for your needs before running/building the application suite.

Each application execution is described below, but before running any of the following instructions, you must install dependencies or build the Docker image:

Installing dependencies

$ cd transport-monitor
$ npm install

Building the Docker image

$ cd transport-monitor
$ docker build -t transport-monitor .

The suggested approach for running this suite is to start the services in the following order:

  1. Seeder - Create Message Queue and generate fake vehicle data
  2. Gateway - Receive GPS emissions and persist to a Message Queue system
  3. Consumer - Consume messages from queue, evaluates/validates and persist following business logic
  4. Emitter - Send fake emissions for each car generated by Seeder (once or each 20 seconds, based on EMITTER_RUN_ONCE environment variable)

You don't have to worry about all this (nor building the Docker image or initializing dependency storage services such as ElasticMQ, MongoDB and Elasticsearch) and can simply execute run-with-deps script:

$ sh run-with-deps.sh

Seeder

Initializes project depedencies and generates 1000 fake vehicles and stores in a MongoDB vehicles collection.

Usage:

Local execution

$ npm run seeder

> transport-monitor@0.1.0 seeder /Users/gmsecrieru/Projects/gmsecrieru/transport-monitor
> TASK_NAME=seeder babel-node src/index.js

[seeder] Done
$

Docker image

$ docker run -it -e TASK_NAME=seeder transport-monitor
[seeder] Done
$

Emitter

Emitter reads data persisted from Seeder and sends a fake GPS emission to Gateway.

Usage:

Local execution

$ npm run emitter
...
$

Docker image

$ docker run -it -e TASK_NAME=emitter transport-monitor

Gateway

Handles GPS emissions in an HTTP endpoint, which checks authorization and persists emission to a Message Queue for later processing.

Usage:

Local execution

$ npm run gateway
...
$

Docker image

$ docker run -it -e TASK_NAME=gateway transport-monitor

Consumer

Consumes GPS emissions from a Message Queue, validate and persist (or discard) information

Usage:

Local execution

$ npm run consumer
...
$

Docker image

$ docker run -it -e TASK_NAME=consumer transport-monitor

About

Collection of (PoC) services to manage/monitor city public transport fleet.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published