# parthgandhinus/tp architecture

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

- Interactive diagram: https://gitdiagram.com/parthgandhinus/tp
- Repository: https://github.com/parthgandhinus/tp

## Overview

##### Project Type and Purpose
- This is a single‐module, command‐line Java application (an open‐source CLI student classification tool), built with Gradle.
- It implements a command‐pattern architecture to let users add, edit, list, archive, and view students stored in a text file.

a. User Interface Layer
- DataUI / UI classes (src/main/java/classify/ui)
- Responsible for I/O with console, invoking the command‐framework.
b. Input Parsing Layer
- UserInput, InputParsing, and exception classes (src/main/java/classify/user)
- Validates and transforms raw strings into structured arguments.
c. Command Layer
- Commands interface and implementations (src/main/java/classify/commands)
- Follows the Command pattern; each command encapsulates an action (AddStudent, EditStudent, ArchiveCommands, etc.).
d. Data Layer
- DataHandler/DataReader/DataWriter (src/main/java/classify/data)
- Coordinates reading from and writing to persistent storage.
e. Domain Model
- Student, StudentAttributes, StudentList, SubjectGrade, Details (src/main/java/classify/student)
- Represents business entities, with sorting/comparator utilities.
f. Text File I/O
- TextFileHandler/Parser/Reader (src/main/java/classify/textfilecode)
- Implements low‐level parsing and formatting of the .txt data store.
g. Persistence (the text file “database”)
- A flat text file in the working directory, manipulated by TextFileHandler.

- UI → InputParsing: user’s raw input
- InputParsing → CommandFactory/Commands: dispatches to specific Command object
- Command → Domain Model (StudentList): reads or mutates in‐memory list
- Command → DataHandler → DataReader/TextFileParser → Persistence
(for load operations)
- Command → DataHandler → DataWriter/TextFileHandler → Persistence
(for save operations)
- Results → UI: formatted output to console

##### Architectural Patterns & Principles
- Command Pattern (commands folder): decouples user actions from execution logic.
- Single Responsibility (each package—ui, user, commands, data, student—has a clear role).
- Layered Architecture: UI → parsing → command → data → persistence.
- Dependency Injection (simple: higher layers instantiate lower‐level handlers).

##### Technologies & Frameworks
- Java 11
- Gradle build automation (build.gradle, gradlew wrapper)
- Checkstyle for code style (config/checkstyle)
- JUnit for testing (src/test)
- GitHub Actions for CI (.github/workflows/gradle.yml)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Entry
    Classify["Classify.java"]:::entry
    click Classify "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/Classify.java"

    %% UI Layer
    subgraph "UI Layer"
        UI["UI.java"]:::ui
        DataUI["DataUI.java"]:::ui
        click UI "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/ui/UI.java"
        click DataUI "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/ui/DataUI.java"
    end

    %% Parser Layer
    subgraph "Parsing Layer"
        UserInput["UserInput.java"]:::parser
        InputParsing["InputParsing.java"]:::parser
        Exceptions["Exceptions"]:::parser_note
        click UserInput "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/user/UserInput.java"
        click InputParsing "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/user/InputParsing.java"
        click Exceptions "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/user/ClassifyExceptions.java"
    end
    subgraph "Parsing Exceptions"
        ICE["InvalidCharacterException.java"]:::parser
        IPNE["InvalidPhoneNumberException.java"]:::parser
        ISE["InvalidSubjectException.java"]:::parser
        NME["NameNumberMatchException.java"]:::parser
        click ICE "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/user/InvalidCharacterException.java"
        click IPNE "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/user/InvalidPhoneNumberException.java"
        click ISE "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/user/InvalidSubjectException.java"
        click NME "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/user/NameNumberMatchException.java"
    end

    %% Command Layer
    subgraph "Command Layer"
        Commands["Commands.java"]:::commands
        AddStudent["AddStudent.java"]:::commands
        EditStudent["EditStudent.java"]:::commands
        ArchiveCommands["ArchiveCommands.java"]:::commands
        DeleteCommands["DeleteCommands.java"]:::commands
        ListStudents["ListStudentsCommand.java"]:::commands
        ViewStudent["ViewStudent.java"]:::commands
        Comparator["StudentComparator*.java"]:::commands
        Sorter["StudentSorter.java"]:::commands
        click Commands "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/Commands.java"
        click AddStudent "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/AddStudent.java"
        click EditStudent "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/EditStudent.java"
        click ArchiveCommands "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/ArchiveCommands.java"
        click DeleteCommands "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/DeleteCommands.java"
        click ListStudents "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/ListStudentsCommand.java"
        click ViewStudent "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/ViewStudent.java"
        click Comparator "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/StudentComparator*.java"
        click Sorter "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/commands/StudentSorter.java"
    end

    %% Data Layer
    subgraph "Data Layer"
        DataHandler["DataHandler.java"]:::data
        DataReader["DataReader.java"]:::data
        DataWriter["DataWriter.java"]:::data
        click DataHandler "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/data/DataHandler.java"
        click DataReader "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/data/DataReader.java"
        click DataWriter "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/data/DataWriter.java"
    end

    %% TextFile I/O
    subgraph "TextFile I/O"
        TFHandler["TextFileHandler.java"]:::textio
        TFParser["TextFileParser.java"]:::textio
        TFReader["TextFileReader.java"]:::textio
        click TFHandler "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/textfilecode/TextFileHandler.java"
        click TFParser "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/textfilecode/TextFileParser.java"
        click TFReader "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/textfilecode/TextFileReader.java"
    end

    %% Domain Model
    subgraph "Domain Model"
        Student["Student.java"]:::domain
        Attributes["StudentAttributes.java"]:::domain
        Details["Details.java"]:::domain
        SubjectGrade["SubjectGrade.java"]:::domain
        StudentList["StudentList.java"]:::domain
        click Student "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/student/Student.java"
        click Attributes "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/student/StudentAttributes.java"
        click Details "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/student/Details.java"
        click SubjectGrade "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/student/SubjectGrade.java"
        click StudentList "https://github.com/parthgandhinus/tp/blob/master/src/main/java/classify/student/StudentList.java"
    end

    %% Persistence
    Persistence[(SampleFile.txt)]:::persistence
    click Persistence "https://github.com/parthgandhinus/tp/blob/master/docs/SampleFile.txt"

    %% Tooling & CI
    subgraph "Tooling & CI"
        Gradle["Gradle (build.gradle)"]:::tool
        Checkstyle["Checkstyle (config/checkstyle)"]:::tool
        CI["GitHub Actions"]:::tool
    end

    %% Relationships
    Classify -->|"starts"| UI
    UI -->|"raw input"| UserInput
    UserInput -->|"parse"| InputParsing
    InputParsing -->|"throws Exceptions"| Exceptions
    InputParsing -->|"dispatch"| Commands
    Commands -->|"execute"| AddStudent
    Commands -->|"execute"| EditStudent
    Commands -->|"execute"| ArchiveCommands
    Commands -->|"execute"| DeleteCommands
    Commands -->|"execute"| ListStudents
    Commands -->|"execute"| ViewStudent
    Commands -->|"use comparators"| Comparator
    Commands -->|"use sorter"| Sorter
    Commands -->|"mutate/read"| StudentList
    Commands -->|"call"| DataHandler
    DataHandler -->|"read"| DataReader
    DataReader -->|"parse"| TFParser
    TFParser -->|"load from"| Persistence
    DataHandler -->|"write"| DataWriter
    DataWriter -->|"format"| TFHandler
    TFHandler -->|"save to"| Persistence
    Commands -->|"results"| UI

    %% Styles
    classDef entry fill:#e3f2fd,stroke:#2196f3,color:#0d47a1;
    classDef ui fill:#bbdefb,stroke:#0d47a1,color:#0d47a1;
    classDef parser fill:#ffe0b2,stroke:#fb8c00,color:#e65100;
    classDef parser_note fill:#fff3e0,stroke:#fb8c00,color:#e65100,stroke-dasharray: 2 2;
    classDef commands fill:#c8e6c9,stroke:#388e3c,color:#1b5e20;
    classDef data fill:#e1bee7,stroke:#8e24aa,color:#4a148c;
    classDef textio fill:#f3e5f5,stroke:#6a1b9a,color:#4a148c;
    classDef domain fill:#eceff1,stroke:#607d8b,color:#37474f;
    classDef persistence fill:#ffecb3,stroke:#ffa000,color:#bf360c,shape:cylinder;
    classDef tool fill:#cfd8dc,stroke:#607d8b,color:#455a64;
```
