# elianiubo/ventacar architecture

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

- Interactive diagram: https://gitdiagram.com/elianiubo/ventacar
- Repository: https://github.com/elianiubo/ventacar

## Overview

##### 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).

## Diagram (Mermaid)

```mermaid
flowchart TD
    f["Frontend (Static HTML/CSS/JS)"]:::frontend

    subgraph "Backend Layers"
        subgraph "Controller Layer"
            b["VehiculoController (Backend)"]:::backend
        end
        subgraph "Service Layer"
            s["VehiculoService (Backend)"]:::backend
        end
        subgraph "Repository Layer"
            r["VehiculoRepository (Backend)"]:::backend
        end
        subgraph "Model Layer"
            m["Vehiculo Model"]:::backend
        end
        boot["VentacarApplication (Bootstrap)"]:::backend
    end

    db["PostgreSQL Database"]:::database
    tomcat["Tomcat Server (10.1)"]:::server

    f -->|"HTTP Request"| b
    b -->|"forwards"| s
    s -->|"invokes"| r
    r -->|"accesses"| db
    r -->|"mapsTo"| m
    boot -->|"initializes"| b
    boot -->|"initializes"| s
    boot -->|"initializes"| r
    boot -->|"deployedOn"| tomcat

    click f "https://github.com/elianiubo/ventacar/tree/main/src/main/resources/static"
    click b "https://github.com/elianiubo/ventacar/blob/main/src/main/java/com/concesionario/ventacar/Controller/VehiculoController.java"
    click s "https://github.com/elianiubo/ventacar/blob/main/src/main/java/com/concesionario/ventacar/Service/VehiculoService.java"
    click r "https://github.com/elianiubo/ventacar/blob/main/src/main/java/com/concesionario/ventacar/Repository/VehiculoRepository.java"
    click m "https://github.com/elianiubo/ventacar/blob/main/src/main/java/com/concesionario/ventacar/Model/Vehiculo.java"
    click boot "https://github.com/elianiubo/ventacar/blob/main/src/main/java/com/concesionario/ventacar/VentacarApplication.java"

    classDef frontend fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef backend fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef server fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
