# danieibazgc/retofutbol architecture

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

- Interactive diagram: https://gitdiagram.com/danieibazgc/retofutbol
- Repository: https://github.com/danieibazgc/retofutbol

## Overview

##### Project Type and Purpose
- This is a Java EE web application (MVC) built with NetBeans, JSP/JSTL for the view, servlets for controllers, a DAO layer for persistence, and MySQL as the backing store.
- It manages inventory, sales, customers, user roles, and reporting for a football‐jersey store (“RetoFutbol”).

##### File Structure Analysis
- **Frontend (View):**
- `web/` (and `build/web/`): all JSP pages (`index.jsp`, `login.jsp`, `clientes.jsp`, `productos.jsp`, etc.), CSS under `web/css/`, images under `web/img/`, navigation fragments under `web/navegador/`.
- **Controller Layer:**
- `src/java/Controlador/`: servlet classes (`srvLogin.java`, `srvCliente.java`, `srvProductos.java`, etc.) that handle HTTP requests, coordinate business logic, and forward/redirect to JSPs.
- **Model & Persistence:**
- `src/java/Modelo/`: plain Java objects (`Cliente.java`, `Producto.java`, `Venta.java`, etc.).
- `src/java/DAO/`: Data Access Object classes (`ClienteDAO.java`, `VentaDAO.java`, etc.) plus `Conexion.java` for JDBC connection and `Parametros.java` for SQL parameters.
- **Configuration & Build:**
- `web/META-INF/context.xml`: resource definitions.
- `build.xml` and `nbproject/`: Ant build scripts and NetBeans project metadata.

##### Key Architectural Patterns
- **MVC:** Views (JSP) ←→ Controllers (Servlets) ←→ Models (Java beans) ←→ DAO (Persistence).
- **DAO Pattern:** Encapsulates all direct JDBC calls and SQL into DAO classes.
- **Ant‐based Deployment:** `build.xml` packages the WAR under `build/web/`.

##### Main Components
a. **Clients (Browsers):** Users interact via HTTP(S).
b. **Web Server / Servlet Container:** e.g., Tomcat running the WAR.
c. **View Layer (JSP + CSS + JSTL):**
- JSP pages under `/WEB‐INF/views` (in this project directly under `web/`).
d. **Controller Layer (Servlets):** one servlet per use‐case (`Login`, `Cliente`, `Producto`, `Venta`, etc.).
e. **Service/Business Logic (if any):** simple orchestration inside servlets and DAO.
f. **DAO Layer:** classes mapping to tables, handling CRUD via JDBC.
g. **MySQL Database:** tables for users, products, sales, clients, etc.
h. **External Libraries:**
- `mysql-connector-j` for JDBC driver
- `jstl-1.2.jar` for JSP tags

##### Interactions & Data Flow
1. Browser → HTTP Request → **Servlet** (e.g., `/srvLogin`)
2. Servlet invokes → **DAO** (e.g., `UsuarioDAO.validate(...)`)
3. DAO opens → **JDBC Connection** → executes SQL on **MySQL** → maps `ResultSet` to **Model** object
4. Servlet stores data in request/session → forwards to → **JSP View**
5. JSP renders HTML/CSS → Browser

- A **deployment node** representing the servlet container and database server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["Client Browser"]:::external

    %% Deployment Cluster
    subgraph "Web Container (Tomcat)" 
        direction TB
        subgraph "View Layer" 
            direction TB
            IDX["index.jsp"]:::view
            LOGIN["login.jsp"]:::view
            CLIENTES["clientes.jsp"]:::view
            PRODUCTOS["productos.jsp"]:::view
            VENTAS["ventas.jsp"]:::view
            CAJA["caja.jsp"]:::view
            REPORTES_VIEW["reportes.jsp"]:::view
            USUARIOS["usuarios.jsp"]:::view
            CSS["css/"]:::view
            IMG["img/"]:::view
            MENU_ADMIN["menuAdmin.jsp"]:::view
            MENU_EMPLEADO["menuEmpleado.jsp"]:::view
        end
        subgraph "Controller Layer"
            direction TB
            SRV_LOGIN["srvLogin Servlet"]:::controller
            SRV_CLIENTE["srvCliente Servlet"]:::controller
            SRV_PRODUCTOS["srvProductos Servlet"]:::controller
            SRV_USUARIO["srvUsuario Servlet"]:::controller
            SRV_VENTA["srvVenta Servlet"]:::controller
            SRV_CAJA["srvCaja Servlet"]:::controller
        end
    end

    %% Model & DAO
    subgraph "Model Layer" 
        direction TB
        MODELO_CLI["Cliente.java"]:::model
        MODELO_PROD["Producto.java"]:::model
        MODELO_USU["Usuario.java"]:::model
        MODELO_VENTA["Venta.java"]:::model
        MODELO_DET["DetalleVenta.java"]:::model
        MODELO_REP["Reportes.java"]:::model
    end

    subgraph "DAO Layer" 
        direction TB
        CONEX["Conexion.java"]:::persistence
        PARAM["Parametros.java"]:::persistence
        DAO_CLI["ClienteDAO.java"]:::persistence
        DAO_PROD["ProductosDAO.java"]:::persistence
        DAO_USU["UsuarioDAO.java"]:::persistence
        DAO_VENTA["VentaDAO.java"]:::persistence
    end

    %% Configuration
    subgraph "Configuration"
        direction TB
        CTX["context.xml"]:::config
        GEN_SERIE["GenerarSerie.java"]:::config
    end

    %% Database Server
    DB["MySQL Database"]:::database

    %% Build & Deployment
    subgraph "Build & Deployment"
        direction TB
        BUILD_XML["build.xml"]:::build
        NBPROJ["nbproject/"]:::build
        LIBS["WEB-INF/lib/"]:::build
        JSTL["jstl-1.2.jar"]:::build
        MYSQL_DRV["mysql-connector-j-8.3.0.jar"]:::build
    end

    %% Data Flows
    Client -->|HTTP Request| SRV_LOGIN
    Client -->|HTTP Request| SRV_CLIENTE
    Client -->|HTTP Request| SRV_PRODUCTOS
    Client -->|HTTP Request| SRV_USUARIO
    Client -->|HTTP Request| SRV_VENTA
    Client -->|HTTP Request| SRV_CAJA

    SRV_LOGIN -->|"calls"| DAO_USU
    SRV_CLIENTE -->|"calls"| DAO_CLI
    SRV_PRODUCTOS -->|"calls"| DAO_PROD
    SRV_USUARIO -->|"calls"| DAO_USU
    SRV_VENTA -->|"calls"| DAO_VENTA
    SRV_CAJA -->|"calls"| DAO_VENTA

    DAO_CLI -->|"JDBC"| DB
    DAO_PROD -->|"JDBC"| DB
    DAO_USU -->|"JDBC"| DB
    DAO_VENTA -->|"JDBC"| DB
    CONEX -->|"manages"| DB

    SRV_LOGIN -->|"forward"| LOGIN
    SRV_CLIENTE -->|"forward"| CLIENTES
    SRV_PRODUCTOS -->|"forward"| PRODUCTOS
    SRV_VENTA -->|"forward"| VENTAS
    SRV_CAJA -->|"forward"| CAJA
    SRV_USUARIO -->|"forward"| USUARIOS
    SRV_VENTA -->|"forward"| REPORTES_VIEW

    BUILD_XML -->|"packages"| WEBF[build/web/] 
    NBPROJ --> WEBF
    WEBF --> LIBS
    LIBS --> JSTL
    LIBS --> MYSQL_DRV

    %% Click Events - View
    click IDX "https://github.com/danieibazgc/retofutbol/blob/main/web/index.jsp"
    click LOGIN "https://github.com/danieibazgc/retofutbol/blob/main/web/login.jsp"
    click CLIENTES "https://github.com/danieibazgc/retofutbol/blob/main/web/clientes.jsp"
    click PRODUCTOS "https://github.com/danieibazgc/retofutbol/blob/main/web/productos.jsp"
    click VENTAS "https://github.com/danieibazgc/retofutbol/blob/main/web/ventas.jsp"
    click CAJA "https://github.com/danieibazgc/retofutbol/blob/main/web/caja.jsp"
    click REPORTES_VIEW "https://github.com/danieibazgc/retofutbol/blob/main/web/reportes.jsp"
    click USUARIOS "https://github.com/danieibazgc/retofutbol/blob/main/web/usuarios.jsp"
    click CSS "https://github.com/danieibazgc/retofutbol/tree/main/web/css/"
    click IMG "https://github.com/danieibazgc/retofutbol/tree/main/web/img/"
    click MENU_ADMIN "https://github.com/danieibazgc/retofutbol/blob/main/web/navegador/menuAdmin.jsp"
    click MENU_EMPLEADO "https://github.com/danieibazgc/retofutbol/blob/main/web/navegador/menuEmpleado.jsp"
    click WEBF "https://github.com/danieibazgc/retofutbol/tree/main/build/web/"

    %% Click Events - Controllers
    click SRV_LOGIN "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Controlador/srvLogin.java"
    click SRV_CLIENTE "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Controlador/srvCliente.java"
    click SRV_PRODUCTOS "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Controlador/srvProductos.java"
    click SRV_USUARIO "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Controlador/srvUsuario.java"
    click SRV_VENTA "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Controlador/srvVenta.java"
    click SRV_CAJA "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Controlador/srvCaja.java"

    %% Click Events - Models
    click MODELO_CLI "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Modelo/Cliente.java"
    click MODELO_PROD "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Modelo/Producto.java"
    click MODELO_USU "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Modelo/Usuario.java"
    click MODELO_VENTA "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Modelo/Venta.java"
    click MODELO_DET "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Modelo/DetalleVenta.java"
    click MODELO_REP "https://github.com/danieibazgc/retofutbol/blob/main/src/java/Modelo/Reportes.java"

    %% Click Events - DAO
    click CONEX "https://github.com/danieibazgc/retofutbol/blob/main/src/java/DAO/Conexion.java"
    click PARAM "https://github.com/danieibazgc/retofutbol/blob/main/src/java/DAO/Parametros.java"
    click DAO_CLI "https://github.com/danieibazgc/retofutbol/blob/main/src/java/DAO/ClienteDAO.java"
    click DAO_PROD "https://github.com/danieibazgc/retofutbol/blob/main/src/java/DAO/ProductosDAO.java"
    click DAO_USU "https://github.com/danieibazgc/retofutbol/blob/main/src/java/DAO/UsuarioDAO.java"
    click DAO_VENTA "https://github.com/danieibazgc/retofutbol/blob/main/src/java/DAO/VentaDAO.java"

    %% Click Events - Config
    click CTX "https://github.com/danieibazgc/retofutbol/blob/main/web/META-INF/context.xml"
    click GEN_SERIE "https://github.com/danieibazgc/retofutbol/blob/main/src/java/config/GenerarSerie.java"

    %% Click Events - Build
    click BUILD_XML "https://github.com/danieibazgc/retofutbol/blob/main/build.xml"
    click NBPROJ "https://github.com/danieibazgc/retofutbol/tree/main/nbproject/"
    click LIBS "https://github.com/danieibazgc/retofutbol/tree/main/build/web/WEB-INF/lib/"
    click JSTL "https://github.com/danieibazgc/retofutbol/blob/main/build/web/WEB-INF/lib/jstl-1.2.jar"
    click MYSQL_DRV "https://github.com/danieibazgc/retofutbol/blob/main/build/web/WEB-INF/lib/mysql-connector-j-8.3.0.jar"

    %% Styles
    classDef view fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef controller fill:#90EE90,stroke:#333,stroke-width:1px
    classDef persistence fill:#FFA500,stroke:#333,stroke-width:1px
    classDef model fill:#FFE4B5,stroke:#333,stroke-width:1px
    classDef database fill:#D2691E,stroke:#333,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef build fill:#E6E6FA,stroke:#333,stroke-width:1px
```
