Skip to content

quanndh/parking_tracker

Repository files navigation

Nest Logo

Installation

$ yarn

Running the app

# development
$ yarn start

# watch mode
$ yarn start:dev

# production mode
$ yarn start:prod

# DOCKER
$ docker-compose up

Example api

http://localhost:3000/api/carparks/nearest?limit=10&page=1&latitude=1.3025452&longitude=103.9043758

Introduction

This project includes Nestjs, Postgres, Redis.

After boostraping the app, a job will be executed to collect car parkings data.

# at ./src/module/parking/services/parking.service.ts
onModuleInit() {
  return this.initData();
}

Another job will also be executed to first time fetching available car parking, so the api is ready to served after this 2 job are finished.

# at ./src/module/cronjobs/services/parking_lot.service.ts
 onModuleInit() {
    this.syncParkingLot();
  }

The second job is also scheduled to execute every minute to update newest data.

All parking lots data are stored to Redis with the parking_code as key (this field is indexed) because they only update 1 per minute but can be read a lot. Geometry search was done by using Redis geometry apis. With these design, it makes the searching fast and scalable.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published