Examen-Computo-en-la-Nube: NovaCore: The Cloud Exam Project That Ships a Real Store

Inside AvanTI Shop, an all-or-nothing checkout is not application logic. It is one database transaction, and everything interesting about this codebase lives on either side of that boundary.

7 min read • View on GitHub • More from muxgame1990

A wide editorial illustration of a long warehouse conveyor carrying a single sealed pallet stacked with mismatched computer parts, approaching one tall gate that spans the full width of the conveyor. The image argues that a database transaction is an all-or-nothing gate: the entire pallet passes through or the entire pallet is turned back, with no partial state.
The transaction is a gate, not a sequence of steps. Either every line of the purchase passes through, or none of them do.
Key Takeaways

The Name Says Exam. The Code Says Store.

A repository named Examen de Cómputo en la Nube should contain a quiz. It contains a store.

Open the repo and you find a Spanish-language e-commerce application for computer components, branded AvanTI Shop, packaged under the Java namespace NovaCore. There is a customer storefront with a category catalog, product search, detail pages, a cart, and a purchase confirmation screen. There is an admin panel for creating, editing, searching, and deleting products, plus recording inventory entries and exits. Underneath sit a MySQL schema with five tables, a Spring Boot entry point, and a deployment story that runs across EC2, RDS, and S3. The name is the only small thing about the project.

The README states the business rule plainly: every purchase is saved as an order and decrements stock immediately, and if any item lacks stock the whole purchase is cancelled and nothing is saved. That rule is the spine of the application. It is also, as we will see, implemented in a surprising place.

LayerTechnology
LanguageJava 21
FrameworkSpring Boot 3.5.6
ViewsJSF (JoinFaces) plus PrimeFaces 14
PersistenceSpring Data JPA and Hibernate
CloudAWS SDK v2 S3 client
DatabaseMySQL 8, schema managed by hand-written SQL

The stack is conventional, with one deliberate exception. Pairing JSF with Spring Boot 3.5 is unusual in 2026, since most new Spring projects reach for Thymeleaf or a single-page frontend. The leftovers agree: application.properties still carries spring.thymeleaf.cache=false even though no Thymeleaf dependency exists. The view layer changed at some point, and the config never caught up.

The Checkout Is One Transaction Wide

CompraServicio.realizarCompra is a single @Transactional method. It opens a database transaction, loops over the cart lines, records an outbound inventory movement for each line (which throws if stock would go negative), attaches a priced order line, and saves the order. If any line throws, the entire method rolls back: every movement, every decrement, every line vanishes together.

That is the whole trick. There is no compensation logic, no retry queue, no saga orchestration, no distributed transaction manager. The database already has a mechanism for do all of this or none of it, and the code simply uses it. For a single-database order system, this is not a shortcut. It is the correct answer, and it is the most interesting decision in the repository.

The checkout as one transaction. Every write for every line lives inside the same boundary, and a single failure reverses all of them retroactively.

@Transactional
public Carrito realizarCompra(String usuario, Map<Integer, Integer> cantidades) {
    Carrito orden = new Carrito(usuario);
    for (Map.Entry<Integer, Integer> item : cantidades.entrySet()) {
        movimientoInventarioServicio.registrar(productoId, TipoMovimiento.SALIDA, cantidad);
        Producto producto = productoRepositorio.findById(productoId)
                .orElseThrow(() -> new IllegalArgumentException("El producto ya no existe."));
        orden.getProductos().add(new CarritoProducto(orden, cantidad, producto));
    }
    return carritoRepositorio.save(orden);
}

The schema rewards the same instinct. carrito_producto.precioUnitario stores the price at the moment of purchase, so a later price change never rewrites order history. The order table is even named carrito (cart), which is misleading, since its rows are completed orders rather than working carts. The naming wobbles, but the price snapshot is standard, correct practice.

The Switch That Moves Your Images to the Cloud

The second clever idea is quieter. A single property, app.imagenes.almacenamiento, selects where product images live. Set it to local and files sit on disk. Point it at S3 and they travel to a bucket. The rest of the application never learns which one is active.

app.imagenes.almacenamiento=${IMAGENES_ALMACENAMIENTO:local}
aws.region=${AWS_REGION:us-east-2}
aws.s3.bucket=${S3_BUCKET:}

Two details make it hold together. First, images are delivered through ImagenServlet, a raw @WebServlet that runs outside the JSF lifecycle, so swapping the backend does not disturb the view framework. Second, the database stores a storage key rather than a full URL. Changing the storage target never requires a data migration, because no row ever recorded where the bytes were.

A close-up editorial illustration of two hands gripping a single heavy brass switch lever set into a plain wall panel, with one pipe running from the switch. On the left the pipe terminates at a small desktop filing cabinet; on the right it terminates at a distant rack of labeled storage shelves, and the pipe is continuous only to one side. The image makes the storage abstraction physical: one switch, two destinations, and the application never touches the pipe.
One property, two destinations. The application flips the switch and never touches the pipe.

Where the Seams Show

The transaction's guarantee has edges, and the same philosophy that makes the checkout correct is missing at three of them.

The first seam is concurrency. The stock check reads producto.getStock() into memory, computes a new value, and saves it. There is no pessimistic lock, no @Version optimistic lock on the product, and no conditional UPDATE ... WHERE stock >= ?. Two concurrent checkouts for the last unit can both read the same stock, both pass the check, and both write, with one overwriting the other. The purchase path is unprotected under load. It is worth noting the codebase contains an atomic repository method, updateStock, which the purchase path simply does not call.

The second seam is the foreign keys, and they disagree with each other. fk_cp_producto carries only ON UPDATE CASCADE, with no ON DELETE clause, so a product that has ever been sold cannot be deleted. But fk_movimiento_producto is ON DELETE CASCADE, so deleting a product silently erases its inventory history. One rule protects the sales record; the other destroys the stock ledger. The design never decides which history deserves to survive.

The third seam is secrets. The usuario.password column stores what the user typed, in plaintext, and the schema seeds an admin account with the password admin123. The committed application.properties also ships working-looking database defaults on a nonstandard port. These are exactly the shortcuts a course deadline encourages and a production review rejects.

What a Production Store Would Do Differently

None of this is a gotcha against a student project. It is a pattern, and the pattern is legible when you line the choices up against what a production team would reach for.

DimensionThis repoProduction answer
Checkout integrityOne @Transactional method, rollback on any failureSame. This is the correct call.
Concurrent stockRead, compute, write. No lock.Pessimistic row lock or UPDATE ... WHERE stock >= ?
SecretsCommitted password default, seeded admin123Environment variables and a secret manager
SchemaHand-written SQL, ddl-auto=noneVersioned migrations (Flyway, Liquibase)

Three rows where the repo falls short, one where it gets the hardest part right. That ratio is the point. The checkout, the piece that decides whether money and inventory stay consistent, is solved. The pieces around it, which a course never stressed, are not.

The Exam Was the Point

A small academic project got the hardest part of an order system right, and it did so by knowing which layer should own the problem. The lesson is not that student code is bad. It is that one well-placed transaction is worth more than a pile of application logic, and that the places where the code stops trusting the database are exactly the places it starts to break. That is a better exam answer than the name suggests.