CSC375 ยท 2081 ยท 10 marks
Draw use case diagram, class diagram and sequence diagram for online book recommendation system. Make your own assumptions.
Draw use case diagram, class diagram and sequence diagram for online book recommendation system. Make your own assumptions.[10]
Quick answer
The Use Case Diagram captures what the system does from the outside (registering, searching, rating, purchasing, and administering the catalog), the Class Diagram captures the static structure that makes those use cases possible (User, Book, WishList, Review, RecommendationEngine, BookCatalog, Order...
Online Book Recommendation System - UML Diagrams
Assumptions
- Users can register, login, browse books, and receive recommendations
- The system recommends books based on user preferences, reading history, and ratings
- Users can search for books, add them to a wishlist, and rate/review books
- An Admin manages the book catalog and user accounts
- The system interacts with an external Payment Gateway for purchases
1. Use Case Diagram
Purpose: Shows interactions between the system and its environment (actors and use cases), focusing on functional requirements and providing an outside view of the system.
+----------------------------------------------------------+
| Online Book Recommendation System |
| |
| +----------------+ +-------------------------+ |
| | Register | | Manage Book Catalog | |
| +----------------+ +-------------------------+ |
| ^ |
| +----------------+ | (Admin) |
| | Login | +-------------------------+ |
| +----------------+ | Manage Users | |
| | +-------------------------+ |
| v |
| +----------------+ +-------------------------+ |
| | Search Book | | View Recommendation | |
| +----------------+ +-------------------------+ |
| | | |
| v v |
| +----------------+ +-------------------------+ |
| | Rate & Review | | Update Preferences | |
| +----------------+ +-------------------------+ |
| |
| +----------------+ +-------------------------+ |
| | Add to | | Purchase Book | |
| | Wishlist | +-------------------------+ |
| +----------------+ | |
| <<include>> |
| +-------------------------+ |
| | Process Payment | |
| +-------------------------+ |
+----------------------------------------------------------+
[User] -----> (Register, Login, Search Book,
Rate & Review, Add to Wishlist,
View Recommendation, Update Preferences,
Purchase Book)
[Admin] -----> (Login, Manage Book Catalog,
Manage Users)
[Payment Gateway] <----- (Process Payment)
Textual Description of Relationships
| Actor | Use Case | Relationship |
|---|---|---|
| User | Register | Association |
| User | Login | Association |
| User | Search Book | Association |
| User | View Recommendation | Association |
| User | Rate and Review | Association |
| User | Add to Wishlist | Association |
| User | Update Preferences | Association |
| User | Purchase Book | Association |
| Purchase Book | Process Payment | <<include>> |
| View Recommendation | Update Preferences | <<extend>> |
| Admin | Manage Book Catalog | Association |
| Admin | Manage Users | Association |
| Payment Gateway | Process Payment | Association |
2. Class Diagram
Purpose: Shows the static structure of the system - the object classes and associations between them, used when developing an object-oriented system model.
+------------------+ +----------------------+
| User | | Book |
+------------------+ +----------------------+
| - userID: int | | - bookID: int |
| - name: String | | - title: String |
| - email: String | | - author: String |
| - password: String| | - genre: String |
| - preferences: | | - ISBN: String |
| List<String> | | - price: float |
+------------------+ | - rating: float |
| + register() | +----------------------+
| + login() | | + getDetails() |
| + updateProfile()| | + getAverageRating() |
| + logout() | +----------------------+
+------------------+ |
| |
| 1 | 1..*
| |
v v
+------------------+ +----------------------+
| WishList | | Review |
+------------------+ +----------------------+
| - wishlistID:int | | - reviewID: int |
| - userID: int | 1 * | - userID: int |
| - bookList: |<-------->| - bookID: int |
| List<Book> | | - rating: int |
+------------------+ | - comment: String |
| + addBook() | | - date: Date |
| + removeBook() | +----------------------+
| + viewWishlist() | | + submitReview() |
+------------------+ | + editReview() |
+----------------------+
|
| 1
|
v
+----------------------+ +-------------------------+
| RecommendationEngine | | Order |
+----------------------+ +-------------------------+
| - engineID: int | | - orderID: int |
| - algorithm: String | | - userID: int |
+----------------------+ | - bookID: int |
| + generateRecommend()| | - amount: float |
| + updateModel() | | - status: String |
| + fetchUserHistory() | +-------------------------+
+----------------------+ | + placeOrder() |
| | + cancelOrder() |
| uses | + getOrderStatus() |
v +-------------------------+
+----------------------+ |
| BookCatalog | | 1
+----------------------+ +-------------------------+
| - catalogID: int | | Payment |
| - bookList: | +-------------------------+
| List<Book> | | - paymentID: int
| | | - orderID: int |
| | | - amount: float |
| | | - method: String |
| | | - status: String |
| | +-------------------------+
| | | + processPayment() |
| | | + refund() |
| | +-------------------------+
+----------------------+
Key Relationships
| Class | Related Class | Multiplicity | Relationship |
|---|---|---|---|
| User | WishList | 1 to 1 | Composition |
| WishList | Book | 1 to many | Association |
| Book | Review | 1 to many | Association |
| RecommendationEngine | BookCatalog | uses | Dependency |
| Order | Payment | 1 to 1 | Composition |
3. Sequence Diagram (Purchase Book Use Case)
Purpose: Shows the time-ordered sequence of messages exchanged between objects to accomplish a specific use case, useful for understanding dynamic, run-time behaviour.
User BookCatalog Order Payment PaymentGateway
| | | | |
|--selectBook()-->| | | |
| |--getDetails()-| | |
|<--bookDetails---| | | |
| | | | |
|--placeOrder()------------------>| | |
| | |--createOrder-| |
| | | |--processPayment()-->|
| | | | |--validateCard()-->
| | | | |<--paymentApproved--
| | | |<--paymentResult-| |
| | |<--orderConfirmed-- | |
|<--orderStatus("Confirmed")------| | | |
| | | | | |
Flow Description:
- The User selects a book, and the system fetches its details from
BookCatalog. - The User places an order, which
Ordercreates and forwards toPayment. Paymentcalls the externalPaymentGatewayto validate the card and process the transaction.- On success, the payment result flows back through
PaymenttoOrder, and a confirmation is shown to the User.
Summary
The Use Case Diagram captures what the system does from the outside (registering, searching, rating, purchasing, and administering the catalog), the Class Diagram captures the static structure that makes those use cases possible (User, Book, WishList, Review, RecommendationEngine, BookCatalog, Order, and Payment, with their attributes, methods, and relationships), and the Sequence Diagram captures how objects collaborate over time to carry out one specific scenario, purchasing a book, from selection through payment confirmation. Together, these three views give a complete picture of the Online Book Recommendation System's structure and behaviour, which is exactly why UML modelling typically combines a structural view (class diagram), a behavioural/interaction view (sequence diagram), and a requirements view (use case diagram) rather than relying on any single diagram alone.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.