# pedrobaonza/proyecto-hibernate architecture

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

- Interactive diagram: https://gitdiagram.com/pedrobaonza/proyecto-hibernate
- Repository: https://github.com/pedrobaonza/proyecto-hibernate

## Overview

##### Project type and purpose
- From the file tree and README, this is a Java-based console application to manage “empleados” (employees), “departamentos” (departments), “clientes” and “proyectos” using Hibernate ORM with XML mappings.
- It provides an interactive menu (MenusPrograma) to let a user perform CRUD operations on those entities, calculate/report data, and persist/retrieve them from a relational database.

##### File structure
- Top-level directories:
- bin – compiled .class files, Hibernate XML mappings (modelo/*.hbm.xml), hibernate.cfg.xml, reveng.xml
- librerias – external JARs (Hibernate core, annotations, persistence API, etc.)
- src – application source code and resources
– src/launcherAPP – entry point (MainApp), Hibernate connection (ConexionHibernate), program controller (ControladorPrograma)
– src/funciones – UI menus (MenusPrograma), input handling (PeticionDatos), business logic (ProcesadoHibernateEmpleado, ProcesadoHibernateDepartamentos, Validaciones)
– src/modelo – domain model (Java POJOs + .hbm.xml mappings for Clientes, Departamentos, Empleados, Proyectos)
– src/hibernate.cfg.xml, hibernate.reveng.xml – Hibernate configuration and reverse-engineering settings
- Patterns:
- Layered architecture (Presentation → Business Logic → Persistence)
- DAO-style services encapsulated in ProcesadoHibernate* classes
- ORM mapping with Hibernate XML (model/*.hbm.xml)
- No web or network layers – it’s a local console application connecting directly to a database via JDBC/Hibernate.

##### README for additional insights
- Describes XML and binary file handling, but the actual code tree shows Hibernate + DB usage. Likely the README was repurposed; the core is ORM-based persistence.
- Interactive menu, exception handling, computing of metrics (e.g., “medias de notas” in README maps to computing averages or summaries here).

##### Essential details to capture
- The separation of layers: UI, Controller, Service, Persistence, DB
- The Hibernate Session lifecycle: SessionFactory initialization → Session
- Mapping files (.hbm.xml) linking Java POJOs to DB tables
- Libraries providing ORM functionality
- Exception handling flow (services catching and propagating errors back to the UI)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Console UI Layer"
        direction TB
        MenusPrograma["MenusPrograma"]:::ui
        PeticionDatos["PeticionDatos"]:::ui
    end

    %% Controller Layer
    subgraph "Controller Layer"
        direction TB
        MainApp["MainApp"]:::controller
        ControladorPrograma["ControladorPrograma"]:::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        ProcesadoHibernateEmpleado["ProcesadoHibernateEmpleado Service"]:::service
        ProcesadoHibernateDepartamentos["ProcesadoHibernateDepartamentos Service"]:::service
        Validaciones["Validaciones"]:::service
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        ConexionHibernate["ConexionHibernate (SessionFactory)"]:::persistence
        hibernate_cfg["hibernate.cfg.xml"]:::persistence
        hibernate_rev["hibernate.reveng.xml"]:::persistence
        subgraph "ORM Mappings"
            direction TB
            ClienteMapping["Clientes.hbm.xml"]:::persistence
            DepartamentoMapping["Departamentos.hbm.xml"]:::persistence
            EmpleadoMapping["Empleados.hbm.xml"]:::persistence
            ProyectoMapping["Proyectos.hbm.xml"]:::persistence
        end
    end

    %% Domain Model
    subgraph "Domain Model"
        direction TB
        Clientes["Clientes.java"]:::model
        Departamentos["Departamentos.java"]:::model
        Empleados["Empleados.java"]:::model
        Proyectos["Proyectos.java"]:::model
    end

    %% External Dependencies
    subgraph "External Libraries"
        direction TB
        Librerias["librerias/*.jar"]:::external
    end

    %% Database
    Database[(Database)]:::db

    %% Flow
    MenusPrograma -->|"user input"| ControladorPrograma
    PeticionDatos -->|"validated data"| ControladorPrograma
    ControladorPrograma -->|"calls service"| ProcesadoHibernateEmpleado
    ControladorPrograma --> ProcesadoHibernateDepartamentos
    ProcesadoHibernateEmpleado -->|"getSession()"| ConexionHibernate
    ProcesadoHibernateDepartamentos --> ConexionHibernate
    ConexionHibernate -->|"uses mappings"| ClienteMapping
    ConexionHibernate --> DepartamentoMapping
    ConexionHibernate --> EmpleadoMapping
    ConexionHibernate --> ProyectoMapping
    ProcesadoHibernateEmpleado -->|"manipulates"| Empleados
    ProcesadoHibernateEmpleado -->|"manipulates"| Departamentos
    ProcesadoHibernateDepartamentos --> Departamentos
    ProcesadoHibernateDepartamentos --> Empleados
    ConexionHibernate --> Database
    Librerias --> ConexionHibernate

    %% Click Events
    click MenusPrograma "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/funciones/MenusPrograma.java"
    click PeticionDatos "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/funciones/PeticionDatos.java"
    click MainApp "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/launcherAPP/MainApp.java"
    click ControladorPrograma "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/launcherAPP/ControladorPrograma.java"
    click ProcesadoHibernateEmpleado "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/funciones/ProcesadoHibernateEmpleado.java"
    click ProcesadoHibernateDepartamentos "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/funciones/ProcesadoHibernateDepartamentos.java"
    click Validaciones "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/funciones/Validaciones.java"
    click ConexionHibernate "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/launcherAPP/ConexionHibernate.java"
    click hibernate_cfg "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/hibernate.cfg.xml"
    click hibernate_rev "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/hibernate.reveng.xml"
    click ClienteMapping "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/modelo/Clientes.hbm.xml"
    click DepartamentoMapping "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/modelo/Departamentos.hbm.xml"
    click EmpleadoMapping "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/modelo/Empleados.hbm.xml"
    click ProyectoMapping "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/modelo/Proyectos.hbm.xml"
    click Clientes "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/modelo/Clientes.java"
    click Departamentos "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/modelo/Departamentos.java"
    click Empleados "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/modelo/Empleados.java"
    click Proyectos "https://github.com/pedrobaonza/proyecto-hibernate/blob/main/src/modelo/Proyectos.java"
    click Librerias "https://github.com/pedrobaonza/proyecto-hibernate/tree/main/librerias/"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef controller fill:#d1ecf1,stroke:#333,stroke-width:1px
    classDef service fill:#d4edda,stroke:#333,stroke-width:1px
    classDef persistence fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef model fill:#f8d7da,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
    classDef db fill:#cccccc,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
