Come fly the friendly skies.
Meant to help start out with ZIO. Build an application that will handle airline bookings and subsequent flights. Will be limited to subset of features of a full-fledged application (or a realistic sim) due to its expressed purpose of serving as an aid in learning some of the more salient aspects of ZIO.
- Use ZIO
- Submission: clone this repo and set your remote to your personal, private repo. Once ready for evaluation, please add @zio-airlines as a collaborator
- a
build.sbt
is included with library versions specified. They were chosen as the latest w/ no known significant issues. However, you're welcome to choose whichever versions you prefer. - Help:
- The Zionomicon (Slack: #zionomicon) book is the ideal companion for this workshop. Particularly, chapters 2-4, 6-14,
20-21, 34-37, and, perhaps, 26 for pt. 4 and 5 could be considered essential. Also, while this book covers ZIO 2, ZIO
2 has changed considerably (e.g., no more
HAS
,ZManaged
) since the current edition was written. - zio.dev is a helpful resource/tutorial.
- The following Scalac blog posts are helpful:
- The Zionomicon (Slack: #zionomicon) book is the ideal companion for this workshop. Particularly, chapters 2-4, 6-14,
20-21, 34-37, and, perhaps, 26 for pt. 4 and 5 could be considered essential. Also, while this book covers ZIO 2, ZIO
2 has changed considerably (e.g., no more
- One flight per booking (1 or more seats).
- There are 40 seats per airplane.
- Booking will consist of the following stages:
- flight selection: flights are captured in
io.scalac.zioairlines.models.flight.FlightNumber
as a convenience but can be implemented or even specified differently at the discretion of the developer. - seat selection/assignment from available seats (since client code may not be able to guarantee that the seat selections input is not stale, there is the possibility that a subset of the seats have been occupied by another client. In said case, the error channel should wholly indicate which of the seats are no longer available)
- confirm booking
- flight selection: flights are captured in
- Once started, a booking will have 5 minutes for completion. If not completed within said time, booking will be invalidated and the seats therein become eligible for booking by any user.
- A booking can be cancelled at any time before the actual flight (reservation number is the only required parameter). Yes, flights in part 1 don't have an actual departure time. Therefore, cancellation for this part can be at any time.
- Ensure integrity in a concurrent-booking context but a whole flight should not be "locked" throughout the entirety of the booking process (i.e., flight selection, seat selection, and confirmation).
- Persistence is addressed in part 3 below. For training purposes, part 1 requires that no persistence provisions be made, however.
- You may notice that no client or UI is specified. For part 1, the only client required is ZIO Test. Please, make sure to test for concurrency correctness.
- Use ZIO-HTTP (and most likely ZIO-JSON) to make the application RESTful (For the adventurous type, there's a DSL under development that may make ZIO-HTTP more palatable)
- Endpoint API:
GET: /flights/
- returns an anonymous JSON array of all flight numbersPOST: /flights/{flight_number}/bookings/start/
- starts booking process and returnsbookingNumber
andavailableSeats
POST: /bookings/{booking_number}/select-seats/
- posts anonymous JSON array of selected seatsPOST: /bookings/{booking_number}/book/
- books flightPOST: /bookings/{booking_number}/cancel/
- cancels bookingGET: /booking/{booking_number}/
- returns booking:
{ "flightNumber": "string", "bookingNumber: "integer", "status: ["Started", "SeatsSelected", "Booked", "Expired", "Canceled"], "seatAssignments": [ { "passengerName": "string", "seat": { "row": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "letter": ["A", "B", "C", "D"] } } ] }
GET: /zio-airlines/flights/{flight_number}/available-seats
- returns available seats:
[ { "row": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], "letter": ["A", "B", "C", "D"] } ]
The year is 2027. ZIO Airlines only serves markets it has exclusive rights to and has also embraced an adhoc flight- operations model. Therefore,
- Once a flight is full and a plane is ready, the flight will be queued up for departure. Additionally,
- A plane needs 5 minutes to ready for next flight after landing.
- All the airports are single-runway.
- Each runway-use (i.e., landing or take-off) takes 1 minute.
- As a safety measure, there must be at least a 2-minute gap between runway-uses.
- The airports (coordinates provided in .conf (use ZIO Config)) are:
- GDN
- SFO
- IEV
- MAD
- SVO
- MEX
- Airplanes have an average speed of 1000 Km/h regardless of distance.
- ZIO Logging for queueing, departure, landing.
Unfortunately, emergencies are part and parcel of this industry and ZIO Airlines is no exception but, at the prodding of the associated government-powers-that-be, some mitigating procedures have been put in place:
- Every airplane of its fleet must send ZIO Central an "I'm-flying" signal (only when it actually is) every 10 seconds with its current location and fuel left.
- Every airplane, when given the signal to abort, must do so by landing on the nearest ZIO market.
- There is a possibility for planes to not make it to an airport either due to lack of fuel, crash, and/or terrorism. The latter should automatically send a fleet-wide abort signal.
- Once within proximity, landing priority shall be given to the plane with the least amount of fuel (consumed at a constant rate of 100 liters/h (every flight starts off w/ 10,000 liters of fuel)).