Git Product home page Git Product logo

garage's Introduction

Frank's garage

  • Architecture
    garage

API Documentation

Technology stack

  • Java 11
  • Spring Boot 2+
  • Basic Authentication
  • Maven Build
  • Environment: Embedded Tomcat
  • Deploymnet: Docker container

Instructions to run

With Docker:

  • Need to have git installed. Clone the project: git clone https://github.com/vishnuvuyyur1/garage.git
  • Need to have docker installed.
  • Command prompt: From insider the project folder mock-api
  • Step1: build the project : docker build -t mock-api-image .
  • Command prompt: From insider the project folder garage-api
  • Step2: build the project : docker build -t garage-api-image .
  • Step3: to run: docker-compose up (pulls image and starts the mongoDB, starts mock-api, garage-api)
  • Base URL: http://localhost:8080/garage/api/v1

Approach:

  • A microservice with its own database with a well defined set of functinatlity. And runs in a containerized environment.
  • A reactive approach down to the databse to enable the API respond in a non-blocking and event based to improve performance.
  • Phase 1 used a mock-api that returns a json from a json file. The content of json file is : https://api.jsonbin.io/b/5ebe673947a2266b1478d892
  • To list all the available cars : Used spring web flux to reactively interact with 3rd party apis (mock-api), using this library enables our client to perform HTTP requests and providing asynchronous behaviour i.e the rest call need not wait till response comes back. Instead when there is a response, a notification will be provided.
  • Get Response from mock api data which has cars that are grouped under warehouses and aggregate the results of all warehouses by parallel processing to one list of custom Car POJO.
  • By utilizing the parallel processing of data using streams the performance is optimized.
  • phase 2 Track the traffic: To track the traffic on 3rd party api, used a counter for each request than can result in either 200, 4XX, 5XX. update the counter based on the result from the 3rd party api(mock-api) in DB.
  • phase 3 Allow Frank to add, update, delete car to the store. A collection with Car is used for this purpose. Used mongo NoSQL Db.
  • Reactive Mongo DB NoSQL database enabling a reactive interaction with DB, a nosql Db is document orientend enables storing of data together in documents.

End points:

Mock API : http://localhost:8080/mock/garages returns a mock json referred from https://api.jsonbin.io/b/5ebe673947a2266b1478d892
Garage API Base URL: http://localhost:8080/garage/api/v1
Basic Authentication
user name: user
password: password

Garage API Operations:

No Operation Endpoint Method Phase
1 get warehouses cars /warehouses GET phase 1
2 get 3rd party traffic results /traffic GET phase 2
3 add car /cars POST phase 3
4 update car /cars PUT phase 3
5 delete car /cars/{id} DELETE phase 3

1. get warehouses cars: Interacts with 3rd party API (Mocki ApI)

  • URI: /warehouses
  • Method: GET

Request Body : None

Response :

[
    {
        "id": 57,
        "year": 1996,
        "model": "Q",
        "make": "Infiniti",
        "price": 28773.14
    },
    {
        "id": 56,
        "year": 1994,
        "model": "del Sol",
        "make": "Honda",
        "price": 18840.96
    },
    {
        "id": 73,
        "year": 2010,
        "model": "Legacy",
        "make": "Subaru",
        "price": 24491.8
    },
    {
        "id": 75,
        "year": 1985,
        "model": "Skyhawk",
        "make": "Buick",
        "price": 10567.27
    },
    .
    .
    .
 ]
  

2. get traffic results of 3rd party API

  • URI: /traffic
  • Method: GET

Request Body
Attributes Type Allowed values Required
status string 200, 4XX, 5XX, TOTAL yes
trafficCountType ENUM MAX,MIN,AVERAGE yes
{
    "status": "200",
    "trafficCountType": "MAX"
}

Response : count: Int, eg 8

3. add car

  • URI: /cars
  • Method: Post

Request Body
Attributes Type Validation Required
id number min 1 yes
year number min 1500 yes
make string any string yes
model string any string yes
price decimal number min 1 yes
{
    "id":1,
    "year": 2002,
    "model": "swift",
    "make": "suzuki",
    "price": 1299.99
}

Response

{
    "id":1,
    "year": 2002,
    "model": "swift",
    "make": "suzuki",
    "price": 1299.99
}

4. update car

  • URI: /cars
  • Method: Put

Request Body
Attributes Type Validation Required
id number min 1 yes
year number min 1500 yes
make string any string yes
model string any string yes
price decimal number min 1 yes
{
    "id":1,
    "year": 2002,
    "model": "swift",
    "make": "suzuki",
    "price": 4299.99
}

Response

{
    "id":1,
    "year": 2002,
    "model": "swift",
    "make": "suzuki",
    "price": 4299.99
}

5. delete car

  • URI: /cars/{id} eg: /cars/1
  • Method: DELETE

Response : none

APP Documentation

Technology stack

  • Angular 9
  • css
  • Bootstarp 4
  • Type Script
  • npm Build
  • Environment: Browsers (google chrome, firefox etc)
  • Deploymnet: Docker container

Instructions to run

With Docker:

  • Need to have git installed. Clone the project: git clone https://github.com/vishnuvuyyur1/garage.git
  • Need to have docker installed.
    Run Mock Api: If not already running from above
  • Command prompt: From insider the project folder mock-api
  • Step1: build the project : docker build -t mock-api-image .
  • Step1: run the api: docker run --name mock-api-container -d -p 8083:8083 mock-api-image
    Run APP
  • Command prompt: From insider the project folder garage-app
  • Step1: build the project : docker build -t garage-app-image .
  • Step1: run the api: docker run --name garage-app-container -d -p 4200:80 garage-app-image
  • Base URL: http://localhost:4200

Approach:

  • A single page application and pure component based approach. And runs in a containerized environment.
  • A service layer to interact with the API to fetch the results. 3rd Party API : http://localhost:8080/mock/garages returns mockdata reference: https://api.jsonbin.io/b/5ebe673947a2266b1478d892
  • Phase 1: Display of all cars: car-diplay components displays the cars from franks garage sorted baesd on date added
  • Phase 2: show details of a car: car-details compnent displays the details of a particular car
  • phase 3: shpping cart: shopping-cart component is display the cars added by user to checkout
  • car-board component: a parent component with two child components car-diaply, shopping-cart and handels the communication between child components.
  • Includes navigation : when a user clicks on view details of a particular car we navigate to anoter route to display the results, and user go back to cars diplay. The reason for this mechanish is to fetch fresh load of cars every time a user navigates to cars display.
  • Additional Futures: Search, sort, pagination, control to dispay no of cars 10,25,50 etc

Results:

  • Phase 1
    image
  • phase 2 image
  • phase 3 image

Useful docker commands for independent DB contianers to work with other apis

Run Database

  • Step1: pull the image - docker pull mongo
  • Step2: Run the DB - docker run -d -p 27017-27019:27017-27019 --name mongodb mongo

garage's People

Contributors

vishnuvuyyur1 avatar

Watchers

 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.