The use of running examples is a prevalent approach found in programming literature. The running example serves as a means to illustrate the principles of a methodology, process, tool, or technique. In this book, we will define a Movies Store running example. We will revisit this running example throughout the book to explain many of the Django concepts and elements in a practical way.
The Movies Store will be a web-based platform where users access information about movies and can place orders to purchase them.
Now, let’s outline the application’s scope for this particular app:
- The Home page will feature a welcoming message.
- The About page will provide details about the Movies Store.
- The Movies page will exhibit information on available movies and include a filter to search movies by name. Additionally, users can click on a specific movie to view its details and post reviews.
- The Cart page will showcase the movies added to the cart, along with the total price to be paid. Users can also remove movies from the cart and proceed with purchases.
- The Register page will present a form enabling users to sign up for accounts.
- The Login page will present a form allowing users to log in to the application.
- The Orders page will display the orders placed by the logged-in user.
- The Admin panel will encompass sections to manage the store’s information, including creating, updating, deleting, and listing information.
The Movies Store will be developed using Django (Python), with a SQLite database and Bootstrap (a CSS framework). Further details about these components will be covered in the forthcoming chapters.
In Figure 1.6, you’ll find a class diagram outlining the application’s scope and design. The user class is depicted with its associated data (such as an id, username, email, and password) and is capable of placing orders. Each order consists of one or more items, which are linked to individual movies. Each movie will possess its respective data (including an id, name, price, description, and image). Lastly, users have the ability to create reviews for movies.
Figure 1.6 – The Movies Store class diagram
This book does not delve into the intricacies of class diagrams; hence, we won’t elaborate on additional details within the diagram (you can refer to this link for additional information about class diagrams: https://www.visual-paradigm.com/guide/uml-unified-modeling-language/uml-class-diagram-tutorial/). As you progress through the book, you’ll notice the correlation between code and this diagram. Serving as a blueprint, this diagram guides the construction of our application.
Note
Creating a class diagram before commencing coding aids in comprehending the application’s scope and identifying crucial data points. Additionally, it facilitates understanding the interconnections among various elements of the application. This diagram can be shared with team members or colleagues for feedback, allowing for adjustments as necessary. Due to its nature as a diagram, modifications can be implemented quickly. Otherwise, once the project has been coded, the cost of relocating data from one class to another increases significantly. Check the following statement from the book Building Microservices by Newman, S. (2015): “I tend to do much of my thinking in the place where the cost of change and the cost of mistakes is as low as it can be: the whiteboard.”
Based on the previous scope, we will build a Movies Store app that will allow users to view and search for movies, as shown in Figure 1.7:
Figure 1.7 – The movies page with search functionality
Users will be able to sign up, as shown in Figure 1.8:
Figure 1.8 – The Sign Up page
Users will be able to log in, add movies to the cart, and make purchases, as shown in Figure 1.9:
Figure 1.9 – The shopping cart page
Users will also be able to list, create, edit, and delete movie reviews, as shown in Figure 1.10:
Figure 1.10 – A specific movie page with its reviews
Many other functionalities will be developed and explained across the book. Now, let’s see the architecture we will use to construct the Movies Store application.