# exora02/autochef architecture

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

- Interactive diagram: https://gitdiagram.com/exora02/autochef
- Repository: https://github.com/exora02/autochef

## Overview

##### Project Type & Purpose
- The README explains that Autochef is an application for managing shopping lists and recipes.
- The project uses Java 15 with Maven for dependency management and build processes.
- The runtime is primarily via JavaFX (as seen by the "mvn clean javafx:run" command and the FXML files in src/main/resources), indicating a rich graphical user interface.
- The presence of “database” packages, “model” packages (SQL models), and “util/import_export” functionality suggests that the application not only handles UI but also interacts with a structured storage (likely a SQL database or dump).

##### Analyzing the File Structure
- Top-level directories indicate a traditional Maven project with directories such as src/main/java, src/main/resources, and test.
- Within src/main/java/ulb/infof307/g02, the project is organized into several layers:
– The /gui directory is divided between controller and view subdirectories, which makes the use of an MVC pattern apparent. Controllers (in /controller) handle business logic connected to the UI while the views (including FXML files in src/main/resources/ulb/infof307/g02/gui/view) represent the presentation layer.
– The /model directory includes subdirectories for SQL interfaces, concrete SQL models (like ingredient_model, recipe_model, etc.), and a shared superclass for SQL-related methods. This segmentation reflects a clear separation between domain logic and data persistence.
– The /database package contains classes (DatabaseManager, DatabaseQuery, DatabaseTool) that abstract and manage the connection to and operations on the underlying database.
– The /util directory contains general utility classes (such as AlertUtils, FieldUtils, and RecipeCellFactory) and an import/export module for external interactions (e.g., JSON, PDF, email).
- Additional directories such as “doc” provide generated documentation, and “test” hosts testing classes that mirror the main project structure.

a. Main Components:
- User Interface Layer (Presentation):
– GUI Views: FXML files and JavaFX controllers (located in src/main/resources and src/main/java/…/gui/view).
– UI Controllers: Handle user events and bridge the view with the application logic (see src/main/java/…/gui/controller).
- Business Logic Layer:
– Controllers that coordinate the actions between UI and Model: login, main application controllers, recipe management controllers, scheduling, and shopping list management.
- Domain/Model Layer:
– SQL Models and domain objects for ingredients, recipes, shopping lists, stores, users, and schedules.
– Model Interfaces that abstract the concrete implementation details.
- Data Access Layer:
– Database Core: Classes such as DatabaseManager, DatabaseQuery, and DatabaseTool manage persistence.
- Utilities & External Integration:
– Utility classes for alerts, field handling, and custom cell factories.
– Import/export components handle data serialization (JSON, PDF, email integration).
- Configuration & Deployment:
– Maven (pom.xml) governs the build.
– Resources include configuration files (e.g., log4j.xml) and initial dumps for database setup.

b. Relationships and Interactions:
- The UI layer (views and their controllers) receives user input, which is then passed to the business logic controllers.
- Controllers invoke methods in the domain/model layer to retrieve or update data.
- The domain/model classes, in turn, interact with the database layer via DatabaseManager and related classes.
- Utility classes support various parts of these processes (conversion, alerting, report generation).

c. Architectural Patterns & Design Principles:
- MVC Pattern: Clearly seen in the separation of controllers, views (FXML + ViewerControllers), and data models.
- Layered Architecture: The system is divided into presentation, business, domain, and data access layers.
- Modular Design: Segregation of concerns is evident with dedicated packages for GUI, model, database, and utilities.

d. Key Technologies and Frameworks:
- Java 15 as the programming language.
- Maven for build automation and dependency management.
- JavaFX for the GUI (supported by FXML for view layouts).
- Potential use of SQL for persistence (as indicated by the SQL Model classes and database dump file).

##### Elements the Principal Software Engineer Should Include
- Clearly labeled components for each major layer (UI, Business Logic, Domain Model, Data Access, and Utilities).
– UI actions triggering controller methods.
– Controllers calling model methods.
– Model classes communicating with the database layer.
– Return flows from the database back to the UI through models and controllers.
– Presentation elements (e.g., rectangles for FXML views and controllers).
– Business/domain components.
– Data access objects and database communication.
– Utility functions and configuration.
- Annotations that note frameworks (JavaFX, Maven, SQL) and key design patterns (MVC, layered architecture).

## Diagram (Mermaid)

```mermaid
flowchart TD
    U["User Actions"]:::external

    subgraph "Presentation Layer"
        A["FXML Views"]:::ui
        B["UI Controllers"]:::ui
    end

    subgraph "Business Logic Layer"
        C["Business Controllers"]:::business
    end

    subgraph "Domain/Model Layer"
        D["SQL Models"]:::domain
        E["Model Interfaces"]:::domain
    end

    subgraph "Data Access Layer"
        F["Database Core"]:::data
        G["Database Annotations"]:::data
    end

    subgraph "Utilities & External Integration"
        H["Utility Classes"]:::utilities
        I["Import/Export Components"]:::utilities
    end

    subgraph "Configuration & Deployment"
        J["Maven Build Config"]:::config
        K["Resources & Config"]:::config
    end

    U -->|"initiates"| A
    A -->|"triggers"| B
    B -->|"delegatesTo"| C
    C -->|"calls"| D
    C -->|"uses"| E
    D -->|"queries"| F
    F -->|"respondsTo"| D
    D -->|"applies"| G

    %% Utilities support flow
    B -.->|"supportedBy"| H
    C -.->|"supportedBy"| H
    D -.->|"supportedBy"| H
    I -.->|"integratesWith"| D

    %% Configuration flow
    J -->|"configures"| F
    K -->|"loadsConfig"| F

    %% Feedback from Data Access to Business
    F -->|"feedback"| C

    %% Class Definitions for styling
    classDef ui fill:#ffe599,stroke:#333,stroke-width:2px;
    classDef business fill:#c9daf8,stroke:#333,stroke-width:2px;
    classDef domain fill:#f4cccc,stroke:#333,stroke-width:2px;
    classDef data fill:#d9ead3,stroke:#333,stroke-width:2px;
    classDef utilities fill:#ead1dc,stroke:#333,stroke-width:2px;
    classDef config fill:#c9c9c9,stroke:#333,stroke-width:2px;
    classDef external fill:#ffffff,stroke:#000,stroke-width:2px;

    %% Click Events
    click A "https://github.com/exora02/autochef/tree/main/src/main/resources/ulb/infof307/g02/gui/view"
    click B "https://github.com/exora02/autochef/tree/main/src/main/java/ulb/infof307/g02/gui/controller"
    click C "https://github.com/exora02/autochef/tree/main/src/main/java/ulb/infof307/g02/gui/controller"
    click D "https://github.com/exora02/autochef/tree/main/src/main/java/ulb/infof307/g02/model/sql_model"
    click E "https://github.com/exora02/autochef/tree/main/src/main/java/ulb/infof307/g02/model/model_interface"
    click F "https://github.com/exora02/autochef/tree/main/src/main/java/ulb/infof307/g02/database"
    click G "https://github.com/exora02/autochef/tree/main/src/main/java/ulb/infof307/g02/database/annotation"
    click H "https://github.com/exora02/autochef/tree/main/src/main/java/ulb/infof307/g02/util"
    click I "https://github.com/exora02/autochef/tree/main/src/main/java/ulb/infof307/g02/util/import_export"
    click J "https://github.com/exora02/autochef/blob/main/pom.xml"
    click K "https://github.com/exora02/autochef/tree/main/src/main/resources"
```
