Projects · Lalalab, 2021

Cart and pricing microservices

Bruno's first assignments at Lalalab, in summer 2021: moving pricing (August 2021) and then the cart (September 2021) out of the PHP monolith into MoleculerJS microservices.

Pricing, built with functional programming

The price calculation applies percentage discounts, fixed-amount discounts, coupons, priority prices, shipping costs… Bruno wrote it as a chain of pure functions ("apply a discount", "compute a subtotal"…).

The choice and its trade-off: a style less familiar to the rest of the team, but fully predictable behaviour — same input, same price — and very fine-grained unit tests, case by case. The service reached 100% test coverage within its first weeks.

The cart

The cart orchestrates pricing, coupons, perks and shipping, and persists everything in a single transaction. This is the service that later ran into database lock issues. → Deadlocks on the cart database

Projects · Lalalab, 2021

Microservices panier et pricing

Les premières missions de Bruno chez Lalalab, à l'été 2021 : sortir du monolithe PHP le pricing (août 2021) puis le panier (septembre 2021), en microservices MoleculerJS.

Le pricing, en programmation fonctionnelle

Le calcul de prix applique remises en pourcentage, remises en montant, coupons, prix prioritaires, frais de port… Bruno l'a écrit comme une suite de fonctions pures (« appliquer une remise », « calculer un sous-total »…).

Le choix et son compromis : un style moins habituel pour le reste de l'équipe, mais un comportement totalement prévisible — même entrée, même prix — et des tests unitaires très fins, cas par cas. Le service a atteint 100 % de couverture de tests dès ses premières semaines.

Le panier

Le panier orchestre le pricing, les coupons, les avantages et la livraison, et persiste le tout dans une transaction. C'est ce service qui a ensuite connu des problèmes de verrous en base. → Deadlocks sur la base du panier

Projects · Lalalab, 2021

Microservices für Warenkorb und Pricing

Brunos erste Aufgaben bei Lalalab im Sommer 2021: das Pricing (August 2021) und danach den Warenkorb (September 2021) aus dem PHP-Monolithen herauszulösen, als MoleculerJS-Microservices.

Pricing mit funktionaler Programmierung

Die Preisberechnung wendet prozentuale Rabatte, Betragsrabatte, Gutscheine, Vorrangpreise, Versandkosten… an. Bruno hat sie als Folge reiner Funktionen geschrieben („Rabatt anwenden“, „Zwischensumme berechnen“…).

Die Entscheidung und ihr Kompromiss: ein für den Rest des Teams ungewohnterer Stil, dafür aber ein vollständig vorhersehbares Verhalten — gleiche Eingabe, gleicher Preis — und sehr feingranulare Unit-Tests, Fall für Fall. Der Service erreichte bereits in den ersten Wochen 100 % Testabdeckung.

Der Warenkorb

Der Warenkorb orchestriert Pricing, Gutscheine, Vorteile und Lieferung und speichert alles in einer Transaktion. Genau dieser Service hatte später mit Datenbank-Locks zu kämpfen. → Deadlocks in der Warenkorb-Datenbank