# ay2425s2-cs2103t-t14-1/tp architecture

> Architecture diagram of the GitHub repository ay2425s2-cs2103t-t14-1/tp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ay2425s2-cs2103t-t14-1/tp
- Repository: https://github.com/ay2425s2-cs2103t-t14-1/tp

## Overview

##### Project Type & Purpose
- This project is a desktop application built using Java (with JavaFX for GUI), which implements an address book for extended families called “WhoAreYouAgain?”.
- Its main aim is to help users manage and remember family members’ details, events, and other pertinent information.
- The project is a variant of the popular AddressBook-Level3 pattern with clearly separated concerns such as UI, logic, model, storage, and configuration.

##### File Structure & Architectural Patterns
- Notice the clear separation in the src/main/java directory. There are distinct packages for:
- UI (user interface components, FXML views in src/main/resources/view)
- Logic (command parsing, command execution, and message handling)
- Model (data representation for persons, address book, user preferences, and other domain models)
- Storage (classes handling file I/O and JSON serialization of the address book data)
- Commons/Utilities (miscellaneous utilities, configuration management, and logging)
- The Gradle build files and tests in src/test further attest to the clean separation of concerns and use of dependency management and unit testing.

##### Main Components and Their Interactions
- UI Layer:
- Comprises classes in the “ui” package and FXML resources defining the layout.
- Handles user inputs and displays results. For example, MainWindow, CommandBox, and other panels.
- Logic Layer:
- Processes user commands through the “logic” package.
- Contains parser components (e.g., AddCommandParser, AddressBookParser) and command classes (e.g., AddCommand, DeleteCommand).
- Converts UI events into business logic execution.
- Model Layer:
- Contains domain classes representing persons, address data, and other family details.
- Includes the address book itself, user preferences, and validation classes.
- Storage Layer:
- Responsible for loading and saving data in JSON (see classes like JsonAddressBookStorage and JsonUserPrefsStorage).
- Abstracts file I/O, ensuring that the Model can persist and retrieve data.
- Configuration & Utilities:
- Provides configuration management, logging, and utility functions that are used across the system.
- These components ensure consistency and easier management of cross-cutting concerns.

##### Relationships and Data Flow
- The Logic Manager then parses these through the relevant Parser and then decides the correct Command to execute.
- The Command interacts with the Model to update the application state (adding, deleting, editing family member records).
- The updated Model is then saved to or loaded from persistent storage via the Storage Manager.
- Finally, the UI is updated to reflect the changes, closing the feedback loop.

##### Important Architectural Patterns & Design Principles
- MVC/MVP Concepts:
- Clearly separate concerns between data (Model), user interaction (View/UI), and control logic.
- Command Pattern:
- Commands are encapsulated as separate classes (e.g., AddCommand, EditCommand) to decouple the command logic.
- Layered Architecture:
- Distinct layers (UI, Logic, Model, Storage) interact via well-defined interfaces, making the system modular and testable.
- Unit Testing:
- The test directories illustrate a systematic approach for ensuring each component works as intended.

##### Essential Elements
- Clear Labels: Mark each component distinctly by naming (e.g., “MainWindow”, “LogicManager”, “ModelManager”, “StorageManager”).
- Annotations: Add notes on key patterns (MVC, Command Pattern) and mention important technologies (Java, JavaFX, Gradle).

Summary:
- The layered architecture (UI, Logic, Model, Storage).
- The flow from user input to command parsing, model update, data persistence, and UI refresh.
- The overall modularity and clean separation of concerns facilitated by patterns like MVC and the Command pattern.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Input
    User["User Input"]:::external

    %% UI Layer
    subgraph "UI Layer"
        UI_Main["MainWindow"]:::uiLayer
        UI_Command["CommandBox"]:::uiLayer
        UI_Help["HelpWindow"]:::uiLayer
    end

    %% Logic Layer
    subgraph "Logic Layer"
        Logic_Manager["Logic Manager"]:::logicLayer
        Logic_Parser["AddressBookParser"]:::logicLayer
        Logic_Command["Command Pattern (AddCommand,DeleteCommand,...)"]:::logicLayer
    end

    %% Model Layer
    subgraph "Model Layer"
        Model["Domain Model (AddressBook,Person,...)"]:::modelLayer
    end

    %% Storage Layer
    subgraph "Storage Layer"
        Storage_Manager["Storage Manager (JsonAddressBookStorage,JsonUserPrefsStorage)"]:::storageLayer
    end

    %% Configuration & Utilities
    subgraph "Configuration & Utilities"
        Config["Configuration & Utilities"]:::configLayer
    end

    %% Data Flow
    User -->|"sendsInput"| UI_Main
    UI_Main -->|"triggersCommand"| Logic_Manager
    Logic_Manager -->|"usesParser"| Logic_Parser
    Logic_Manager -->|"executesCommands"| Logic_Command
    Logic_Command -->|"updates"| Model
    Model -->|"persistsData"| Storage_Manager
    Storage_Manager -->|"refreshes"| UI_Main

    %% Cross Layer Dependencies
    Config --- UI_Main
    Config --- Logic_Manager
    Config --- Model

    %% Click Events for Component Mapping
    click UI_Main "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/ui"
    click UI_Command "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/ui"
    click UI_Help "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/ui"
    click UI_Main "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/resources/view"
    click Logic_Manager "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/logic"
    click Logic_Parser "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/logic"
    click Logic_Command "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/logic"
    click Model "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/model"
    click Storage_Manager "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/storage"
    click Config "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/src/main/java/seedu/address/commons"
    click Config "https://github.com/ay2425s2-cs2103t-t14-1/tp/tree/master/config"

    %% Styles
    classDef external fill:#FFFFFF,stroke:#000000,stroke-width:2px;
    classDef uiLayer fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef logicLayer fill:#A9DFBF,stroke:#2471A3,stroke-width:2px;
    classDef modelLayer fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef storageLayer fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef configLayer fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
