# gracesong146/ip architecture

> Architecture diagram of the GitHub repository gracesong146/ip, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gracesong146/ip
- Repository: https://github.com/gracesong146/ip

## Overview

##### Project Type & Purpose
- This is a lightweight, greenfield Java command‐line application template.
- It models a simple task management tool (ToDo, Deadline, Event) with file‐based persistence and a text-UI test harness.

##### File Structure
- Top-level folders:
- src/main/java: application entry point and core classes (Cathy.java, Task, Storage, etc.)
- data: runtime task store (cathy.txt)
- docs: documentation for the project template
- text-ui-test: automated CLI input/output tests
- No external frameworks or microservices—just plain Java, file I/O, and JDK tooling.

##### Extract Insights from README
- Uses JDK17, plain Java.
- Entrypoint: Cathy.main() prints a banner and drives the application loop.
- Emphasis on keeping src/main/java as the code root (standard Gradle/IDE layout).

##### Main Components & Interactions
a. Application Layers/Components
1. Command-Line UI (Cathy.java): reads user commands, displays output.
2. Parser & Controller Logic (embedded in Cathy.java or helper methods): interprets user input, invokes domain operations.
3. Domain Model:
- Task (abstract)
- ToDo, Deadline, Event (subclasses)
- TaskType enum
- InvalidTaskTypeException for invalid command handling
4. Storage Layer (Storage.java): reads/writes `data/cathy.txt` to persist the list of tasks.
5. Data File (data/cathy.txt): the on-disk representation of current tasks.
6. Test Harness (text-ui-test): simulates CLI input, compares against EXPECTED.TXT to validate behavior.

b. Component Interactions
- UI captures raw input → Parser interprets into domain operations → Domain Model is created/modified → Storage persists updated model to file → UI prints success or error messages → Loop continues.
- On startup, Storage loads tasks from `data/cathy.txt` into in-memory model.
- On exit or after each command, Storage writes back to file.
- Test Harness injects input into the UI’s stdin and captures stdout for verification.

##### Architectural Patterns & Principles
- Layered Architecture (UI → Controller/Parser → Domain Model → Persistence).
- Single-Responsibility per class (each Task subclass only knows about its own fields; Storage only does file I/O).
- Open–Closed: new TaskTypes can be added by introducing new subclasses & updating enum without modifying existing code heavily.
- Thin main class (Cathy.java) that orchestrates modules rather than mixing concerns.

- Clear component names that match class/folder names
- Annotations for technologies (Java 17, file I/O)
- Boundaries: in-process vs. on-disk vs. external test harness

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        CLIUI["CLI UI\n(Cathy.java)"]:::ui
        Parser["Parser/Controller\n(Cathy.java)"]:::ui
    end

    %% Domain Model Layer
    subgraph "Domain Model"
        TaskAbstract["Task (abstract)"]:::domain
        ToDo["ToDo"]:::domain
        Deadline["Deadline"]:::domain
        Event["Event"]:::domain
        TaskType["TaskType enum"]:::domain
        InvalidType["InvalidTaskTypeException"]:::domain
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        Storage["Storage Layer\n(Storage.java)"]:::persistence
        DataFile["Data File\n(cathy.txt)"]:::persistence
    end

    %% Test Harness
    subgraph "Test Harness"
        TestHarness["Test Harness"]:::test
        InputScript["input.txt"]:::test
        Expected["EXPECTED.TXT"]:::test
        RunnerBat["runtest.bat"]:::test
        RunnerSh["runtest.sh"]:::test
    end

    %% Connections
    CLIUI -->|"parseCommand()"| Parser
    Parser -->|"create/modify Task()"| TaskAbstract
    TaskAbstract --> ToDo
    TaskAbstract --> Deadline
    TaskAbstract --> Event
    TaskAbstract --> TaskType
    TaskAbstract --> InvalidType
    TaskAbstract <-->|"loadTasks()/saveTasks()"| Storage
    Storage -->|"read/write file I/O"| DataFile
    TestHarness -->|"stdin injection"| CLIUI
    CLIUI -->|"stdout capture"| TestHarness

    %% Click Events
    click CLIUI "https://github.com/gracesong146/ip/blob/master/src/main/java/Cathy.java"
    click Parser "https://github.com/gracesong146/ip/blob/master/src/main/java/Cathy.java"
    click TaskAbstract "https://github.com/gracesong146/ip/blob/master/src/main/java/Task.java"
    click ToDo "https://github.com/gracesong146/ip/blob/master/src/main/java/ToDo.java"
    click Deadline "https://github.com/gracesong146/ip/blob/master/src/main/java/Deadline.java"
    click Event "https://github.com/gracesong146/ip/blob/master/src/main/java/Event.java"
    click TaskType "https://github.com/gracesong146/ip/blob/master/src/main/java/TaskType.java"
    click InvalidType "https://github.com/gracesong146/ip/blob/master/src/main/java/InvalidTaskTypeException.java"
    click Storage "https://github.com/gracesong146/ip/blob/master/src/main/java/Storage.java"
    click DataFile "https://github.com/gracesong146/ip/blob/master/data/cathy.txt"
    click TestHarness "https://github.com/gracesong146/ip/tree/master/text-ui-test/"
    click InputScript "https://github.com/gracesong146/ip/blob/master/text-ui-test/input.txt"
    click Expected "https://github.com/gracesong146/ip/blob/master/text-ui-test/EXPECTED.TXT"
    click RunnerBat "https://github.com/gracesong146/ip/blob/master/text-ui-test/runtest.bat"
    click RunnerSh "https://github.com/gracesong146/ip/blob/master/text-ui-test/runtest.sh"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6;
    classDef domain fill:#DFF2BF,stroke:#4F8A10;
    classDef persistence fill:#FFE599,stroke:#B45F06;
    classDef test fill:#E0E0E0,stroke:#666;
```
