BlockBook Developer Guide


Acknowledgements

The UI mockup was generated with ChatGPT using the following input.

Setting up and getting started

Refer to the guide: Setting up and getting started.


Design

Architecture

The Architecture Diagram given above explains the high-level design of the App.

Given below is a quick overview of main components and how they interact with each other.

Main components of the architecture

Main (consisting of classes Main and MainApp) is in charge of the app launch and shut down.

  • At app launch, it initializes the other components in the correct sequence, and connects them up with each other.
  • At shut down, it shuts down the other components and invokes cleanup methods where necessary.

The bulk of the app's work is done by the following four components:

  • UI: The UI of the App.
  • Logic: The command executor.
  • Model: Holds the data of the App in memory.
  • Storage: Reads data from, and writes data to, the hard disk.

Commons represents a collection of classes used by multiple other components.

How the architecture components interact with each other

The Sequence Diagram below shows how the components interact with each other for the scenario where the user issues the command delete 1.

Each of the four main components (also shown in the diagram above),

  • defines its API in an interface with the same name as the Component.
  • implements its functionality using a concrete {Component Name}Manager class (which follows the corresponding API interface mentioned in the previous point.

For example, the Logic component defines its API in the Logic.java interface and implements its functionality using the LogicManager.java class which follows the Logic interface. Other components interact with a given component through its interface rather than the concrete class (reason: to prevent outside component's being coupled to the implementation of a component), as illustrated in the (partial) class diagram below.

The sections below give more details of each component.

UI component

The API of this component is specified in Ui.java

Structure of the UI Component

The UI consists of a MainWindow that is made up of parts e.g.CommandBox, ResultDisplay, GamerListPanel, StatusBarFooter etc. All these, including the MainWindow, inherit from the abstract UiPart class which captures the commonalities between classes that represent parts of the visible GUI.

The UI component uses the JavaFx UI framework. The layout of these UI parts are defined in matching .fxml files that are in the src/main/resources/view folder. For example, the layout of the MainWindow is specified in MainWindow.fxml

The UI component,

  • executes user commands using the Logic component.
  • listens for changes to Model data so that the UI can be updated with the modified data.
  • keeps a reference to the Logic component, because the UI relies on the Logic to execute commands.
  • depends on some classes in the Model component, as it displays Gamer object residing in the Model.

Logic component

API : Logic.java

Here's a (partial) class diagram of the Logic component:

The sequence diagram below illustrates the interactions within the Logic component, taking execute("delete 1") API call as an example.

Interactions Inside the Logic Component for the `delete 1` Command

Note: The lifeline for DeleteCommandParser should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline continues till the end of diagram.

How the Logic component works:

  1. When Logic is called upon to execute a command, it is passed to an BlockBookParser object which in turn creates a parser that matches the command (e.g., DeleteCommandParser) and uses it to parse the command.
  2. This results in a Command object (more precisely, an object of one of its subclasses e.g., DeleteCommand) which is executed by the LogicManager.
  3. The command can communicate with the Model when it is executed (e.g. to delete a gamer).
    Note that although this is shown as a single step in the diagram above (for simplicity), in the code it can take several interactions (between the command object and the Model) to achieve.
  4. The result of the command execution is encapsulated as a CommandResult object which is returned back from Logic.

Here are the other classes in Logic (omitted from the class diagram above) that are used for parsing a user command:

How the parsing works:

  • When called upon to parse a user command, the BlockBookParser class creates an XYZCommandParser (XYZ is a placeholder for the specific command name e.g., AddCommandParser) which uses the other classes shown above to parse the user command and create a XYZCommand object (e.g., AddCommand) which the BlockBookParser returns back as a Command object.
  • All XYZCommandParser classes (e.g., AddCommandParser, DeleteCommandParser, ...) inherit from the Parser interface so that they can be treated similarly where possible e.g, during testing.

Model component

API : Model.java

The Model component,

  • stores contact data i.e., all Gamer objects (which are contained in a UniqueGamerList object).
    • stores the currently 'selected' Gamer objects (e.g., results of a search query) as a separate filtered list which is exposed to outsiders as an unmodifiable ObservableList<Gamer> that can be 'observed' e.g. the UI can be bound to this list so that the UI automatically updates when the data in the list change.
  • stores a UserPrefs object that represents the user's preferences. This is exposed to the outside as a ReadOnlyUserPrefs object.
  • does not depend on any of the other three components (as the Model represents data entities of the domain, they should make sense on their own without depending on other components)

Note: An alternative (arguably, a more OOP) model is given below. It has a Tag list in the BlockBook, which Gamer references. This allows BlockBook to only require one Tag object per unique tag, instead of each Gamer needing their own Tag objects.

Storage component

API : Storage.java

The Storage component,

  • can save both contact data and user preference data in JSON format, and read them back into corresponding objects.
  • inherits from both BlockBookStorage and UserPrefsStorage, which means it can be treated as either one (if only the functionality of only one is needed).
  • depends on some classes in the Model component (because the Storage component's job is to save/retrieve objects that belong to the Model)

Common classes

Classes used by multiple components are in the seedu.blockbook.commons package.


Implementation

This section describes some noteworthy details on how certain features are implemented.

[Proposed] Undo/redo feature

Proposed Implementation

The proposed undo/redo mechanism will be facilitated by VersionedBlockBook. It will extend BlockBook with an undo/redo history, stored internally as an blockBookStateList and currentStatePointer. Additionally, it should implement the following operations:

  • VersionedBlockBook#commit() - Saves the current BlockBook state in its history.
  • VersionedBlockBook#undo() - Restores the previous BlockBook state from its history.
  • VersionedBlockBook#redo() - Restores a previously undone BlockBook state from its history.

These operations should be exposed in the Model interface as Model#commitBlockBook(), Model#undoBlockBook() and Model#redoBlockBook() respectively.

Given below is an example usage scenario and how the undo/redo mechanism behaves at each step.

Step 1. The user launches the application for the first time. The VersionedBlockBook will be initialized with the initial BlockBook state, and the currentStatePointer pointing to that single BlockBook state.

UndoRedoState0

Step 2. The user executes delete 5 command to delete the 5th gamer in BlockBook. The delete command calls Model#commitBlockBook(), causing the modified state of BlockBook after the delete 5 command executes to be saved in the blockBookStateList, and the currentStatePointer is shifted to the newly inserted BlockBook state.

UndoRedoState1

Step 3. The user executes add name/David … to add a new gamer. The add command also calls Model#commitBlockBook(), causing another modified BlockBook state to be saved into the blockBookStateList.

UndoRedoState2

Note: If a command fails its execution, it will not call Model#commitBlockBook(), so the BlockBook state will not be saved into the blockBookStateList.

Step 4. The user now decides that adding the gamer was a mistake, and decides to undo that action by executing the undo command. The undo command will call Model#undoBlockBook(), which will shift the currentStatePointer once to the left, pointing it to the previous BlockBook state, and restores BlockBook to that state.

UndoRedoState3

Note: If the currentStatePointer is at index 0, pointing to the initial BlockBook state, then there are no previous BlockBook states to restore. The undo command uses Model#canUndoBlockBook() to check if this is the case. If so, it will return an error to the user rather than attempting to perform the undo.

The following sequence diagram shows how an undo operation goes through the Logic component:

UndoSequenceDiagram-Logic

Note: The lifeline for UndoCommand should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

Similarly, how an undo operation goes through the Model component is shown below:

UndoSequenceDiagram-Model

The redo command does the opposite — it calls Model#redoBlockBook(), which shifts the currentStatePointer once to the right, pointing to the previously undone state, and restores BlockBook to that state.

Note: If the currentStatePointer is at index blockBookStateList.size() - 1, pointing to the latest BlockBook state, then there are no undone BlockBook states to restore. The redo command uses Model#canRedoBlockBook() to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo.

Step 5. The user then decides to execute the command list. Commands that do not modify BlockBook, such as list, will usually not call Model#commitBlockBook(), Model#undoBlockBook() or Model#redoBlockBook(). Thus, the blockBookStateList remains unchanged.

UndoRedoState4

Step 6. The user executes clear, which calls Model#commitBlockBook(). Since the currentStatePointer is not pointing at the end of the blockBookStateList, all BlockBook states after the currentStatePointer will be purged. Reason: It no longer makes sense to redo the add command. This is the behavior that most modern desktop applications follow.

UndoRedoState5

The following activity diagram summarizes what happens when a user executes a new command:

Design considerations:

Aspect: How undo & redo executes:

  • Alternative 1 (current choice): Saves the entire BlockBook.

    • Pros: Easy to implement.
    • Cons: May have performance issues in terms of memory usage.
  • Alternative 2: Individual command knows how to undo/redo by itself.

    • Pros: Will use less memory (e.g. for delete, just save the gamer being deleted).
    • Cons: We must ensure that the implementation of each individual command are correct.

{more aspects and alternatives to be added}

[Proposed] Data archiving

{Explain here how the data archiving feature will be implemented}


Documentation, logging, testing, configuration, dev-ops


Appendix: Requirements

Product scope

Target user profile:

  • Minecraft player
  • Discord user
  • Has a Minecraft gamertag
  • CLI users, fast typer
  • Comfortable typing Minecraft commands
  • Needs to keep track of a significant number of contacts for gaming together

Value proposition: BlockBook makes it easy for Minecraft gamers to connect with other players by saving contacts of players they meet on servers. With a familiar command line interface, adding, organising and finding is a breeze.

User stories

Priorities: High (must have) - * * *, Medium (nice to have) - * *, Low (unlikely to have) - *

Priority As a ... I want to ... So that I can...
* * * general user add a new contact link multiple contact methods to a gamer
* * * general user delete a gamer remove contact entries that I no longer need
* * * general user list out my contacts see my contacts that I saved previously
* * * general user view a contact’s profile with their full details access comprehensive details when needed
* * general user find a gamer by name locate details of gamers without having to go through the entire list
* * new user see usage instructions figure out how to use the app easily
* * general user update contact details keep track of my contacts' latest information
* * general user avoid adding duplicate contacts not store the same contact twice by accident
* * general user sort the contacts alphabetically access my contacts easier
* * general user sort the contacts by added date find my contacts I recently added
* * minecraft gamer / pro typer delete contacts in bulk delete more contacts at one go
* * general user see clear error messages when I enter invalid commands correct my mistakes quickly
* * general user add contacts to a favourites list access my favourite contacts easier
* * general user list out my favourite contacts find my favourite contacts
* * general user add a personal note to a contact's profile preserve context information about a contact
* * general user create a social group create groups with contacts with a context
* * general user add contact to social group find the contacts I want to play with based on context
* general user use autocomplete when typing in CLI type faster and easier when I forget the command
* general user add profile picture to contact recognise contacts more easily via visual
* minecraft gamer see quality sprite styles that align with minecraft have a good interface experience

Use cases

(For all use cases below, the System is the BlockBook (BB) and the Actor is the user, unless specified otherwise) As these represent the expected behaviour of the final iteration, some use cases might not reflect the current functionality of the app.

UC01 - Add Contact

MSS

  1. User chooses to add a new contact.
  2. BB requests the contact's details (gamertag, server name, optional label).
  3. User enters the requested details.
  4. BB requests confirmation.
  5. User confirms.
  6. BB saves the new contact and displays the updated contact list.

Use case ends.

Extensions

3a. BB detects that the gamertag field is empty or contains invalid characters.

  • 3a1. BB displays an error and requests correct data.

  • 3a2. User enters new data.

  • Steps 3a1-3a2 are repeated until the data entered is correct.

  • Use case resumes from step 4.

3b. BB detects that a contact with the same gamertag already exists.

  • 3b1. BB warns the user of the duplicate entry and asks whether to proceed.
  • 3b2. User chooses to proceed or cancel.
  • If User cancels, use case ends. Otherwise, use case resumes from step 4.

*a. At any time, User chooses to cancel adding the contact.

  • *a1. BB discards all entered data.
  • Use case ends.

UC02 - List All Contacts

MSS

  1. User chooses to view all saved contacts.
  2. BB retrieves all entries.
  3. BB displays a list of all contacts with their basic details.

Use case ends.

Extensions

2a. The contact list is empty.

  • 2a1. BB informs the user that no contacts are currently stored.
  • Use case ends.

UC03 - Favourite a Contact

MSS

  1. User chooses to favourite a contact.
  2. BB requests the gamertag of the contact to favourite.
  3. User enters the gamertag.
  4. BB marks the contact as a favourite and confirms the update.

Use case ends.

Extensions

3a. BB cannot find a contact matching the entered gamertag.

  • 3a1. BB displays an error and requests a valid gamertag.
  • 3a2. User enters a new gamertag.
  • Steps 3a1-3a2 are repeated until a match is found.
  • Use case resumes from step 4.

4a. The contact is already marked as a favourite.

  • 4a1. BB notifies the user that the contact is already a favourite.
  • Use case ends.

UC04 - Add Profile Picture to Contact

MSS

  1. User chooses to add a profile picture to a contact.
  2. BB requests the contact's gamertag.
  3. User enters the gamertag.
  4. BB requests the image to use as the profile picture.
  5. User provides the image.
  6. BB requests confirmation.
  7. User confirms.
  8. BB saves the profile picture and displays the updated contact profile.

Use case ends.

Extensions

3a. BB detects that the gamertag is empty or contains invalid characters.

  • 3a1. BB displays an error and requests correct data.
  • 3a2. User enters new data.
  • Steps 3a1-3a2 are repeated until the data entered is correct.
  • Use case resumes from step 4.

5a. BB detects that the provided image is invalid or cannot be accessed.

  • 5a1. BB displays an error and requests a valid image.
  • 5a2. User provides new image data.
  • Steps 5a1-5a2 are repeated until the data entered is correct.
  • Use case resumes from step 6.

*a. At any time, User chooses to cancel.

  • *a1. BB discards all entered data.
  • Use case ends.

UC05 - Add Note to Contact

MSS

  1. User chooses to add a note to an existing contact.
  2. BB requests the gamertag of the target contact.
  3. User enters the gamertag.
  4. BB displays the contact's current details.
  5. User enters the note to be added.
  6. BB saves the note and displays the updated contact profile.

Use case ends.

Extensions

3a. BB cannot find a contact matching the entered gamertag.

  • 3a1. BB displays an error and requests a valid gamertag.
  • 3a2. User enters a new gamertag.
  • Steps 3a1-3a2 are repeated until a match is found.
  • Use case resumes from step 4.

5a. User enters a note that exceeds the maximum character limit.

  • 5a1. BB displays an error indicating the limit and requests a shorter note.
  • 5a2. User enters a new note.
  • Use case resumes from step 6.

*a. At any time, User chooses to cancel.

  • *a1. BB discards all unsaved changes.
  • Use case ends.

UC06 - Sort Contacts by Added Date

MSS

  1. User chooses to sort contacts by added date.
  2. BB displays all contacts sorted in chronological order by added date, from most recent.

Use case ends.

Extensions

2a. BB finds no contacts.

  • 2a1. BB informs the user that there are no contacts.
  • Use case ends.

UC07 - Update Contact

MSS

  1. User chooses to update a contact's details.
  2. BB requests the current gamertag of the contact.
  3. User enters the current gamertag.
  4. BB displays the contact's current details and requests which attribute to change.
  5. User enters the attribute to change.
  6. BB requests the new value for the attribute.
  7. User enters the new value.
  8. BB requests confirmation.
  9. User confirms.
  10. BB updates the contact and displays the updated contact profile.

Use case ends.

Extensions

3a. BB cannot find a contact matching the entered gamertag.

  • 3a1. BB displays an error and requests a valid gamertag.
  • 3a2. User enters a new gamertag.
  • Steps 3a1-3a2 are repeated until a match is found.
  • Use case resumes from step 4.

5a. BB cannot identify the attribute to edit.

  • 5a1. BB displays an error and requests a valid attribute name.
  • 5a2. User enters a new attribute name.
  • Steps 5a1-5a2 are repeated until a valid attribute is entered.
  • Use case resumes from step 6.

7a. BB detects that the new gamertag is already in use by another contact.

  • 7a1. BB warns the user of the conflict and requests a different gamertag.
  • 7a2. User enters a new gamertag.
  • Use case resumes from step 8.

7b. BB detects that the entered value contains invalid characters.

  • 7b1. BB displays an error and requests a valid value.
  • 7b2. User enters a new value.
  • Use case resumes from step 8.

*a. At any time, User chooses to cancel.

  • *a1. BB discards all changes.
  • Use case ends.

Non-Functional Requirements

  1. Should work on any mainstream OS as long as it has Java 17 or above installed.
  2. Should be able to hold up to 1000 gamers without a noticeable sluggishness in performance for typical usage.
  3. A user with above average typing speed for regular English text (i.e. not code, not system admin commands) should be able to accomplish most of the tasks faster using commands than using the mouse.
  4. Any successful command (e.g., add, delete) should cause the GUI to update without noticeable delay (less than 1 second).
  5. The application should not crash or terminate under normal usage scenarios (e.g., listing, adding, or deleting contacts).
  6. The application should not lose user data during normal operation.
  7. The application should continue operating normally when invalid input is provided.
  8. When performing operations such as bulk delete or filter, the system should process the request without freezing the GUI.
  9. All user data should be stored locally.
  10. The data should be stored locally in a human-editable text file so that advanced users can manually manipulate the data if necessary.
  11. The GUI should work well (i.e., should not cause resolution-related inconveniences) for:
  • screen resolutions 1920 x 1080 and higher
  • screen scales 100% and 125%
  1. The GUI should remain usable (i.e., all functions can still be used even if the user experience is not optimal) for:
  • screen resolutions 1280 x 720 and higher
  • screen scales 150%

{More to be added}

Glossary

  • Minecraft: A sandbox game developed and published by Mojang Studios. See more here.
    • Gamertag: A Minecraft player's in-game username.
    • Modpack: A collection of Minecraft modifications bundled together for gameplay.
    • Server: A multiplayer Minecraft world hosted online where players interact.
  • Discord: An instant messaging and VoIP social platform popular among gamers that allows communication through voice calls, video calls, text messaging, and media. Communication can be private or in virtual communities called "servers". See more here.
  • Contact: A gamer that a user has saved in BlockBook, representing a Minecraft player they have met on servers. A contact typically includes details such as the player's gamertag, server name, and other attributes.
  • CLI: Command Line Interface, a way to interact with a computer program by typing commands into a console or terminal.
  • GUI: Graphical User Interface, a way to interact with a computer program through graphical elements like windows, buttons, and icons.
  • Mainstream OS: The common personal computer operating systems that BlockBook should be able to run on - Windows, Linux and MacOS.
  • Alias: A shortened version of a command that performs the same function.
    • For example: l can be an alias for list, and d can be an alias for delete.

Appendix: Instructions for manual testing

Given below are instructions to test the app manually.

Note: These instructions only provide a starting point for testers to work on; testers are expected to do more exploratory testing.

Launch and shutdown

  1. Initial launch

    1. Download the jar file and copy into an empty folder

    2. Double-click the jar file Expected: Shows the GUI with a set of sample contacts. The window size may not be optimum.

  2. Saving window preferences

    1. Resize the window to an optimum size. Move the window to a different location. Close the window.

    2. Re-launch the app by double-clicking the jar file.
      Expected: The most recent window size and location is retained.

  3. { more test cases ... }

Deleting a gamer

  1. Deleting a gamer while all gamers are being shown

    1. Prerequisites: List all gamers using the list command. Multiple gamers in the list.

    2. Test case: delete 1
      Expected: First contact is deleted from the list. Gamertag of the deleted contact shown in the status message. Timestamp in the status bar is updated.

    3. Test case: delete 0
      Expected: No gamer is deleted. Error details shown in the status message. Status bar remains the same.

    4. Test case: delete 1 2
      Expected: The first two contacts are deleted from the list. Gamertags of the deleted contacts shown in the status message. Timestamp in the status bar is updated.

    5. Other incorrect delete commands to try: delete, delete x, ... (where x is larger than the list size)
      Expected: Similar to previous.

  2. { more test cases ... }

Saving data

  1. Dealing with missing/corrupted data files

    1. {explain how to simulate a missing/corrupted file, and the expected behavior}
  2. { more test cases ... }