Skip to content

SirajChaudhary/comprehensive-example-on-microservices-using-spring-boot-with-spring-cloud

Repository files navigation

A comprehensive example on microservices using spring-boot with spring-cloud

It is a project for airport service.

In this project we have created six microservices for airport officials and airport passengers. These microservices provides services from passenger's ticket booking to passenger's boarding.

It has two more microservices one for eureka server and one for api gateway.

Watch the video


Microservice Purpose Note
airport-pilot-service
  • It is a microservice for airport officials
  • It is having APIs for PILOT such as createPilot, getPilotById, getAllPilots, updatePilot, deletePilot, findPilotsByDesignation & flushCache
  • airport-flight-service
  • It is a microservice for airport officials
  • It is having APIs for FLIGHT such as createFlight, getFlightById, updateFlight, deleteFlight & searchFlightBySourceDestinationAndDate
  • This microservice internally calls airport-pilot-service using OpenFiegn to get PILOT details.
    airport-booking-service
  • It is a microservice for airport flight passengers & airport officials
  • It is having APIs for BOOKING such as createBooking, getBookingById & findBookingByPNRNumber
  • This microservice internally calls airport-flight-service using OpenFiegn to get FLIGHT details.
    airport-security-service
  • It is a microservice for airport officials
  • It is having APIs for airport SECURITY check such as createSecurity, getSecurityById & findSecurityByBookingId
  • airport-checkin-service
  • It is a microservice for airport officials
  • It is having APIs for airport CHECKIN service such as createCheckin, getCheckinById & findCheckinByBookingId
  • airport-boarding-service
  • It is a microservice for airport officials
  • It is having APIs for BOARDING findBoardingByBookingId
  • This microservice internally calls airport-booking-service, airport-checkin-service, airport-security-service using OpenFiegn to get BOOKING, CHECKIN, SECURITY CHECK details.
    eureka-server It is a microservice for service discovery and registry
    api-gateway It is a microservice work as a gateway (single entry point) for all microservices

    Microservice Architecture

    microservices-architecture

    Technology Stack

    HowTo

    Step 1. Database Setup (you can use MySQL Workbench)

    • create schema CREATE DATABASE airportdb
    • create tables by running dump file airportdb.sql

    Step 2 (optional). Download and Run the Zipkin Server to trace Sleuth logs on GUI.

    Step 3. Configure lombok for your eclipse IDE (i.e. run lombok.jar)

    Step 4. Clone the project

    git clone https://github.com/SirajChaudhary/comprehensive-example-on-microservices-using-spring-boot-with-spring-cloud.git

    Step 5. Import the project into your eclipse IDE

    Step 6. Update following properties

    • update your database credentials in the .properties file wherever it is used in all microservices.
    • update YOUR_GMAIL_USERNAME/YOUR_GMAIL_PASSWORD in the .properties file of airport-booking-service.

    Step 7. Build all microservices mvn clean install
    - we build microservices in the following sequence and before that we set Java Build Path of each microservice to JDK11

    • eureka-server
    • api-gateway
    • airport-pilot-service
    • airport-flight-service
    • airport-booking-service
    • airport-security-service
    • airport-checkin-service
    • airport-boarding-service

    Step 8. Run all microservices in the following sequence.

    • eureka-server
    • api-gateway
    • all microservices one by one in any sequence

    Step 9. Run APIs in the following sequence for the first time using Postman or OpenAPI
    - Import the attached postman collection into postman client.

    • airport-pilot-service
    • airport-flight-service
    • airport-booking-service
    • airport-security-service
    • airport-checkin-service
    • airport-boarding-service

    Snapshots

    Eureka Server

    http://localhost:8761/ http://localhost:8761/

    OpenAPI

    swagger-ui will be used just for testing purpose. It won't route via API Gateway. We run like an independent swagger-ui of each microservice.

    Postman

    API calls will route via API Gateway (2021) only!

    URL: localhost:2021/airport-pilot-service/api/v1/pilots
    Method: POST
    RequestBody: { "name": "Ashutosh Sharma", "designation": "Sr. Captain", "experience": "22 Year" }

    URL: localhost:2021/airport-flight-service/api/v1/flights
    Method: POST
    RequestBody: { "vendor": "AirIndia", "source": "Delhi", "destination": "London", "departureDate": "08/08/2021", "departureTime": "10:15pm", "status": "On Time", "pilotId": 1 }

    URL: localhost:2021/airport-booking-service/api/v1/bookings
    Method: POST
    RequestBody: { "fullname": "Bill Gates", "mobile": "9100800123", "email": "mr.billgates@yahoo.com", "address": "stree1, adambakham", "flightNumber": 1 }

    URL: localhost:2021/airport-security-service/api/v1/securities
    Method: POST
    RequestBody: { "identityProof": "passport", "covidReport": "-ve", "ctScan": "done", "status": "done", "bookingId": "1" }

    URL: localhost:2021/airport-checkin-service/api/v1/checkin
    Method: POST
    RequestBody: { "checkInBags": "5", "cabinBags": "2", "bookingId": "1" }

    URL: localhost:2021/airport-boarding-service/api/v1/boardings/find-by-booking-id/1
    Method: GET

    output

    Similarly there are a bunch of APIs (e.g. create/read/update/delete/findByXXX) in each microservice which you can explore yourself easily.

    License

    Free Software, by Siraj Chaudhary

    About

    A comprehensive example on microservices using spring-boot with spring-cloud.

    Topics

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published