# gabrieldpzz/wompi-gateway architecture

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

- Interactive diagram: https://gitdiagram.com/gabrieldpzz/wompi-gateway
- Repository: https://github.com/gabrieldpzz/wompi-gateway

## Overview

##### Project type and purpose
- This is a full-stack e-commerce gateway built with Spring Boot (Java) on the backend, Thymeleaf/HTML/CSS/JavaScript on the frontend, and MySQL as the database.
- It provides product catalog browsing, cart management, user authentication, and payment processing via the external Wompi payment API.

##### File structure
- src/main/java/com/ejemplo/wompigateway: Spring Boot application entry point (WompiGatewayApplication.java), controllers, models, repository, and service layers.
- src/main/resources/templates: Thymeleaf (or JSP) templates for UI pages (index, productos, carrito, form, signup, signout, response).
- src/main/resources/static: Frontend assets (config.js, page0.js, page1.js, styles.css).
- Configuration: application.properties for DB and other settings.
- pom.xml, mvnw scripts: Maven build and dependency management.

##### README for additional insights
- Describes supported API routes (authentication, cart operations, purchase transactions, Wompi payment links).
- Highlights external dependency on MySQL and Wompi’s REST API.

a. Main components
- Client (Browser) – renders Thymeleaf templates, static JS/CSS
- Spring Boot Backend
– Web layer: CompraController, ProductoController
– Service layer: ProductoService (business logic, cart operations, payment orchestration)
– Repository layer: ProductoRepository (CRUD on productos table via JPA)
- MySQL Database – productos table, user sessions stored in HTTP session or DB
- External Service – Wompi Payment API (transaction endpoints)

b. Relationships and interactions
- Browser → HTTP GET/POST → Controllers
- Controllers ↔ Services (cart manipulation, validation)
- Services ↔ Repository (persisting/fetching Producto entities)
- Services → Wompi API (REST calls for transactions, payment link generation)
- Controllers → Thymeleaf templates/static resources → Browser

c. Architectural patterns & design principles
- Layered architecture (Controller → Service → Repository)
- MVC at the web tier (templates as views, controllers as presenters)
- Dependency Injection (Spring-managed beans)
- External service integration via REST client in service layer

d. Technologies & frameworks
- Java 17+, Spring Boot (Web, Data JPA)
- Thymeleaf (view rendering)
- MySQL (relational DB)
- JavaScript/CSS (frontend interactivity & styling)
- Maven (build), Git (VCS)
- Wompi REST API

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client Side"
        Browser["Browser"]:::frontend
        subgraph "Static Assets"
            config_js["config.js"]:::frontend
            page0_js["page0.js"]:::frontend
            page1_js["page1.js"]:::frontend
            styles_css["styles.css"]:::frontend
        end
        subgraph "Templates"
            index_html["index.html"]:::frontend
            productos_html["productos.html"]:::frontend
            carrito_html["carrito.html"]:::frontend
            form_html["form.html"]:::frontend
            signup_html["signup.html"]:::frontend
            signout_html["signout.html"]:::frontend
            response_html["response.html"]:::frontend
        end
    end

    %% Server Side
    subgraph "Server Side"
        Application["WompiGatewayApplication"]:::web
        subgraph "Web Layer"
            ProductoController["ProductoController\n(GET/POST endpoints)"]:::web
            CompraController["CompraController\n(purchase endpoints)"]:::web
        end
        subgraph "Service Layer"
            ProductoService["ProductoService"]:::business
        end
        subgraph "Repository Layer"
            ProductoRepository["ProductoRepository"]:::data
        end
        subgraph "Domain Model"
            ProductoEntity["Producto Entity"]:::data
        end
    end

    %% Database
    MySQL["MySQL Database"]:::db

    %% External Service
    WompiAPI["Wompi Payment API\n/transaccion\n/enlacePago"]:::external

    %% Relationships
    Browser -->|"HTTP GET/POST"| ProductoController
    Browser -->|"HTTP GET/POST"| CompraController
    ProductoController -->|"calls"| ProductoService
    CompraController -->|"calls"| ProductoService
    ProductoService -->|"CRUD via JPA"| ProductoRepository
    ProductoRepository -->|"JDBC"| MySQL
    ProductoService -->|"REST API calls"| WompiAPI
    ProductoController -->|"renders"| index_html
    ProductoController -->|"renders"| productos_html
    ProductoController -->|"renders"| carrito_html
    CompraController -->|"renders"| form_html
    CompraController -->|"renders"| response_html
    Browser --> config_js
    Browser --> page0_js
    Browser --> page1_js
    Browser --> styles_css

    %% Click Events
    click Application "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/java/com/ejemplo/wompigateway/WompiGatewayApplication.java"
    click ProductoController "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/java/com/ejemplo/wompigateway/controller/ProductoController.java"
    click CompraController "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/java/com/ejemplo/wompigateway/controller/CompraController.java"
    click ProductoService "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/java/com/ejemplo/wompigateway/service/ProductoService.java"
    click ProductoRepository "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/java/com/ejemplo/wompigateway/repository/ProductoRepository.java"
    click ProductoEntity "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/java/com/ejemplo/wompigateway/model/Producto.java"
    click index_html "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/templates/index.html"
    click productos_html "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/templates/productos.html"
    click carrito_html "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/templates/carrito.html"
    click form_html "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/templates/form.html"
    click signup_html "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/templates/signup.html"
    click signout_html "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/templates/signout.html"
    click response_html "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/templates/response.html"
    click config_js "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/static/config.js"
    click page0_js "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/static/page0.js"
    click page1_js "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/static/page1.js"
    click styles_css "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/static/styles.css"
    click application_properties "https://github.com/gabrieldpzz/wompi-gateway/blob/main/src/main/resources/application.properties"
    click pom.xml "https://github.com/gabrieldpzz/wompi-gateway/blob/main/pom.xml"
    click mvnw "https://github.com/gabrieldpzz/wompi-gateway/tree/main/mvnw"
    click mvnw.cmd "https://github.com/gabrieldpzz/wompi-gateway/blob/main/mvnw.cmd"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000
    classDef web fill:#90EE90,stroke:#000
    classDef business fill:#FFA500,stroke:#000
    classDef data fill:#D2B48C,stroke:#000
    classDef db fill:#D2B48C,stroke:#000
    classDef external fill:#DDA0DD,stroke:#000
```
