# Create application architecture based on microservices ## Application requirements **Trips:** An organizer can create trips. An organizer should add packages to trips. Each trip can have an unlimited number of packages. Each trip should have at least one package. **Draft Trip:** When an organizer first creates a trip, it is draft and it cannot be seen by anyone. When the organizer publishes the trip, the system creates a published version of the trip and it is visible to everyone. **Published Trip:** After organizer creates draft trip he can press publish button and this trip will be available to public. ### Publishing process Before a trip was published first time there only draft version of the trip. When organizer publish a trip, all the changes made in draft version of the trip/packages (changed trip title, changed number of packages and their names/prices, etc.) apply to the published version of the trip. Regular users always see only published version of the trip and all their manipulations in the system should be made on published version of the trip (bookings, reporting etc.). But, the organizer manipulations (trip editing, adding/removing/editing packages, etc.) should be done in draft version of the trip and can be seen only by organizer. After publishing the trip, the organizer can edit it again (changed trip title, changed number of packages and their names/prices, etc.). These changes are saved but they are not visible to the regular users until the organizer clicks publish button. **Packages:** Each trip has packages where the organizer can specify price and name for them. Any change to packages should effect only the future bookings. <iframe src="https://drive.google.com/file/d/1Wr-9NxhYckcTpjXwiRG_oB8j1OPg1vab/preview" width="640" height="480"></iframe> **Trip booking:** A traveler can go to the trip page and book a one or more packages for one or more participants and pay for it via the specified payment gateway. <iframe src="https://drive.google.com/file/d/1dXOtN45FElE3D-SYQSOZvEUeLkiDwsE0/preview" width="640" height="480"></iframe> Each trip can have its own payment gateway. Each trip can have different payment gateways. Payment gateways are specified by the organizer while creating or editing the trip. The payment gateway cannot be changed after the first payment. We have predefined payment gateway list. Payment gateways will be external APIs where you send amount and currency CC numbers and receive success or error. A participant can be cancelled and refunded at any time. If the traveler booked for 3 participants and the organizer cancels one (the refund amount should be calculable), the rest (two out of three) still should be visible. **Refunds**: Refunds are calculated based on the price of the package at booking time. Changes to the package price should not affect refund amount of new bookings. An organizer will have a dashboard where s/he can see payment reporting with details. The following information should be available: - type of payment (bank, credit card, cash) - payment gateway - amount - date - status (pending, processed, failed) - participant names - user - packages booked - trip name <iframe src="https://drive.google.com/file/d/11sVUhYPs7fUU1zzO-vvdkdM8uury4HlD/preview" width="640" height="480"></iframe> For any other aspects which are not clear until now, please ask the interviewer(s). ## Request from Candidate 1. Create Microservice Diagram 1. Which microservices will you have and how are they related to each other? 2. How will your microservices interact with each other? 3. How will you microservices deal with the database? How will you organize the database access? 4. What will be the flow for: 1. Publishing the trip 2. Booking the trip 3. Cancellation and refund 4. Reporting 2. Create a database structure (use Google Sheets with the following [example structure](https://docs.google.com/spreadsheets/d/1y4VC-1mPdXRR_LaPMoHf8mEX--bTIhyz51Zn3JSp8ok/edit?usp=sharing)): 1. Which databases/tables will you have? 2. Specify the field types 3. Specify the relations among tables 3. Specify the class diagram and flowchart diagram for any 2 of the following flows: 1. Publishing the trip 2. Booking the trip 3. Cancellation and refund 4. Reporting You can use [draw.io](https://draw.io) or any familiar UML diagramming tool to draw.