# lesvinyesdam/asistenciaform architecture

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

- Interactive diagram: https://gitdiagram.com/lesvinyesdam/asistenciaform
- Repository: https://github.com/lesvinyesdam/asistenciaform

## Overview

##### Project Type & Purpose
- This is a Java application built primarily with JavaFX (as indicated by the several FXML files) for managing attendance (fichaje) using NFC technology.
- The project leverages the Model-View-Controller (MVC) pattern: FXML files represent the views, while Controllers in the package (under org.vinyes.asistencia.Controllers) handle user interactions; Entities represent data models.
- Additional modules include NFC reading/writing, database connectivity, and security (e.g., encryption), indicating an architecture with multiple layers of functionality.

##### Analyzing the File Structure
- Main Directory “Asistencia”: Contains the complete application including UI forms, controllers, database connectors, NFC driver code, and security utilities.
- Java Source Code (in /src/main/java/org/vinyes/asistencia):
- Controllers: These classes (e.g., LoginScreenController, FirstScreenController, etc.) manage user interactions and coordinate between the view and the underlying logic.
- Entities: POJOs such as “Login” and “Usuario” that represent data structures in the application.
- Database: Modules like DatabaseConnection and RegistroDAO indicate a dedicated data access layer. Also, SQL scripts and CSV files are present, suggesting there is an embedded or configured database.
- NFCDriver: Contains NFCReader and DatabaseWriter classes to handle communication with NFC hardware.
- Security: Contains the Encryption class to secure sensitive data.
- The MainApplication class is the entry point, initializing the application.
- Resource Files: The FXML files in the /resources directory define the UI layout for various screens such as login, registration, and management.
- Build & Dependency Files: Maven-related files (pom.xml, mvnw) indicate that the project is built using Maven.

a. Main Components:
- User Interface (UI): Represented by the FXML files (first-screen.fxml, login-screen.fxml, etc.) under /src/main/resources.
- Controllers: The various controllers handling UI events (e.g., LoginScreenController, GestionUsuarioController).
- Business Logic / Domain Layer: Entities (Login, Usuario) and potentially any service logic within the controllers.
- Database Layer: Database, including DatabaseConnection and DAO classes, interacting with SQL scripts (db.sql) and CSV/database files.
- NFC Module: NFCDriver components (NFCReader, DatabaseWriter) that handle NFC interactions.
- Security Module: Encryption class that supports data integrity and confidentiality.
- Integration/Startup: MainApplication serves as the application bootstrap.

b. Relationships & Interactions:
- The UI sends user actions to Controllers.
- Controllers interact with the Domain models (Entities) and invoke business logic.
- Data is persisted or retrieved via the Database layer (using DAO methods).
- The NFC module is integrated to read/write data (likely triggered by the UI or controllers) to handle attendance via NFC.
- Security functions are invoked during data handling for encryption or other secure interactions.

c. Architectural Patterns and Design Principles:
- MVC (Model-View-Controller) separates presentation (FXML files and views), control (Controllers), and data (Entities + Database access).
- Modular separation where NFC-specific functionality is isolated in its own package.
- Use of dependency injection or similar patterns might be inferred from the clear separation between the user interface, data access, and external NFC interaction.
- The use of a Database Access Object (DAO) pattern is evident from the RegistroDAO class.

d. Notable Technologies and Frameworks:
- Java and JavaFX for the frontend.
- Maven as the build and dependency management tool.
- Standard Java packages for security and database access.
- External NFC hardware integration through dedicated driver classes.

## Diagram (Mermaid)

```mermaid
flowchart TD
    M["Main Application"]:::integration
    U["UI (FXML Views)"]:::ui
    C["Controllers"]:::controller
    E["Entities"]:::domain
    D["Database"]:::database
    N["NFC Module"]:::nfc
    S["Encryption"]:::security

    M -->|"initializes"| U
    M -->|"initializes"| C
    M -->|"initializes"| D
    M -->|"initializes"| N
    M -->|"initializes"| S

    U -->|"userActions"| C
    C -->|"processData"| E
    C -->|"persistQuery"| D
    C -->|"encryptData"| S
    N -->|"sendNFCEvent"| C
    N -->|"writeRead"| D

    %% Click Events
    click U "https://github.com/lesvinyesdam/asistenciaform/tree/main/Asistencia/src/main/resources/org/vinyes/asistencia"
    click C "https://github.com/lesvinyesdam/asistenciaform/tree/main/Asistencia/src/main/java/org/vinyes/asistencia/Controllers"
    click E "https://github.com/lesvinyesdam/asistenciaform/tree/main/Asistencia/src/main/java/org/vinyes/asistencia/Entities"
    click D "https://github.com/lesvinyesdam/asistenciaform/tree/main/Asistencia/src/main/java/org/vinyes/asistencia/Database"
    click N "https://github.com/lesvinyesdam/asistenciaform/tree/main/Asistencia/src/main/java/org/vinyes/asistencia/NFCDriver"
    click S "https://github.com/lesvinyesdam/asistenciaform/tree/main/Asistencia/src/main/java/org/vinyes/asistencia/Security"
    click M "https://github.com/lesvinyesdam/asistenciaform/blob/main/Asistencia/src/main/java/org/vinyes/asistencia/MainApplication.java"

    %% Styles
    classDef ui fill:#ffccff,stroke:#333,stroke-width:2px;
    classDef controller fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef domain fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef database fill:#ffcce6,stroke:#333,stroke-width:2px;
    classDef nfc fill:#ffffcc,stroke:#333,stroke-width:2px;
    classDef security fill:#e6ffe6,stroke:#333,stroke-width:2px;
    classDef integration fill:#ffe6e6,stroke:#333,stroke-width:2px;
```
