2081 3

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]

Software EngineeringChapter 7: Design and ImplementationObject-Oriented Design using UML

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

ActorUse CaseRelationship
UserRegisterAssociation
UserLoginAssociation
UserSearch BookAssociation
UserView RecommendationAssociation
UserRate and ReviewAssociation
UserAdd to WishlistAssociation
UserUpdate PreferencesAssociation
UserPurchase BookAssociation
Purchase BookProcess Payment<<include>>
View RecommendationUpdate Preferences<<extend>>
AdminManage Book CatalogAssociation
AdminManage UsersAssociation
Payment GatewayProcess PaymentAssociation

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

ClassRelated ClassMultiplicityRelationship
UserWishList1 to 1Composition
WishListBook1 to manyAssociation
BookReview1 to manyAssociation
RecommendationEngineBookCatalogusesDependency
OrderPayment1 to 1Composition

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:

  1. The User selects a book, and the system fetches its details from BookCatalog.
  2. The User places an order, which Order creates and forwards to Payment.
  3. Payment calls the external PaymentGateway to validate the card and process the transaction.
  4. On success, the payment result flows back through Payment to Order, 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.