Home

Awesome

Build Status

Overview

The idea of this project

The Domain and Bounded context

The example is regarding online booking/checkin for an airline company. An airline company named 'RestAirline' is offering online booking/checkin. There are four possible Bounded context for above business:

The Microservices and communication

Generally each bounded context can be build as a standalone Microservice, For now I just created two Microservices: Booking and FlightAvailability. There are some interactions between these two Microservices, the obvious action is when passenger selected flight in Booking Microservice, The available amount of flights in FlightAvailability Microservice should subtract corresponding amount. The idea is when passenger selected a flight in Booking service, A event named JourneysSelectedEvent will be published to message bus, Any Microservices who are interested in this event can subscribe this event and handle it.

How to Run

Clone this repo

git clone https://github.com/twzhangyang/RestAirline.git

Running the container

Then spin up a new container using docker-compose

docker-compose up

Note: add a -d to run the container in background

An API service and mssql will run in docker

Run in local

This project based on .NET Core 3.1, please install corresponding SDK for your operating system:

After installing, please run below command to make sure current .NET Core version is 3.1.101 dotnet --version

Run the API

1. Try to input home api link in Postman:

GET http://localhost:61200/booking/home/


2. Select Journeys

Journey items should come from another micro-service named flight availability, for now let's build a journey in the api automatically for convenience. So you need not pass any journey id to this api.

POST /booking/journeys

add journey

3. Add passenger

We can get request body schema from last Api response become the whole Api is designed by Hypermedia. The api definition is totally described by last api response under resourceCommands\addPassengerCommand:

"addPassengerCommand": 
{
    "bookingId": "booking-352cb1f3-0f68-4e04-a2f7-24036eb53ce7",
    "name": null,
    "passengerType": 0,
    "age": 0,
    "email": null,
    "postUrl": {
        "uri": "/booking/booking-352cb1f3-0f68-4e04-a2f7-24036eb53ce7/passenger"
    }
}

Obviously the endpoint is:

http://localhost:61100/booking/booking-352cb1f3-0f68-4e04-a2f7-24036eb53ce7/passenger

The payload schema is:

{
	"bookingId": "booking-352cb1f3-0f68-4e04-a2f7-24036eb53ce7",
    "name": null,
    "passengerType": 0,
    "age": 0,
    "email": null,
}

bookingId is filled already, please try to fill other parameters, eg:

{
	"bookingId": "booking-352cb1f3-0f68-4e04-a2f7-24036eb53ce7",
    "name": "test",
    "passengerType": 0,
    "age": 22,
    "email": "test@test.com",
}

Send request:

POST booking/{bookingId}/passenger

add booking

4. Get booking

According to response of last api, you can either get the booking by resourceLinks or post data by resourceCommand.

GET /booking/{bookingId}

get booking

5. Update passenger Name

Business

The example is regarding online booking for an airline company. An airline company named 'RestAirline' is offering online booking.

2h <= timeWindow <= departure time - 30m