# brikanpo/orderflow architecture

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

- Interactive diagram: https://gitdiagram.com/brikanpo/orderflow
- Repository: https://github.com/brikanpo/orderflow

## Overview

1. This is a layered Java application built with Maven and Java modules. The runtime is centered on `it.orderflow.Main`, with configuration handled by `ConfigManager` and `src/main/resources/config.properties`.

2. The application supports two presentation fronts: a CLI UI and a JavaFX UI. Both expose the same functional screens (`Login`, `Home`, `Manage*`, `AddClientOrder`, `CloseClientOrder`, `PersonalInfo`) through parallel view implementations under `view.cli` and `view.javafx`.

3. The UI layer is separated from interaction logic by “view controllers” (`control.viewcontroller`). These controllers receive view events, translate them into application actions, and notify the corresponding logic layer. The root views/controllers coordinate top-level navigation and screen switching.

4. Business/use-case orchestration lives in `control.logiccontroller`. Each major workflow has a dedicated logic controller, such as login, client/order management, product/article/supplier management, employee management, and personal-info management. This is the main boundary where validation, permissions, and workflow decisions are handled.

5. The domain model is in `model`. It contains core entities such as `Employee`, `Client`, `Supplier`, `Product`, `Article`, `ClientOrder`, `SupplierOrder`, `Inventory`, and supporting value objects like addresses, contacts, quantities, order state, and roles. The `beans` package appears to provide simpler data-transfer shapes for UI/controller exchange and tabular display.

6. Persistence is abstracted behind DAO interfaces in `dao`. The app uses a factory pattern (`DAOFactory`, `DAOType`) to select a backend implementation. There are three persistence families: database-backed DAOs in `dao.dbms`, cached wrappers in `dao.cache`, and a smaller file-backed path in `dao.file` (notably employee-related).

7. The DBMS backend is the primary durable store. `DBMSConnectionPool` indicates pooled database access, and the `DBMS*DAO` classes are the concrete adapters used by the use-case layer. The cache package wraps DAO behavior to improve read performance and likely protect data consistency with an application-level cache.

8. Transaction handling is explicit. `dao.TransactionControl`, `control.TransactionSafeController`, and the `Statement` type suggest that multi-step workflows are executed with transaction boundaries and rollback-safe coordination, especially for order creation/closure and inventory changes.

9. Data flow is typically: user action in a CLI/JavaFX view → view controller → logic controller → DAO layer → DB/cache/file backend → domain objects/beans → back to the view. Selection screens for clients, products, suppliers, and related articles are used to support composite workflows like order assembly.

10. The application includes role-oriented behavior. `model.UserRole`, employee access-related classes, and the login/home flow suggest navigation and available actions depend on the authenticated user’s role.

11. There is a small service layer for external communication: `services.EmailSenderService`. This is likely invoked from business logic when notifications or confirmations need to be sent, making email an external side effect rather than a UI concern.

12. Error handling is modeled with a dedicated exception hierarchy in `exceptions`, covering persistence, entity lookup, authentication, invalid input/state, and integration failures. This keeps failures meaningful as they cross the controller/DAO boundaries.

13. Tests focus on domain behavior and at least one key use case (`AddClientOrderLogicController`), with mock DAO/model implementations under `src/test/java/mock`. That indicates the architecture is designed to be unit-tested by substituting persistence dependencies.

14. For an architecture diagram, the main boundaries to show are: presentation (CLI/JavaFX), interaction controllers, business logic controllers, domain model, persistence abstraction, concrete persistence backends (DBMS/cache/file), and external services like email and the database.

Main entry points: [`src/main/java/it/orderflow/control/logiccontroller`](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/control/logiccontroller) (Logic Controllers), [`src/main/java/it/orderflow/dao/DAOFactory.java`](https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/dao/DAOFactory.java) (DAO Factory), [`src/main/java/it/orderflow/control/viewcontroller`](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/control/viewcontroller) (View Controllers), [`src/main/java/it/orderflow/dao`](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao) (DAO APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_cli_views["CLI Views<br/>presentation"]
  node_fx_views["JavaFX Views<br/>presentation"]
  node_shared_views["View API<br/>view contracts"]
end

subgraph group_interaction["Interaction"]
  node_view_ctrls["View Controllers<br/>ui bridge"]
  node_root_ctrl["Root Flow<br/>navigation"]
end

subgraph group_business["Business"]
  node_main(("Main<br/>bootstrap<br/>[Main.java]"))
  node_config["Config<br/>settings<br/>[ConfigManager.java]"]
  node_logic_ctrls["Logic Controllers<br/>use cases"]
  node_tx_ctrl["Tx Control<br/>transaction"]
  node_exceptions["Exceptions<br/>error model"]
end

subgraph group_domain["Domain"]
  node_domain_model["Domain Model<br/>entities"]
  node_beans["Beans<br/>dto shapes"]
end

subgraph group_persistence["Persistence"]
  node_dao_factory["DAO Factory<br/>persistence api<br/>[DAOFactory.java]"]
  node_dao_api["DAO APIs<br/>repositories"]
  node_dbms_daos["DBMS DAOs<br/>db adapters"]
  node_cache_daos["Cache DAOs<br/>cached adapters"]
  node_file_daos["File DAOs<br/>file adapters"]
end

subgraph group_external["External"]
  node_email(("Email Service<br/>external service"))
end

node_main -->|"loads"| node_config
node_main -->|"boots UI"| node_shared_views
node_shared_views -->|"CLI impl"| node_cli_views
node_shared_views -->|"FX impl"| node_fx_views
node_cli_views -->|"events"| node_view_ctrls
node_fx_views -->|"events"| node_view_ctrls
node_view_ctrls -->|"navigate"| node_root_ctrl
node_view_ctrls -->|"invoke"| node_logic_ctrls
node_root_ctrl -->|"session flow"| node_logic_ctrls
node_logic_ctrls -->|"orchestrate"| node_tx_ctrl
node_tx_ctrl -->|"access"| node_dao_api
node_logic_ctrls -->|"reads/writes"| node_dao_api
node_dao_api -->|"select backend"| node_dao_factory
node_dao_factory -->|"dbms"| node_dbms_daos
node_dao_factory -->|"cache"| node_cache_daos
node_dao_factory -->|"file"| node_file_daos
node_dbms_daos -->|"maps"| node_domain_model
node_cache_daos -->|"wraps"| node_dbms_daos
node_file_daos -->|"maps"| node_domain_model
node_logic_ctrls -->|"projects"| node_beans
node_domain_model -->|"adapts"| node_beans
node_logic_ctrls -->|"notifies"| node_email
node_logic_ctrls -->|"raises"| node_exceptions
node_dao_api -->|"fails with"| node_exceptions

click node_main "https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/Main.java"
click node_config "https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/ConfigManager.java"
click node_cli_views "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/view/cli"
click node_fx_views "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/view/javafx"
click node_shared_views "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/view"
click node_view_ctrls "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/control/viewcontroller"
click node_root_ctrl "https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/control/RootController.java"
click node_logic_ctrls "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/control/logiccontroller"
click node_tx_ctrl "https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/control/TransactionSafeController.java"
click node_dao_factory "https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/dao/DAOFactory.java"
click node_dao_api "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao"
click node_dbms_daos "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao/dbms"
click node_cache_daos "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao/cache"
click node_file_daos "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao/file"
click node_domain_model "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/model"
click node_beans "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/beans"
click node_email "https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/services/EmailSenderService.java"
click node_exceptions "https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/exceptions"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli_views,node_fx_views,node_shared_views toneBlue
class node_view_ctrls,node_root_ctrl toneAmber
class node_main,node_config,node_logic_ctrls,node_tx_ctrl,node_exceptions toneMint
class node_domain_model,node_beans toneRose
class node_dao_factory,node_dao_api,node_dbms_daos,node_cache_daos,node_file_daos toneIndigo
class node_email toneTeal
```

## Components

### Presentation

CLI and JavaFX front ends plus shared view contracts

- [CLI Views](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/view/cli): presentation · Console implementations of login, home, management, and selection screens · `src/main/java/it/orderflow/view/cli`
- [JavaFX Views](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/view/javafx): presentation · GUI implementations of the same screens and reusable widgets · `src/main/java/it/orderflow/view/javafx`
- [View API](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/view): view contracts · Shared view interfaces, events, and factories · `src/main/java/it/orderflow/view`

### Interaction

View controllers that translate UI events into app actions

- [View Controllers](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/control/viewcontroller): ui bridge · Receives view events and routes them to business logic · `src/main/java/it/orderflow/control/viewcontroller`
- [Root Flow](https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/control/RootController.java): navigation · Top-level screen switching and session navigation · `src/main/java/it/orderflow/control/RootController.java`

### Business

Workflow orchestration and transaction coordination

- [Main](https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/Main.java): bootstrap · Application entry point and startup wiring · `src/main/java/it/orderflow/Main.java`
- [Config](https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/ConfigManager.java): settings · Loads runtime configuration · `src/main/java/it/orderflow/ConfigManager.java`
- [Logic Controllers](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/control/logiccontroller): use cases · Login, order, and management workflows with validation and permissions · `src/main/java/it/orderflow/control/logiccontroller`
- [Tx Control](https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/control/TransactionSafeController.java): transaction · Coordinates rollback-safe multi-step operations · `src/main/java/it/orderflow/control/TransactionSafeController.java`
- [Exceptions](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/exceptions): error model · Domain, persistence, authentication, and integration failure types · `src/main/java/it/orderflow/exceptions`

### Domain

Entities, value objects, and UI data shapes

- [Domain Model](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/model): entities · Core business entities and value objects such as employees, clients, orders, inventory, and roles · `src/main/java/it/orderflow/model`
- [Beans](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/beans): dto shapes · Simpler transfer objects for view/controller exchange and tables · `src/main/java/it/orderflow/beans`

### Persistence

DAO abstractions and backend implementations

- [DAO Factory](https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/dao/DAOFactory.java): persistence api · Selects DAO backend family · `src/main/java/it/orderflow/dao/DAOFactory.java`
- [DAO APIs](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao): repositories · Persistence interfaces for clients, orders, products, suppliers, employees, and articles · `src/main/java/it/orderflow/dao`
- [DBMS DAOs](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao/dbms): db adapters · Primary database-backed DAO implementations and connection pool · `src/main/java/it/orderflow/dao/dbms`
- [Cache DAOs](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao/cache): cached adapters · Application-level caching wrappers around DAO behavior · `src/main/java/it/orderflow/dao/cache`
- [File DAOs](https://github.com/brikanpo/orderflow/tree/main/src/main/java/it/orderflow/dao/file): file adapters · File-backed persistence path for employee data · `src/main/java/it/orderflow/dao/file`

### External

Database, file store, and email side effects

- [Email Service](https://github.com/brikanpo/orderflow/blob/main/src/main/java/it/orderflow/services/EmailSenderService.java): external service · Sends outbound notifications and confirmations · `src/main/java/it/orderflow/services/EmailSenderService.java`

## Connections

- Main → Config: loads · Startup reads configuration
- Main → View API: boots UI · Application creates and starts the chosen view stack
- View API → CLI Views: CLI impl · Console implementation family
- View API → JavaFX Views: FX impl · JavaFX implementation family
- CLI Views → View Controllers: events · Views send user actions upward
- JavaFX Views → View Controllers: events · Views send user actions upward
- View Controllers → Root Flow: navigate · Root controllers manage top-level screen flow
- View Controllers → Logic Controllers: invoke · UI events become use-case calls
- Root Flow → Logic Controllers: session flow · Login and role-dependent navigation depend on business logic
- Logic Controllers → Tx Control: orchestrate · Complex workflows use transaction-safe coordination
- Tx Control → DAO APIs: access · Transactional workflows operate through DAO abstractions
- Logic Controllers → DAO APIs: reads/writes · Use cases persist and query via repository interfaces
- DAO APIs → DAO Factory: select backend · Factory chooses implementation family
- DAO Factory → DBMS DAOs: dbms · Primary durable backend
- DAO Factory → Cache DAOs: cache · Cached wrapper backend
- DAO Factory → File DAOs: file · Employee file-backed backend
- DBMS DAOs → Domain Model: maps · Database adapters materialize domain objects
- Cache DAOs → DBMS DAOs: wraps · Cache layer delegates to concrete persistence
- File DAOs → Domain Model: maps · File adapters materialize domain objects
- Logic Controllers → Beans: projects · Controllers exchange table-friendly data shapes with views
- Domain Model → Beans: adapts · Domain data is projected into UI-facing beans
- Logic Controllers → Email Service: notifies · Some workflows trigger outbound email
- Logic Controllers → Exceptions: raises · Validation, auth, and persistence failures cross the boundary
- DAO APIs → Exceptions: fails with · DAO contracts surface persistence-related errors
