# sebastiansierra15/invehin architecture

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

- Interactive diagram: https://gitdiagram.com/sebastiansierra15/invehin
- Repository: https://github.com/sebastiansierra15/invehin

## Overview

##### Project type and purpose
- This is a full-stack Java web application (INVEHIN) for clothing store sales and inventory management.
- It uses JSP as the view layer, Servlets as controllers, Java classes for business logic and data access, and a MySQL database.

##### File structure
- Top-level “src/java” breaks into packages:
- Entidades – domain/model classes & DB connection
- Interfaces – DAO/service interface definitions
- Logica – business/service implementations
- Utils – reporting helpers (Excel/PDF generators)
- servlets – HTTP controllers
- “web” (and its build/web counterpart) holds static assets (images, components) and JSP views under “Views”.
- “WEB-INF/lib” contains third-party JARs (JDBC driver, Apache POI, iTextPDF, Gson, Commons libs, Log4j).
- “sql/DB_INVEHIN.sql” defines the schema.
- Build artifacts (build.xml, nbproject) reflect an Ant+NetBeans setup, producing a WAR for Tomcat.

##### README for additional insights
- Confirms Java 21, JSP/Servlet, Tomcat 10+, MySQL 8, JDBC, Apache POI & iTextPDF.
- Key modules: user management, sales, inventory, orders, reports.

a. Main components
- Browser (User Interface)
- Web Server & Servlet Container (Apache Tomcat)
- View Layer (JSP pages + static assets)
- Controller Layer (Servlet classes)
- Service/Business Layer (Logica package)
- Data Access Layer (Entidades + Interfaces using JDBC)
- MySQL Database
- Reporting Subsystem (Utils + Apache POI/iText)
- External Libraries (Log4j, Gson, Commons, MySQL Connector)
b. Relationships & interactions
1. User → HTTP Request → JSP (view) or directly to Servlet
2. Servlet reads request, invokes service in Logica
3. Service uses DAO interfaces (Interfaces) and Entities (Entidades) to perform JDBC operations
4. JDBC communicates with MySQL DB
5. Service returns data to Servlet → JSP renders response
6. For report endpoints, service delegates to Utils which uses Apache POI/iText to generate Excel/PDF
c. Architectural patterns & design principles
- MVC separation: JSP = View, Servlets = Controller, Logica = Model/Service
- DAO pattern: Interfaces define contracts, Entities represent tables, Logica implements business rules
- Layered architecture: clear boundaries between presentation, business, and data layers
- Reusable utility components for reporting
d. Key technologies/frameworks
- Java Servlets & JSP (Controller + View)
- MySQL via JDBC (Data persistence)
- Apache Tomcat (Servlet container)
- Apache POI & iTextPDF (report generation)
- Log4j, Gson, Apache Commons (extras)

##### Elements
- Labels: “Browser”, “Tomcat Container”, “JSP Views”, “Servlet Controllers”, “Service Layer”, “DAO Layer”, “MySQL DB”, “Reporting Utils”.
→ HTTP flow (Browser → JSP/Servlet → Browser)
→ Method calls (Servlet → Service → DAO → DB)
→ File generation (Service → Utils → PDF/Excel)
- Rounded rectangles for UI components (JSP, static assets) in blue
- Rectangles for controllers (Servlets) in green
- Rectangles for services (Logica) in orange

## Diagram (Mermaid)

```mermaid
flowchart TB
    Browser["Browser"]:::external
    IndexJSP["index.jsp"]:::frontend
    JSPViews["JSP Views"]:::frontend
    Components["Components"]:::frontend
    Images["Images"]:::frontend

    subgraph "Frontend Layer"
        Browser -->|HTTP GET/POST| IndexJSP
        Browser -->|HTTP GET/POST| JSPViews
        Browser -->|HTTP GET/POST| Components
        Browser -->|HTTP GET/POST| Images
    end

    subgraph "Tomcat Container"
        subgraph "Controller Layer"
            Servlets["Servlet Controllers"]:::controller
        end
        subgraph "Service Layer"
            Services["Service/Business Layer"]:::service
        end
        subgraph "DAO Layer"
            DAOInterfaces["DAO Interfaces"]:::dao
            Entities["Entity Models & DB Connection"]:::dao
        end
        subgraph "Reporting Subsystem"
            ExcelGen["GeneradorExcelBase"]:::docs
            PDFGen["GeneradorPDFBase"]:::docs
            PrendasExcel["GeneradorReportesPrendasExcel"]:::docs
            PrendasPDF["GeneradorReportesPrendasPDF"]:::docs
            VentasExcel["GeneradorReportesVentasExcel"]:::docs
            VentasPDF["GeneradorReportesVentasPDF"]:::docs
        end
    end

    Servlets -->|calls| Services
    Services -->|uses| DAOInterfaces
    Services -->|uses| Entities
    DAOInterfaces -->|JDBC calls| Entities
    Entities -->|JDBC| DB["MySQL Database"]:::db

    Services -->|generate report| ExcelGen
    Services -->|generate report| PDFGen
    ExcelGen -->|specialized| PrendasExcel
    PDFGen -->|specialized| PrendasPDF
    ExcelGen -->|specialized| VentasExcel
    PDFGen -->|specialized| VentasPDF

    subgraph "Configuration & Build"
        WebXML["web.xml"]:::external
        SQL["DB_INVEHIN.sql"]:::external
        Libs["Libraries (.jar)"]:::external
        BuildXML["build.xml"]:::external
        NB["nbproject/"]:::external
    end

    WebXML -->|configures| Servlets
    SQL -->|schema| DB
    Libs -.->|classpath| Servlets
    Libs -.->|classpath| Services
    BuildXML -->|build WAR| Servlets
    NB -->|project files| BuildXML

    click JSPViews "https://github.com/sebastiansierra15/invehin/tree/main/web/Views/"
    click IndexJSP "https://github.com/sebastiansierra15/invehin/blob/main/web/index.jsp"
    click Components "https://github.com/sebastiansierra15/invehin/tree/main/web/components/"
    click Images "https://github.com/sebastiansierra15/invehin/tree/main/web/images/"
    click Servlets "https://github.com/sebastiansierra15/invehin/tree/main/src/java/servlets/"
    click Services "https://github.com/sebastiansierra15/invehin/tree/main/src/java/Logica/"
    click DAOInterfaces "https://github.com/sebastiansierra15/invehin/tree/main/src/java/Interfaces/"
    click Entities "https://github.com/sebastiansierra15/invehin/tree/main/src/java/Entidades/"
    click ExcelGen "https://github.com/sebastiansierra15/invehin/blob/main/src/java/Utils/GeneradorExcelBase.java"
    click PDFGen "https://github.com/sebastiansierra15/invehin/blob/main/src/java/Utils/GeneradorPDFBase.java"
    click PrendasExcel "https://github.com/sebastiansierra15/invehin/blob/main/src/java/Utils/Prendas/GeneradorReportesPrendasExcel.java"
    click PrendasPDF "https://github.com/sebastiansierra15/invehin/blob/main/src/java/Utils/Prendas/GeneradorReportesPrendasPDF.java"
    click VentasExcel "https://github.com/sebastiansierra15/invehin/blob/main/src/java/Utils/Ventas/GeneradorReportesVentasExcel.java"
    click VentasPDF "https://github.com/sebastiansierra15/invehin/blob/main/src/java/Utils/Ventas/GeneradorReportesVentasPDF.java"
    click SQL "https://github.com/sebastiansierra15/invehin/blob/main/sql/DB_INVEHIN.sql"
    click WebXML "https://github.com/sebastiansierra15/invehin/blob/main/web/WEB-INF/web.xml"
    click Libs "https://github.com/sebastiansierra15/invehin/tree/main/web/WEB-INF/lib/"
    click BuildXML "https://github.com/sebastiansierra15/invehin/blob/main/build.xml"
    click NB "https://github.com/sebastiansierra15/invehin/tree/main/nbproject/"

    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef controller fill:#d4edda,stroke:#155724,color:#155724
    classDef service fill:#fff3cd,stroke:#856404,color:#856404
    classDef dao fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef db fill:#d6d8db,stroke:#1b1e21,color:#1b1e21
    classDef docs fill:#e2e3e5,stroke:#6c757d,color:#6c757d
    classDef external fill:#f0f0f0,stroke:#888888,color:#333333
```
