Skip to content

RachaneeSaeng/clean-architecture-workshop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Clean Architecture Workshop

This repository is created to be a workshop codebase to learn the Clean Architecture.

Workshop Scenario

In this workshop we will implement a Cinema System to support ticket purchasing use case.

Cinema System

This may be an example user interface of a cinema system when a user try to search for a movie and book a show time.

Screenshot 2567-03-27 at 11.55.59 cinema-seats

User stories for ticket purchasing use case

As a customer,​

  • I want to see now-showing movies.​
  • I want to search movies by title.​
  • I want to see details of a movie, then view its showtimes, available seats, and pricing, so that I can select preferable showtime and seats.​
  • I want to purchase ticket by paying with my default payment method and get booking detail for reference.​

NOTE:

  • Now-showing mean having showtimes between now to the next 15 days.- Let assume that the customer has an account and logged in.​
  • Customer have setup default payment method.​

Code base

In this repository, we already provided some key entities and classes to save time crafting them.

Class diagrams of some key entities

classDiagram
    ShowTime <-- Movie
    ShowTime <-- Theater
    ShowTime o-- Seat
    Booking <-- ShowTime
    Booking <-- Seat: which seats in the showtime\nthat the booking reserved

    class Movie{
        + Guid Id
        + string Title
        + string Description
        + DateTime EndTime
        + TimeSpan Length
    }
    class Theater{
        + string Name
        + int NumberOfRow
        + int SeatsPerRow
        + int SeatPrice
    }
    class ShowTime{
        + Guid Id
        + Movie Movie
        + DateTime StartTime
        + DateTime EndTime
        + Theater Theater
        + List<Seat> Seats
        + ReserveSeat(string row, int number) Seat
    }
    class Seat{
        + string Row
        + int Number
        + int Price
        + bool IsAvailable
        + Reserve()
    }
    class Booking{
        + Guid Id
        + ShowTime ShowTime
        + List<Seat> Seats
        + int TotalPrice
        + string CustomerAccountId
        + CompletePayment()
    }

Initial data

Some data have be put into the key entities to setup movies and showtime data. You can see code to initialise data in Repositories.

Theaters cinema-seats

Movies cinema-seats

Showtimes cinema-seats Note:

  • There are some movies having past showtimes and some movies having no showtimes. This to demonstrate the GetNowShowingMovies method.
  • today.AddHours(19.5) = Today 19:30

TODO

You may see that currently the codebase is incompleted. Most of classes be put in a temporary folder CleanCodeApp.Domain/ToBeStructured and most of them have only properties defined but methods. Meaning there is no logic to solve the user stories yet. So, In this workshop you have to

  1. Structure classes in proper layer/folder.​
    • Moving classes around may cause issue of missing reference. You can run command to add project reference to allow referencing class from other domain. For example, dotnet add tests/CleanCodeApp.Application reference source/CleanCodeApp.Domain
  2. Implement logic to GetNowShowingMovies, GetShowTimesByMovieIdAndDate and CreateBooking​. You have to consider where to put the logic. You may put it in existing class or create a new class for it. Screenshot 2567-04-03 at 14.56.10

Other Branches

There are 3 branches in this repository, which are

  • main (this branch) : the workshop workspace. It consist of incompleted code in an improper layers that require architecturing and implementing to acheive the system requirement.
  • n-tier_architecture : a working example that implemented using the N-Tier architecture to solve the problem. We can learn the disadvantages of dependencies on external parties from this branch.
  • clean_architecture : a working example that implemented using the Clean architecture to solve the problem. We can learn this at the end of the workshop to get the idea of how to structure and implement logic in Clean style.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages