Clean Architecture, DDD et CQRS example with Laravel
The application will provide a Rest JSON API allowing a user to book lessons for an instructor on defined schedules, these will be created by the instructor.
A lesson is available if it does not have a confirmed or pending reservation.
A lesson will have a price.
The validation of the reservation by the instructor of a lesson will result in the debit of the user's wallet.
The user will be able to fill his wallet in euros only.
(It would have been better to make a sequence diagram by use case and to do a real event storming)
Application can create a user to be a teacher
Application can create a user to be a learner
Teacher create a lesson with a start date and hour and price
Learner add euros on his wallet
Learner see lessons available
Learner book a lesson available if wallet is sufficient
Teacher validate a booking
Transfert money to debit wallet of learner and credit wallet of techer and close it lesson
Learner (Bounded Context) :
User (Domain)
- Use case 2
Booking (Domain)
- Use Case 5
- Use Case 6
Teacher (Bounded Context) :
User (Domain)
- Use case 1
Lesson (Domain)
- Use Case 3
- Use Case 7
Bank (Bounded Context) :
Wallet (Domain)
- Use Case 4
- Use Case 8
CreateLearner : create a learner BookLesson : book a lesson by a learner, booking is pending and payment status is new also, and send event
GetLessonsAvailable : get all lessons available GetBookings : get all booking create by learner
LessonBooked : event to indicate a lesson has been booked
CreateTeacher : create a teacher CreateLesson : create a lesson by a teacher ValidateBooking : validate a booking RefuseBooking : refuse a booking
GetBookingsPending : get all booking of its lessons pending validation and payment state pending
BookingValidated : event to indicate a booking has been validated BookingRefused : event to indicate a booking has been refused
AddMoneyToWallet : add money to a wallet of an user TransfertMoney : transfert money between wallet AuthorizeTransaction : check if has enough money for a user to do a transaction, state new to pending CreateTransaction : create transaction for a wallet with new state and price
TransactionAuthorized : event to indicate that a transaction is authorized
LessonBookedConsumer : listen if a booking has been asked, create Transaction and authorize transaction BookingValidatedConsumer : listen if a booking has been validated and transfert money between learner wallet and teacher wallet BookingRefusedConsumer : listen if a booking has been refused and cancel transaction