# david12-ops/systemproject architecture

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

- Interactive diagram: https://gitdiagram.com/david12-ops/systemproject
- Repository: https://github.com/david12-ops/systemproject

## Overview

##### Project type and purpose
- This is a Java desktop GUI application (likely JavaFX-based) organized with MVC (Model–View–Controller) and a set of reusable UI components.
- It provides user authentication screens (login, register, forgot credentials, switch user), a main application screen, and supports avatar uploads, file-drop zones, and tabular data.

##### File structure
- Top-level src/main/java/com/example:
- components: reusable UI widgets (AppBar, SideBar, Table, FileDropZone, etc.)
- view: concrete screens (LoginScreen, RegisterScreen, MainScreen, etc.)
- controller: controllers handling user events and coordinating between view and model (UserController, MessageController, ScreenController)
- model: domain entities and their “Model” wrappers (User, Message, UserModel, MessageModel, UserToken)
- utils: cross-cutting concerns—error handling, JSON storage, image conversion, enums, interfaces, and service implementations (SessionService, ValidationService, StateEventService)
- src/main/resources/styles: CSS files for styling the UI.
- src/test: unit tests for core utilities and model validations.

##### README
- Minimal (“# JavaProject”), so our understanding comes primarily from the package structure.

a. Main components
- Presentation Layer
– View screens (LoginScreen, MainScreen, etc.)
– UI Components library (AppBar, CustomGridPane, FileDropZone, etc.)
- Controller Layer
– ScreenController (navigates between screens)
– UserController (handles user CRUD & auth)
– MessageController (manages messages)
- Domain Layer
– Models (UserModel, MessageModel)
– Entities (User, Message, UserToken)
- Service/Utility Layer
– SessionService (auth/session state)
– StateEventService (event bus)
– ValidationService (model & input validation)
– JsonStorageTool (persist/retrieve data from JSON)
– ImageConvertor, ErrorToolManager
- Resource Layer
– CSS style assets
– Local JSON files (data store)
b. Relationships & interactions
1. User interacts with View → triggers Controller via event listeners
2. Controller invokes Service(s) for business logic and validation
3. Service calls JsonStorageTool to read/write persistent data
4. Controller updates Model or issues events via StateEventService
5. View subscribes to model/state changes and re-renders UI components
6. ImageConvertor and ErrorToolManager are invoked by controllers/services as needed
c. Architectural patterns/design principles
- MVC: clear separation of View, Controller, Model
- Layered architecture: Presentation → Application/Controller → Domain → Infrastructure
- Dependency inversion via interfaces in utils/interfaces
- Service-oriented approach for cross-cutting concerns (validation, session, state events)
d. Relevant technologies/frameworks
- Java (JDK)
- JavaFX UI toolkit (implied by custom components & CSS)
- JSON storage for local persistence
- JUnit (tests)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        AppBar["AppBar"]:::presentation
        SideBar["SideBar"]:::presentation
        CustomGridPane["CustomGridPane"]:::presentation
        FileDropZone["FileDropZone"]:::presentation
        TableComp["Table"]:::presentation
        Avatar["Avatar"]:::presentation
        LayoutComp["Layout"]:::presentation

        LoginScreen["LoginScreen"]:::presentation
        RegisterScreen["RegisterScreen"]:::presentation
        ForgotCredentialsScreen["ForgotCredentialsScreen"]:::presentation
        SwitchUserScreen["SwitchUserScreen"]:::presentation
        AddAnotherAccountScreen["AddAnotherAccountScreen"]:::presentation
        UpdateAvatar["UpdateAvatar"]:::presentation
        MainScreen["MainScreen"]:::presentation
    end

    %% Controller Layer
    subgraph "Controller Layer"
        direction TB
        UserController["UserController"]:::controller
        MessageController["MessageController"]:::controller
        ScreenController["ScreenController"]:::controller
    end

    %% Domain Layer
    subgraph "Domain Layer"
        direction TB
        UserEnt["User"]:::domain
        MessageEnt["Message"]:::domain
        UserToken["UserToken"]:::domain
        UserModel["UserModel"]:::domain
        MessageModel["MessageModel"]:::domain
    end

    %% Service/Utility Layer
    subgraph "Service/Utility Layer"
        direction TB
        JsonStorageTool["JsonStorageTool"]:::service
        ImageConvertor["ImageConvertor"]:::service
        ErrorToolManager["ErrorToolManager"]:::service

        subgraph "Interfaces"
            AuthManagement["AuthManagement"]:::service
            UserManagement["UserManagement"]:::service
            ErrorManagement["ErrorManagement"]:::service
            GuiHelperFunctions["GuiHelperFunctions"]:::service
            UserModelValidations["UserModelValidationsTools"]:::service
            MessageModelValidations["MessageModelValidationsTools"]:::service
        end

        subgraph "Enums"
            AddTypeOperation["AddTypeOperation"]:::service
            Environment["Environment"]:::service
            FormEnum["Form"]:::service
            GetUserTypeOperation["GetUserTypeOperation"]:::service
            LayoutMode["LayoutMode"]:::service
            MessageType["MessageType"]:::service
            OperationEnum["Operation"]:::service
        end

        SessionService["SessionService"]:::service
        StateEventService["StateEventService"]:::service
        ValidationService["ValidationService"]:::service
    end

    %% Resource Layer
    subgraph "Resource Layer"
        direction TB
        Styles["CSS Stylesheets"]:::resource
        JSONStore["Local JSON Files"]:::storage
    end

    %% Connections
    %% Views to ScreenController
    LoginScreen -->|"navigate()"| ScreenController
    RegisterScreen -->|"navigate()"| ScreenController
    ForgotCredentialsScreen -->|"navigate()"| ScreenController
    SwitchUserScreen -->|"navigate()"| ScreenController
    AddAnotherAccountScreen -->|"navigate()"| ScreenController
    UpdateAvatar -->|"navigate()"| ScreenController
    MainScreen -->|"navigate()"| ScreenController

    %% ScreenController to other controllers
    ScreenController -->|"loadUserScreen()"| UserController
    ScreenController -->|"loadMessageScreen()"| MessageController

    %% Controllers to Services
    UserController -->|"validateUser()"| ValidationService
    UserController -->|"manageSession()"| SessionService
    UserController -->|"convertImage()"| ImageConvertor
    UserController -->|"handleError()"| ErrorToolManager
    UserController -->|"persistUser()"| JsonStorageTool

    MessageController -->|"validateMessage()"| ValidationService
    MessageController -->|"persistMessage()"| JsonStorageTool
    MessageController -->|"handleError()"| ErrorToolManager

    %% Services to Storage and Event
    JsonStorageTool -->|"read/write()"| JSONStore
    ValidationService -->|"usesInterfaces()"| AuthManagement
    ValidationService -->|"usesInterfaces()"| UserModelValidations
    ValidationService -->|"usesInterfaces()"| MessageModelValidations
    SessionService -->|"broadcast()"| StateEventService
    StateEventService -->|"notify()"| MainScreen
    StateEventService -->|"notify()"| TableComp

    %% Domain interactions
    UserController -->|"updateModel()"| UserModel
    MessageController -->|"updateModel()"| MessageModel
    UserModel -->|"contains"| UserEnt
    MessageModel -->|"contains"| MessageEnt
    UserModel -->|"contains"| UserToken

    %% Resources to Presentation
    Styles -->|"appliedTo"| AppBar
    Styles -->|"appliedTo"| LayoutComp

    %% Click Events
    click AppBar "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/components/AppBar.java"
    click SideBar "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/components/SideBar.java"
    click CustomGridPane "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/components/CustomGridPane.java"
    click FileDropZone "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/components/FileDropZone.java"
    click TableComp "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/components/Table.java"
    click Avatar "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/components/Avatar.java"
    click LayoutComp "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/components/Layout.java"

    click LoginScreen "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/view/LoginScreen.java"
    click RegisterScreen "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/view/RegisterScreen.java"
    click ForgotCredentialsScreen "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/view/ForgotCredentialsScreen.java"
    click SwitchUserScreen "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/view/SwitchUserScreen.java"
    click AddAnotherAccountScreen "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/view/AddAnotherAccountScreen.java"
    click UpdateAvatar "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/view/UpdateAvatar.java"
    click MainScreen "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/view/MainScreen.java"

    click UserController "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/controller/UserController.java"
    click MessageController "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/controller/MessageController.java"
    click ScreenController "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/controller/ScreenController.java"

    click UserEnt "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/model/User.java"
    click MessageEnt "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/model/Message.java"
    click UserToken "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/model/UserToken.java"
    click UserModel "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/model/UserModel.java"
    click MessageModel "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/model/MessageModel.java"

    click JsonStorageTool "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/utils/JsonStorageTool.java"
    click ImageConvertor "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/utils/ImageConvertor.java"
    click ErrorToolManager "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/utils/ErrorToolManager.java"

    click SessionService "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/utils/services/SessionService.java"
    click StateEventService "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/utils/services/StateEventService.java"
    click ValidationService "https://github.com/david12-ops/systemproject/blob/main/src/main/java/com/example/utils/services/ValidationService.java"

    click Styles "https://github.com/david12-ops/systemproject/tree/main/src/main/resources/styles"
    
    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef controller fill:#D6F5D6,stroke:#28A745,color:#28A745;
    classDef domain fill:#FFF5CC,stroke:#D4A017,color:#D4A017;
    classDef service fill:#FFE5CC,stroke:#F66D0A,color:#F66D0A;
    classDef resource fill:#E8E8E8,stroke:#6A737D,color:#6A737D;
    classDef storage fill:#E8E8E8,stroke:#6A737D,color:#6A737D,stroke-dasharray: 5 5;
    class TableComp presentation
    class Styles resource
```
