How emanuelleramirez28-rgb/proyecto-final-grupo works
1. Type of application
- AutoElite is a Java Swing desktop application for managing a used-car dealership.
- It is not web-based; the user interface runs locally on the desktop and talks directly to a local H2 database.
2. High-level architecture
- The repository follows a classic MVC structure:
- Model: domain entities under src/model
- View: Swing screens/dialogs under src/view
- Controller: interaction and orchestration logic under src/controller
- Data persistence is handled separately through DAO classes under src/dao.
3. Application entry and startup flow
- src/Main.java is the entry point.
- The app starts by loading the login screen, initializes the UI flow, and connects to the database.
- The database is prepared using resources/init.sql, which seeds or creates the schema on startup.
4. User interface boundary
- The UI is split into discrete Swing views:
- LoginView
- MainView
- InventarioView
- DashboardView
- SucursalView
- GaleriaView
- AgregarVehiculoDialog
- MainView acts as the shell/container after authentication, while the other views represent functional modules inside the app.
5. Controller responsibilities
- Controllers mediate between views and persistence:
- LoginController handles authentication and session entry.
- MainController coordinates navigation in the main shell.
- InventarioController manages vehicle listing, filters, and CRUD actions.
- DashboardController prepares dashboard metrics.
- SucursalController manages branch operations.
- GaleriaController manages vehicle images and gallery actions.
- Controllers are the main coordination layer between UI events and DAOs.
6. Domain model
- The core business entities live in src/model:
- Vehiculo is the abstract base class.
- Auto, Motocicleta, and Camion extend it and provide polymorphic behavior.
- Sucursal represents dealership branches.
- Usuario represents authenticated users and roles.
- Imagen represents stored vehicle media.
- The model layer also encodes business logic like vehicle type behavior and price validation.
7. Persistence layer
- DAO classes encapsulate all database access:
- ConexionDB centralizes the H2 connection.
- UsuarioDAO, VehiculoDAO, SucursalDAO, and ImagenDAO isolate SQL and CRUD operations.
- The application uses H2 Database Engine via lib/h2-2.4.240.jar.
- The database is configured as in-memory (jdbc:h2:mem:autoelite), so state is temporary unless exported elsewhere.
8. Data flow through the system
- A typical flow is: user action in Swing view → controller → DAO → H2 database → controller updates view.
- This pattern is repeated across login, inventory, branches, dashboard metrics, and gallery management.
- The UI does not access the database directly; all persistence goes through the DAO boundary.
9. Key functional subsystems
- Authentication and session management: login against the user table with role-based access.
- Inventory management: vehicle CRUD, search, filtering by branch/type/price, and logical deletion.
- Branch management: CRUD for dealership branches.
- Gallery management: vehicle image browsing, upload, primary image selection, and deletion.
- Dashboard analytics: inventory KPIs and vehicle-type distribution summaries.
10. Role-based access control
- The app distinguishes at least two roles: ADMIN and VENDEDOR.
- ADMIN users can perform full CRUD operations.
- VENDEDOR users are restricted mainly to viewing inventory and dashboard-style access, depending on module rules.
11. File and media handling
- Images are copied into resources/images/ and referenced from the database by path.
- Gallery behavior is therefore split between file system storage and database metadata.
- Inventory export uses CSV generation through standard file writers, making reporting an external file output path.
12. Error and validation boundary
- The project defines custom exceptions for expected failure modes:
- AuthFailedException
- InvalidPriceException
- DatabaseException
- These indicate clear separation between authentication, domain validation, and persistence failures.
13. Build and runtime packaging
- compile.sh / compile.bat build the app into bin/.
- run.sh / run.bat launch the compiled desktop application.
- The included MANIFEST.MF suggests the project can also be packaged as a runnable Java application.
14. Architectural diagram focus
- A correct diagram should show:
- Desktop user
- Swing views
- Controllers
- DAO/persistence layer
- H2 in-memory database
- File system for images and CSV export
- init.sql as startup initialization
- The main boundary is between the presentation/controller layer and the DAO/database + file-system side effects.
Main entry points: MainController.java MainCtrl · ImagenDAO.java ImagenDAO · VehiculoDAO.java VehiculoDAO · ConexionDB.java ConexionDB
Components 29
Presentation
Swing desktop UI and interaction flow
- Desktop user · Person using the Swing application
- Main · Application startup and bootstrap
src/Main.java - Login · Authentication screen
src/view/LoginView.java - Main shell · Authenticated container and navigation shell
src/view/MainView.java - Inventario · Vehicle listing and actions
src/view/InventarioView.java - Dashboard · Metrics and summary screen
src/view/DashboardView.java - Sucursal · Branch management screen
src/view/SucursalView.java - Galeria · Vehicle image gallery screen
src/view/GaleriaView.java - Agregar vehículo · Vehicle creation/edit dialog
src/view/AgregarVehiculoDialog.java - LoginCtrl · Handles authentication and session entry
src/controller/LoginController.java - MainCtrl · Coordinates shell navigation
src/controller/MainController.java - InventarioCtrl · Manages inventory CRUD, filters, and export
src/controller/InventarioController.java - DashboardCtrl · Builds dashboard metrics
src/controller/DashboardController.java - SucursalCtrl · Manages branch operations
src/controller/SucursalController.java - GaleriaCtrl · Manages vehicle images and gallery actions
src/controller/GaleriaController.java
Domain
Business entities and rules
- Vehiculo · Base vehicle entity and shared rules
src/model/Vehiculo.java - Vehicle types · Auto, Motocicleta, and Camion specializations
- Sucursal · Dealership branch entity
src/model/Sucursal.java - Usuario · Authenticated user and role entity
src/model/Usuario.java - Imagen · Vehicle media metadata
src/model/Imagen.java
Persistence
DAO layer and database access
- ConexionDB · Central H2 connection manager
src/dao/ConexionDB.java - UsuarioDAO · User authentication queries
src/dao/UsuarioDAO.java - VehiculoDAO · Vehicle CRUD and listing queries
src/dao/VehiculoDAO.java - SucursalDAO · Branch CRUD queries
src/dao/SucursalDAO.java - ImagenDAO · Image metadata and gallery queries
src/dao/ImagenDAO.java
External
Database, file system, and startup resources
- H2 DB · Temporary local database state
data/autoelite.mv.db - init.sql · Schema creation and seed data
resources/init.sql - Image files · Stored vehicle images under resources/images
resources/images - CSV export · Inventory reporting output path
Connections 37
- Desktop user → Login: uses · User interacts with the login screen
- Desktop user → Main shell: uses · User works in the authenticated shell
- Main → Login: starts · Application bootstraps the login UI
- Main → init.sql: initializes · Startup schema and seed script are applied
- Login → LoginCtrl: events · Login actions are handled by controller
- LoginCtrl → UsuarioDAO: auth · Authenticates against user records
- UsuarioDAO → ConexionDB: uses · DAO obtains the shared connection
- ConexionDB → H2 DB: connects · Central access to the H2 database
- Main shell → MainCtrl: nav · Shell navigation is coordinated by controller
- MainCtrl → Inventario: opens · Shows inventory module
- MainCtrl → Dashboard: opens · Shows dashboard module
- MainCtrl → Sucursal: opens · Shows branch module
- MainCtrl → Galeria: opens · Shows gallery module
- Inventario → InventarioCtrl: events · Inventory UI actions go through controller
- Dashboard → DashboardCtrl: events · Dashboard requests are handled by controller
- Sucursal → SucursalCtrl: events · Branch UI actions go through controller
- Galeria → GaleriaCtrl: events · Gallery UI actions go through controller
- Agregar vehículo → InventarioCtrl: edit · Vehicle add/edit dialog is managed by inventory flow
- InventarioCtrl → VehiculoDAO: crud · Inventory controller reads and mutates vehicles
- InventarioCtrl → CSV export: exports · Inventory data can be written to CSV
- DashboardCtrl → VehiculoDAO: reads · Dashboard derives metrics from vehicle data
- SucursalCtrl → SucursalDAO: crud · Branch controller manages branches
- GaleriaCtrl → ImagenDAO: crud · Gallery controller manages image metadata
- VehiculoDAO → ConexionDB: uses · Vehicle persistence uses shared connection
- SucursalDAO → ConexionDB: uses · Branch persistence uses shared connection
- ImagenDAO → ConexionDB: uses · Image persistence uses shared connection
- VehiculoDAO → Vehiculo: maps · DAO persists the vehicle hierarchy
- Vehiculo → Vehicle types: extends · Auto, Motocicleta, and Camion specialize the base entity
- Vehiculo → Sucursal: relates · Vehicles are associated with branches
- Vehiculo → Imagen: relates · Vehicles are associated with images
- UsuarioDAO → Usuario: maps · DAO loads authenticated users
- SucursalDAO → Sucursal: maps · DAO loads branch entities
- ImagenDAO → Imagen: maps · DAO loads image metadata
- ImagenDAO → Image files: stores · Image files live on disk and are referenced by path
- VehiculoDAO → H2 DB: reads/writes · Vehicle data is persisted in H2
- SucursalDAO → H2 DB: reads/writes · Branch data is persisted in H2
- ImagenDAO → H2 DB: reads/writes · Image metadata is persisted in H2