# tephsav/mvc-tableeditor architecture

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

- Interactive diagram: https://gitdiagram.com/tephsav/mvc-tableeditor
- Repository: https://github.com/tephsav/mvc-tableeditor

## Overview

##### Project type and purpose
- This is a desktop GUI application written in Java.
- It uses the Swing toolkit and follows the Model-View-Controller (MVC) pattern.
- It performs CRUD operations on “Student” data, persisting data to an XML file via DOM and SAX parsers.

##### File structure
- Top-level directories/files:
- .gitignore, IDEA project files
- photos/ (screenshots of the UI)
- README.md
- src/
- Under src/:
- Controller/Controller.java
- Model/Model.java, Student.java, TableModel.java
- View/EntryPoint.java, MainFrame.java, AddDialog.java, DeleteDialog.java, SearchDialog.java, XMLHandler.java
- No database; persistence handled by XMLHandler in the View package.

##### Extract architecture insights from the README
- Confirms MVC pattern, Swing UI, XML via DOM and SAX.
- No web server or external microservices—purely desktop.

##### Main components
a. View Layer (Swing UI)
– EntryPoint
– MainFrame (menu, table display)
– AddDialog, DeleteDialog, SearchDialog
b. Controller Layer
– Controller (receives user actions, orchestrates operations)
c. Model Layer
– Model (business logic, holds Student list)
– Student (data structure)
– TableModel (bridges Model data to Swing’s JTable)
d. Persistence
– XMLHandler (reads/writes XML file via DOM/SAX)

##### Relationships and data flow
- User clicks in View → events propagated to Controller
- Controller invokes Model methods (create, read, update, delete)
- Model updates its internal data (List<Student>)
- Model notifies TableModel of changes → View refreshes JTable
- For persistence, Model (or Controller via XMLHandler) calls XMLHandler to load or save XML

##### Architectural patterns and design principles
- MVC separation:
- Model is unaware of View
- View components forward events only to Controller
- Controller mediates between View and Model
- Observer (Swing’s TableModel) for UI updates
- Single responsibility for XMLHandler (parsing/persistence)

##### Essential details not to omit
- The XML file as the persistence store
- TableModel’s observer role in UI updates
- Clear separation of MVC packages
- Swing event flow from View to Controller

##### Final checklist
- [ ] Clear labels for all classes/components
- [ ] Package/group boundaries (Model, View, Controller)
- [ ] Persistence layer (XMLHandler + XML file) explicitly shown

## Diagram (Mermaid)

```mermaid
graph TD
    %% View Layer
    subgraph "View Layer"
        EP["EntryPoint"]:::view
        MF["MainFrame"]:::view
        AD["AddDialog"]:::view
        DD["DeleteDialog"]:::view
        SD["SearchDialog"]:::view
    end

    %% Controller Layer
    subgraph "Controller Layer"
        C["Controller"]:::controller
    end

    %% Model Layer
    subgraph "Model Layer"
        M["Model"]:::model
        S["Student"]:::model
        TM["TableModel"]:::model
    end

    %% Persistence Layer
    subgraph "Persistence"
        XH["XMLHandler"]:::persistence
        XMLFile["students.xml"]:::storage
    end

    %% Relationships
    EP -->|"launches"| MF
    MF -->|"userAction()"| C
    AD -->|"addStudent()"| C
    DD -->|"deleteStudent()"| C
    SD -->|"searchStudent()"| C
    C -->|"create()/read()/update()/delete()"| M
    M -->|"fireTableDataChanged()"| TM
    TM -->|"updateView()"| MF
    C -->|"loadFromXML()/saveToXML()"| XH
    XH -->|"reads/writes"| XMLFile

    %% Click Events
    click EP "https://github.com/tephsav/mvc-tableeditor/blob/master/src/View/EntryPoint.java"
    click MF "https://github.com/tephsav/mvc-tableeditor/blob/master/src/View/MainFrame.java"
    click AD "https://github.com/tephsav/mvc-tableeditor/blob/master/src/View/AddDialog.java"
    click DD "https://github.com/tephsav/mvc-tableeditor/blob/master/src/View/DeleteDialog.java"
    click SD "https://github.com/tephsav/mvc-tableeditor/blob/master/src/View/SearchDialog.java"
    click C "https://github.com/tephsav/mvc-tableeditor/blob/master/src/Controller/Controller.java"
    click M "https://github.com/tephsav/mvc-tableeditor/blob/master/src/Model/Model.java"
    click S "https://github.com/tephsav/mvc-tableeditor/blob/master/src/Model/Student.java"
    click TM "https://github.com/tephsav/mvc-tableeditor/blob/master/src/Model/TableModel.java"
    click XH "https://github.com/tephsav/mvc-tableeditor/blob/master/src/View/XMLHandler.java"

    %% Styles
    classDef view fill:#ADD8E6,stroke:#000,color:#000
    classDef controller fill:#90EE90,stroke:#000,color:#000
    classDef model fill:#FFA500,stroke:#000,color:#000
    classDef persistence fill:#DDA0DD,stroke:#000,color:#000
    classDef storage fill:#9370DB,stroke:#000,color:#fff,shape:cylinder
```
