Giter Site home page Giter Site logo

parking-api's Introduction

Toll Parking Library : APIs for a Toll Parking

Project created using:

  • Java 11
  • Spring Boot 2.2
  • Swagger 2
  • Prometheus Client
  • Mockito/ PowerMock
  • Maven

! The data is not persisted !

! This is not a multi-client API, i.e., one deployment per parking lot (client) is needed !

Requiments

Docker and docker-compose

Building

The project build is done using maven but inside a docker build image.

Like this we can assure that only the correct language version and libraries are going to be used.

To build and start the project:

docker-compose -f docker-compose.yml up --build

This will build the ParkingAPI and the ParkingAPI-TEST images. The compose will also download also Prometheus and Grafana.

Architecture

Project

This projects provides two services :

parkcar : That will reserve a parking spot based on the car type. takecar : Will release the occupied slot and return the amount to be paid.

for both services the Payload should be send in POST :

{"regPlate": "BM-009-GT", "type": "EV20KW"}

The API is documented using Swagger 2 and is available after the container start :

http://localhost:8080/swagger-ui.html

Project Configuration

The project configuration is done using an application.property file, that is passed as an argument in the docker container.

If you want to modify the configuration, please update the docker-compose.yml, service parking-api, with the correct file path.

Parking Setup

The parking setup is done using the configuration file, where you can set the number of spots per spot type.

Pricing Policy

For the moment we have only 2 price policies available. Future pricing policy can be done implementing the PricingService Interface.

The selected pricing policy will be selected using also the application.properties file.

Testing

Unit tests done with JUnit , using Mockito and Powermock for "mocks" and some reflection magic ( I know, this is bad :/ ).

A container for the Integration test is available in the docker-compose, with an ugly bash "testServices.sh" that will be non-stop requests to emulate some traffic.

Test coverage around 80%.

Used SonarLint for quality check.

Monitoring

The Application is setup to be monitored using Prometheus and Grafana.

Accessing http://localhost:3000/d/E3G83l9Wk/parking-api ( user: admin , pwd: admin ) you will have available a dashboard including technical and functional KPIs like:

JVM related metrics

API latency time

Parking Revenue per seconds

Parking Occupancy

Improvements

  • Implement Authentication (OAuth would be ok)
  • Add proper logs
  • Split the application in two different apps , Parking and Pricing , in a more microservice approach.
  • Persist data

parking-api's People

Contributors

topine avatar

Watchers

 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.