System requirements
Functional:
List functional requirements for the system (Ask interviewer if stuck)...
users:
customers
- purchase movie tickets
- create an account
admins
- ticket inventory, pricing, promotion
- add/remove listings, theatres, showtimes
customer create an account and login
admins have their own special panel
features:
- user registration and authentication
- display a list of available movies, showtimes, theatres
- genre, casting, ratings, trailers
- users can pick seats in theatres
- update seat availability in real time
- payment processing for ticket purchase
- support different payments
- send confirmation with booking details
- notify customers of changes or cancellations
- customers can add movie ratings and add reviews
- display overall rating for each movie
- movie management - add movies, update existing movies, set showtimes
- theatre management - add new theatres, edit existing theatres, update showtimes at each theatre
Because each set of actions can be encompassed by a category, they will be separated by microservices and live in each respective microservice. For example, payment-related actions will live in the payments service.
Non-Functional:
List non-functional requirements for the system...
capacity metrics:
user traffic - peak during weekends or holidays
traffic spikes during movie releases or special events
1000 users concurrently during peak hours
50 admins/day
10,000 reads / hour during peak
500 writes / hour throughout the day
updates within milliseconds - real time updates
non-functional requirements
- needs to be fault tolerant for both users and admins at any given time
- real time write updates - writes needs to be fast
- read delays are minimal - reads also need to be fast
- low latency
- peaks will increase reads/writes
- scale dynamically
the system needs to be able to scale dynamically as there are more traffic so we will need to look at things like horizontal scaling, reads needs to be fast since there are more reads than writes so we can consider caching reads for more popular movies and theatres, and it needs to be highly performant and available to users and admins to provide a seamless experience. because there can be high peak traffic, we want to ensure that the load is also evenly distributed through load balances that can be scaled and the load balancers will handle distributing traffic to ensure that no single server is overwhelmed causing application degradation. because we want to ensure that admins and users are routed properly, we will also need an api gateway. to ensure high performance, we need to ensure that the application survives hardware faults and network failures and that there are no single points of failures. since we need highly available data but also highly consistent data, we can look at the CAP theorem - we cant have both so we will need to make tradeoffs. this will depend on the data model but we can also utilize consistent hashing to help with load and availability.
given that we will also need to host trailers and they are video media, we want to also consider using a CDN to host and serve files. since we need low latency, we will want to have multiple CDNs that serve content to users based on their locale.
in order to ensure high performance and fault tolerance, we will also need to consider monitoring and logging with tools such as elastic search, logstash, and kibana and monitoring such as grafana.
because each action is an event, we will also want to consider an event driven architecture using apache kafka to handle decoupling of actions and services.
Capacity estimation
Estimate the scale of the system you are going to design...
API design
Define what APIs are expected from the system...
Database design
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
High-level design
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design...
Request flows
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Detailed component design
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Trade offs/Tech choices
Explain any trade offs you have made and why you made certain tech choices...
Failure scenarios/bottlenecks
Try to discuss as many failure scenarios/bottlenecks as possible.
Future improvements
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?