Class Diagrams - DistributedTravels/Documentation GitHub Wiki

Inter-service classes

Models

Models are special classes type which refer to communicates sent between services. They are presented in schemes placed below. In each scheme are these group of models which are handled by or are a result of handling by continuous services. In each scheme EventModel class is shown because it is base class for all models (with one exception; will be presented later).

Hotel models

"Hotel Service models"

Offers models

"Offers Service models"

Paymaent models

"Payment Service models"

Reservation models

"Reservation Service models" In above picture there is presented one model - ReservationTimeoutEvent - which does not inherit from EventModel

Transport models

"Transport Service models"

WebAPI models

"WebAPI Service models"

Intra-service classes

Event Consumers are classes which job is handling incoming events accordingly to the type of event. All of them implement IConsumer interface provided by MassTransit for RabbitMQ.

Data Transfer Object (DTO) class is a class used for transferring data between different services inside RabbitMQ messages.

Offers

"Offers Service Class Diagram"

Offers service provides two Entity Framework object-relational mapping classes providing possibility of database operations(These classes are presented on the right side of scheme):

  • OffersContext inherits DbContext - it's used for database connection and access
  • Trip - specifies all essential parameters about trips (includes hotel data, transport data, times of trip, information about number of people)

Event Consumers classes are also included in the service (they are presented in the top left corner of the picture). There are two events on which each adequate consumer reacts:

  • GetTripsFromDatabaseEvent
  • SaveOffersToDatabaseEvent

Functionalities used by consumers related to operations on database objects are extracted to an independent layer. These functionalities are GetTrips and SaveTrips methods declared in ITripsService interface and implemented TripsService class inheriting from mentioned interface. Interface and class previously described are presented in the middle bottom of a picture.

Offers service serves as orchestrator for getting offers saga. Because of that there is a OfferStateMachine class which maintains the saga. It reacts to another event - GetOffersEvent. There is also a StatefulOffer class inheriting from SagaStateMachineInstance which stores state of the saga and elements contained in it. Both OfferStateMachine and StatefulOffer are presented in the middle top of the picture.

Last group of classes are - shown in the left bottom corner - three DTO classes for obtaining adequate information:

  • TripDto
  • TravelDto
  • HotelDto

Reservations

"Reservation Service Class Diagram"

Classes grouped in the top-left corner are meant for saga orchestration.

  • StatefulReservation - contains current saga state and variables
  • ReservationStateMachine - orchestrates whole saga by transfering between different states and reacting to events

Classes on the bottom-left are consumers - their responsibility is to communicate with the database when their corresponding events are received.

  • GetReservationsFromDatabaseEventConsumer - gathers all reservations where userId equals the one present in event received
  • SaveReservationToDatabaseEventConsumer - saves received successful reservation to the database

The middle-top class is a DTO

  • ReservationDto - model used for transporting information from ReservationEntity

Classes in the top-right corner are repository classes.

  • ReservationsContext - a database context used for reading, modifying and saving data
  • ReservationEntity - entity class for database reservation object representation

Finally, classes in the bottom-right are an abstraction layer between the repository and the rest of the service

  • IReservationService - interface declaring SaveReservation and GetReservations methods
  • ReservationService - class implementing IReservationService interface, which uses repository classes for communication with the database

Hotels

"Hotel Service Class Diagram"

Group of classes presented on the left side are Entity Framework object-relational mapping classes, whose role is creation and access to the database. Function of all these classes, except HotelContext, is to map their structure into database tables.

  • HotelContext inherits DbContext - it's used for database connection and access
  • Hotel - specifies hotels available in the service and information about them: name, country, facilities
  • Room - broaden information about hotels by types of rooms which can be reserved in each hotel
  • Reservation - store informations about reservations made upon rooms in hotels by users

On the right side are presented Event Consumers classes. Each consumer handles adequate events presented below:

  • GetHotelsEvent
  • GetInfoFromHotelEvent
  • ReserveRoomsEvent
  • UnreserveRoomsEvent

AdditionalFunctions class is also presented in the foregoing group, it is a static class which provides additional functionality used by consumers.

Single class in the center bottom serves as a DTO class for obtaining information about hotels.

Transport

"Transport Service Class Diagram"

The top group of classes are Entity Framework object-relational mapping classes for database creation and access. Aside from TransportContext, all other classes in that group are used for mapping their structure into database tables.

  • TransportContext inherits DbContext - it's used for database connection and access
  • Destination - specifies a travel destination and the distance to it from Poland
  • Sources - specifies a travel departure city
  • Travel - specifies details of a tranport means (flight) which consist of: departure time, destination and source, available seats and price for a person for that travel
  • Reservation - specifies how many seats are reserved for a certain reservation for a specific flight
  • Booking - specifies a history of booked (purchased) seats for specific travel

Second, bottom-left group of classes are Event Consumers. Transport service includes 7 consumers which handle following events:

  • BookTravelEvent
  • GetAvailableDestinationsEvent
  • GetAvailableSourcesEvent
  • GetAvailableTravelsEvent
  • ReserveTravelEvent
  • UnbookTravelEvent
  • UnreserveTravelEvent

Single class on the right is a DTO class for travel details.

Payments

"Payments Service Class Diagram"

Left class is an Event Consumer, it's job is handling ProcessPaymentEvent.

Right class is a DTO class for payment card credentials.

WebAPI

"WebAPI Service Class Diagram"

Classes are grouped into Controller with corresponding DTO classes for retrieving data from body of HTTP requests.