# ay2425s2-cs2103t-f11-2/tp architecture

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

- Interactive diagram: https://gitdiagram.com/ay2425s2-cs2103t-f11-2/tp
- Repository: https://github.com/ay2425s2-cs2103t-f11-2/tp

## Overview

##### Main Components
- User Interface (UI) Layer: Represented by the files in the src/main/java/seedu/address/ui package and associated FXML files in src/main/resources/view. This layer handles all user interactions.
- Logic Layer: This layer exists in src/main/java/seedu/address/logic and includes the command classes (e.g., AddCommand, EditCommand, DeleteCommand, etc.), logic manager, and message handling. It parses user inputs and delegates commands.
- Parsing Component: In src/main/java/seedu/address/logic/parser, you have classes that tokenize and transform user input into commands.
- Domain Model: Located under src/main/java/seedu/address/model. This includes the core business objects (e.g., Person, Allergy, Priority, etc.) and collections like UniquePersonList.
- Storage Component: Found under src/main/java/seedu/address/storage, this component is responsible for persisting and retrieving data using JSON files.
- Utility and Common Components: The src/main/java/seedu/address/commons package contains core classes (like Config, LogsCenter, GuiSettings, etc.) that support the other layers.

##### Relationships and Interactions
- The UI layer interacts with the Logic layer by capturing user events and forwarding them to the LogicManager.
- The Logic layer uses the Parser to interpret user commands and then operates on the Domain Model.
- The Storage layer is accessed by both the Logic and Model layers when data persistence or retrieval is required.
- Utility classes (within Commons) are used across layers for tasks like configuration, logging, and file handling.

##### Architectural Patterns and Design Principles
- MVC or a similar pattern: which separates concerns into view (UI), controller (Logic) and model (Domain Model).
- Command Pattern: Evident in the various command classes, making it easier to add or modify commands.
- Separation of Concerns: Each component (UI, logic, storage, model) has a distinct responsibility.
- Use of utility classes to centralize common functions (e.g., file, string, JSON utilities).

##### Relevant Technologies and Frameworks
- Java and JavaFX – for the desktop user interface (noted by the FXML files).
- Gradle for build management (build.gradle and gradlew scripts).
- JSON for persistence (via JSON-based storage classes).

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface (UI) Layer
    subgraph "User Interface (UI) Layer"
        UI_Java["UI - Java Classes"]:::ui
        UI_FXML["UI - FXML Files"]:::ui
    end

    %% Logic Layer
    subgraph "Logic Layer"
        Logic["Logic Manager & Commands"]:::logic
    end

    %% Parsing Component
    subgraph "Parsing Component"
        Parser["User Command Parser"]:::parser
    end

    %% Domain Model
    subgraph "Domain Model"
        Model["Core Business Objects & Lists"]:::model
    end

    %% Storage Component
    subgraph "Storage Component"
        Storage["Data Persistence (JSON)"]:::storage
    end

    %% Utility and Common Components
    subgraph "Utility and Common Components"
        Commons["Utilities & Common Classes"]:::commons
    end

    %% Data Flow Connections
    UI_Java -->|"UserInput"| Logic
    UI_FXML -->|"UserInput"| Logic
    Logic -->|"CommandParsing"| Parser
    Parser -->|"ParsedCommand"| Logic
    Logic -->|"OperateOn"| Model
    Logic -->|"PersistData"| Storage
    Model -->|"Save/Retrieve"| Storage
    Logic -->|"DisplayResults"| UI_Java
    Logic -->|"DisplayResults"| UI_FXML

    %% Common Utilities dotted connections (support)
    Commons ---|"Supports"| UI_Java
    Commons ---|"Supports"| UI_FXML
    Commons ---|"Supports"| Logic
    Commons ---|"Supports"| Parser
    Commons ---|"Supports"| Model
    Commons ---|"Supports"| Storage

    %% Click Events
    click UI_Java "https://github.com/ay2425s2-cs2103t-f11-2/tp/tree/master/src/main/java/seedu/address/ui"
    click UI_FXML "https://github.com/ay2425s2-cs2103t-f11-2/tp/tree/master/src/main/resources/view"
    click Logic "https://github.com/ay2425s2-cs2103t-f11-2/tp/tree/master/src/main/java/seedu/address/logic"
    click Parser "https://github.com/ay2425s2-cs2103t-f11-2/tp/tree/master/src/main/java/seedu/address/logic/parser"
    click Model "https://github.com/ay2425s2-cs2103t-f11-2/tp/tree/master/src/main/java/seedu/address/model"
    click Storage "https://github.com/ay2425s2-cs2103t-f11-2/tp/tree/master/src/main/java/seedu/address/storage"
    click Commons "https://github.com/ay2425s2-cs2103t-f11-2/tp/tree/master/src/main/java/seedu/address/commons"

    %% Styles
    classDef ui fill:#f9c74f,stroke:#333,stroke-width:2px,stroke-dasharray:5,5;
    classDef logic fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef parser fill:#f9844a,stroke:#333,stroke-width:2px;
    classDef model fill:#577590,stroke:#fff,stroke-width:2px;
    classDef storage fill:#277da1,stroke:#fff,stroke-width:2px;
    classDef commons fill:#f94144,stroke:#fff,stroke-width:2px,stroke-dasharray:2,2;
```
