How elianiubo/ventacar works
Project Type and Purpose
• This is a full-stack web application designed for the purchase and sale of vehicles. Its main goal is the management of vehicles (“gestió de vehicles”) and executing buy-sell operations.
• The project is built using Spring Boot for the backend with a clearly separated MVC/M-V-C-like architecture (Model, Controller, Service, Repository), and a frontend composed of static HTML, CSS (including Bootstrap), and JavaScript.
• The application interacts with a PostgreSQL database and is served through Tomcat as the web server.
File Structure
• Top-Level Files: The presence of pom.xml, mvnw, and mvnw.cmd indicates a Maven-based Java project.
• Directory Organization:
• The "src/main/java/com/concesionario/ventacar" directory breaks down into several key sub-packages: Controller, Model, Repository, and Service, reflecting the MVC layering.
• The "src/main/resources" folder contains an application.properties file (for configuration) along with static resources (HTML, CSS, JS, and images) that support the frontend.
• Testing is set up under "src/test", demonstrating unit/integration tests.
Key Components
a. Frontend:
• Static content (HTML, CSS, JS) found under "src/main/resources/static". This is likely served as the view layer.
b. Backend:
• Controller: Contains components handling incoming RESTful API calls (e.g., VehiculoController.java).
• Service: Implements business logic (e.g., VehiculoService.java).
• Repository: Handles database interactions (e.g., VehiculoRepository.java).
• Model: Defines the data models/entities such as Vehiculo.java.
• Application Bootstrap: VentacarApplication.java which sets up the Spring Boot application.
c. Database:
• A PostgreSQL database as outlined in the README, used by the Repository layer.
d. External Services & Server:
• RESTful API architecture that can be seen from the controllers.
• Tomcat 10.1 as the web server hosting the application.
Relationships and Interactions
• Frontend interacts with Backend through RESTful API calls.
• The Controller receives these calls, forwards them to the appropriate Service.
• The Service layer contains the business logic and communicates with the Repository to execute database operations.
• The Repository interfaces directly with the PostgreSQL database.
• The entire backend is run on a Spring Boot framework and deployed using Tomcat.
Architectural Patterns and Design Principles
• The system follows the layered (or N-tier/MVC) architecture, which supports separation of concerns.
• RESTful APIs serve as the communication conduit between the frontend and backend.
• Dependency Inversion and Service Abstraction: The Service layer decouples business logic from the presentation layer (controllers).