How adrils16/mercadawfinal works
Project Type and Purpose
• This is a final-year web application project – “Trabajo final de Desarrollo de Aplicaciones Web”.
• The README emphasizes scripts for DB setup and data loading, as well as instructions for executing several utility scripts (backup, label printing, payroll, etc.).
• The project uses Java as the primary language (the “src/main/java/…” package structure) and leverages JavaFX (the .fxml files under resources) for view components.
• The application interacts with a MariaDB database (see the SQL folder and docker-compose file) and reads/writes data using CSV and JSON formats, indicating full-stack behavior with a clear separation of view, controller, and model (MVC) responsibilities.
Analyzing the File Structure
• Top-level folders include:
• documentation (with comprehensive HTML and Markdown documentation along with javadocs)
• src (which contains the core Java source code, divided in packages by functionality such as controller, model, DAO, entity, utilities, reader, writer, and view)
• sql (for database setup)
• ficherosDarAlta (for initial data files in CSV/JSON)
• Scripts (various .sh files for backup, printing labels, payroll, etc.)
• The presence of docker-compose.yml indicates containerized deployment; the application expects the MariaDB instance to be available when the container is running.
• The project also includes tests (src/test) that mirror the main functionality, emphasizing software robustness.
Key Components and their Relationships
a. Presentation Layer:
• JavaFX Views: FXML files and their corresponding controllers (e.g., DarAltaEmpeadoViewController, PrincipalViewController, etc.) located in src/main/resources and src/main/java/.../view.
• These manage the UI interactions and pass requests to the business logic.
b. Business Logic / Controller Layer:
• Controllers (e.g., MercadawController, various other view controllers) that coordinate user actions.
• Exception handling (custom exceptions like FicheroException, FormatoException, etc.)
c. Data Access / Model Layer:
• Model Entities: Employee, Client, Product (found in the model/entity subfolders).
• DAO layer: Concrete implementations (e.g., MercaDawMariaDBDAOImp and MercaDawMockDAOImp) that manage database operations, selecting the right DAO via a DAO factory.
• The model also defines interfaces (Gestionable, Imprimible) to ensure consistency across entity operations.
d. Utility and Integration Components:
• Reader and Writer utilities (e.g., LectorCSV, LectorJSON, ExportarCSV, PDFUtil) that enable data import/export functions.
• Scripts and Docker: External scripts and docker-compose are used to manage execution and database initialization.
e. Database and Infrastructure:
• A MariaDB database is configured with initialization scripts (located in the sql folder).
• Docker and the accompanying docker-compose.yml file underline an infrastructure component.
Architectural Patterns and Principles
• MVC/MVP is used: A clear separation between the view (JavaFX UI defined in FXML and accompanying controllers), the controller (business logic controllers and coordinators), and the model/DAO (entities and data access components).
• Factory pattern for DAO creation (e.g., MercaDawDAOFactory) to support different implementations (MariaDB vs. mock).
• Utility classes encapsulate cross-cutting concerns (file reading, CSV export, PDF generation, etc.).
• Presentation (UI / JavaFX Views)
• Business Logic (Controllers: MercadawController and various view controllers)
• Data Access (Model, DAO, Factory, Entities)
• Infrastructure/Support (Scripts, Docker container handling, Database)
• Inside each layer, list the key packages or components (refer to the package names in src/main/java).
• Showing external integrations and how the system is set up for testing (as indicated by the src/test structure).