# jhongo201/tienda_laravel architecture

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

- Interactive diagram: https://gitdiagram.com/jhongo201/tienda_laravel
- Repository: https://github.com/jhongo201/tienda_laravel

## Overview

1. **Overall shape**
   - This is a Laravel 11 e-commerce monolith built around a **server-rendered UI** with **Livewire 3 + Volt** for interactivity.
   - The app is organized as a **domain-oriented backend** under `app/Domains/`, while HTTP controllers, Livewire components, views, jobs, and listeners orchestrate user flows around those domains.

2. **Presentation layer**
   - The main entry points are **Blade pages** in `resources/views/` plus **Livewire components** in `app/Livewire/`.
   - Public shopping interactions are handled by components like `ProductCatalog`, `CartDrawer`, and `CheckoutForm`, with Blade partials providing the layout and page structure.
   - This is not a separate SPA; Livewire keeps most stateful UI behavior on the Laravel side.

3. **Public commerce flow**
   - Browsing starts at home/shop/product routes and flows into the cart and checkout pages.
   - The cart and checkout screens are the main conversion boundary: product selection becomes cart state, cart state becomes an order draft, and the order draft becomes a payment request.

4. **Domain decomposition**
   - Core business logic is split into bounded domains:
     - **Cart**: `Cart`, `CartItem`, `CartService`
     - **Product**: `Product`, `Category`, `ProductVariant`, `ProductService`, `StockService`
     - **Order**: `Order`, `OrderItem`, `Address`, `OrderStatus`, `OrderService`
     - **Payment**: `Payment`, `WebhookLog`, `WompiService`, `ProcessWompiWebhook`
     - **Coupon**: `Coupon`, `CouponValidator`
     - **Shipping**: `ShippingZone`
   - These domains are the main architecture boundaries and are where persistence and business rules converge.

5. **Checkout and order lifecycle**
   - The checkout flow likely pulls from **cart**, validates **coupon** and **shipping**, creates an **order** with items/address, and then creates a **payment** record.
   - `OrderStatus` and the `OrderPaid` event indicate a state machine-like lifecycle where payment confirmation advances the order from pending to paid and downstream actions are triggered.

6. **Payment integration with Wompi**
   - Wompi is the external payment boundary.
   - `WompiService` encapsulates the provider-specific interaction, while `WompiController` and the webhook route handle the redirect/return and asynchronous provider callback.
   - `ProcessWompiWebhook` runs on the queue, which means payment confirmation is processed asynchronously rather than inline with the HTTP request.
   - `WebhookLog` suggests webhook payloads are persisted for audit/replay/debugging.

7. **Asynchronous and event-driven work**
   - The app uses the **database queue** for background processing.
   - Two explicit jobs show important async responsibilities:
     - `ExpirePendingOrders` for order cleanup/timeouts
     - `SendAbandonedCartEmails` for re-engagement
   - Domain events and listeners connect the workflow:
     - `OrderPaid` event
     - `SendOrderConfirmation`
     - `MergeGuestCart`
   - This creates a clear split between immediate user actions and deferred side effects.

8. **Authentication, roles, and admin boundary**
   - Auth is provided by Laravel Breeze, while authorization is driven by **Spatie Laravel Permission**.
   - The admin area is separated in `app/Http/Controllers/Admin/` and admin Livewire components under `app/Livewire/Admin/`.
   - Admin functions cover product, category, order, shipping, coupon, and user management, so the diagram should show a distinct privileged back-office path from the public store.

9. **Persistence and data model**
   - Migrations reveal the main tables: users, categories, products, product variants, shipping zones, coupons, addresses, carts, cart items, orders, order items, payments, webhook logs, and coupon usages.
   - The app is designed for a relational database, with PostgreSQL recommended and SQLite supported for lightweight development.
   - Session, cache, and queue are all configured to use the database, which means application state is intentionally kept inside the same persistence boundary.

10. **Media, ops, and observability**
   - The presence of Spatie Media Library and Backup in config/migrations implies support for managed media assets and backups, though they are not the primary commerce flow.
   - Laravel Telescope is included for debugging/inspection.
   - Vite and Tailwind handle the frontend asset pipeline; they affect deployment/runtime because the app needs both the PHP server and the Vite build/dev process.

11. **Testing and quality**
   - The repo includes feature tests for auth, cart, order, payment, and profile behavior, which map closely to the main user journeys.
   - Pest is the test runner, so the test suite is centered on end-to-end business scenarios rather than isolated units.

12. **Key architecture view to draw**
   - A useful diagram would show:
     - **Public users** interacting with **Livewire/Blade UI**
     - UI calling **controllers/components**
     - Controllers/components invoking **domain services/models**
     - Domain services persisting into **relational DB tables**
     - Checkout handing off to **Wompi**
     - Wompi callbacks entering through **webhooks**
     - Webhooks processed by **queued jobs**, emitting **events/listeners**, and updating orders/payments
     - Admin users entering through a separate **role-protected back office**

Main entry points: [`app/Livewire`](https://github.com/jhongo201/tienda_laravel/tree/main/app/Livewire) (Livewire UI), [`database/migrations`](https://github.com/jhongo201/tienda_laravel/tree/main/database/migrations) (Persistence), [`app/Domains/Payment`](https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Payment) (Payments), [`app/Domains/Order`](https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Order) (Orders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_public["Public store"]
  node_node_routes["Routes<br/>[web.php]"]
  node_node_blade_storefront["Storefront<br/>blade pages"]
  node_node_livewire_public["Livewire UI<br/>interactive ui"]
  node_node_views_mail["Mail & views<br/>presentation assets"]
end

subgraph group_group_domains["Domain core"]
  node_node_cart_domain[("Cart<br/>domain")]
  node_node_product_domain[("Catalog<br/>domain")]
  node_node_order_domain[("Orders<br/>domain")]
  node_node_payment_domain[("Payments<br/>domain")]
  node_node_coupon_domain[("Coupons<br/>domain")]
  node_node_shipping_domain[("Shipping<br/>domain")]
end

subgraph group_group_admin["Back office"]
  node_node_admin_routes["Admin HTTP<br/>admin controllers"]
  node_node_admin_livewire["Admin Livewire<br/>admin ui"]
end

subgraph group_group_platform["Platform"]
  node_node_queue_jobs["Queue jobs<br/>async workers"]
  node_node_events_listeners(("Events"))
  node_node_webhooks["Wompi entry<br/>payment boundary"]
  node_node_models_migrations[("Persistence<br/>relational db")]
  node_node_config["App config<br/>runtime config"]
  node_node_tests["Feature tests<br/>test suite"]
end

node_node_routes -->|"renders"| node_node_blade_storefront
node_node_routes -->|"mounts"| node_node_livewire_public
node_node_livewire_public -->|"uses"| node_node_cart_domain
node_node_livewire_public -->|"browses"| node_node_product_domain
node_node_livewire_public -->|"creates"| node_node_order_domain
node_node_livewire_public -->|"validates"| node_node_coupon_domain
node_node_livewire_public -->|"prices"| node_node_shipping_domain
node_node_cart_domain -->|"persists"| node_node_models_migrations
node_node_product_domain -->|"persists"| node_node_models_migrations
node_node_order_domain -->|"persists"| node_node_models_migrations
node_node_payment_domain -->|"persists"| node_node_models_migrations
node_node_payment_domain -->|"receives"| node_node_webhooks
node_node_webhooks -->|"queues"| node_node_queue_jobs
node_node_queue_jobs -->|"processes"| node_node_payment_domain
node_node_payment_domain -->|"confirms"| node_node_order_domain
node_node_events_listeners -->|"reacts"| node_node_order_domain
node_node_admin_routes -->|"orchestrates"| node_node_admin_livewire
node_node_admin_routes -->|"manages"| node_node_models_migrations
node_node_admin_livewire -->|"edits"| node_node_models_migrations
node_node_config -->|"configures"| node_node_queue_jobs
node_node_config -->|"wires"| node_node_webhooks
node_node_views_mail -->|"renders"| node_node_events_listeners
node_node_tests -->|"covers"| node_node_livewire_public
node_node_tests -->|"covers"| node_node_payment_domain

click node_node_routes "https://github.com/jhongo201/tienda_laravel/blob/main/routes/web.php"
click node_node_blade_storefront "https://github.com/jhongo201/tienda_laravel/tree/main/resources/views"
click node_node_livewire_public "https://github.com/jhongo201/tienda_laravel/tree/main/app/Livewire"
click node_node_cart_domain "https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Cart"
click node_node_product_domain "https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Product"
click node_node_order_domain "https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Order"
click node_node_payment_domain "https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Payment"
click node_node_coupon_domain "https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Coupon"
click node_node_shipping_domain "https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Shipping"
click node_node_admin_routes "https://github.com/jhongo201/tienda_laravel/tree/main/app/Http/Controllers/Admin"
click node_node_admin_livewire "https://github.com/jhongo201/tienda_laravel/tree/main/app/Livewire/Admin"
click node_node_queue_jobs "https://github.com/jhongo201/tienda_laravel/tree/main/app/Jobs"
click node_node_events_listeners "https://github.com/jhongo201/tienda_laravel/tree/main/app/Listeners"
click node_node_webhooks "https://github.com/jhongo201/tienda_laravel/blob/main/app/Http/Controllers/WompiController.php"
click node_node_models_migrations "https://github.com/jhongo201/tienda_laravel/tree/main/database/migrations"
click node_node_config "https://github.com/jhongo201/tienda_laravel/tree/main/config"
click node_node_views_mail "https://github.com/jhongo201/tienda_laravel/tree/main/resources/views/emails"
click node_node_tests "https://github.com/jhongo201/tienda_laravel/tree/main/tests/Feature"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_routes,node_node_blade_storefront,node_node_livewire_public,node_node_views_mail toneBlue
class node_node_cart_domain,node_node_product_domain,node_node_order_domain,node_node_payment_domain,node_node_coupon_domain,node_node_shipping_domain toneAmber
class node_node_admin_routes,node_node_admin_livewire toneMint
class node_node_queue_jobs,node_node_events_listeners,node_node_webhooks,node_node_models_migrations,node_node_config,node_node_tests toneRose
```

## Components

### Public store

Customer-facing pages, Livewire components, and checkout entry points.

- [Routes](https://github.com/jhongo201/tienda_laravel/blob/main/routes/web.php): http routes · Web and auth route entry points for the application. · `routes/web.php`
- [Storefront](https://github.com/jhongo201/tienda_laravel/tree/main/resources/views): blade pages · Server-rendered public pages for home, shop, cart, checkout, and orders. · `resources/views`
- [Livewire UI](https://github.com/jhongo201/tienda_laravel/tree/main/app/Livewire): interactive ui · Public Livewire components for product browsing, cart, and checkout. · `app/Livewire`
- [Mail & views](https://github.com/jhongo201/tienda_laravel/tree/main/resources/views/emails): presentation assets · Email templates and shared view components used by order and cart flows. · `resources/views/emails`

### Domain core

Business rules and persistence boundaries for commerce flows.

- [Cart](https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Cart): domain · Cart aggregate and service for session/cart state and line items. · `app/Domains/Cart`
- [Catalog](https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Product): domain · Products, categories, variants, stock, and catalog services. · `app/Domains/Product`
- [Orders](https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Order): domain · Orders, order items, addresses, status, and order service. · `app/Domains/Order`
- [Payments](https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Payment): domain · Payment records, webhook logs, Wompi integration, and webhook job. · `app/Domains/Payment`
- [Coupons](https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Coupon): domain · Coupon model and validation rules for checkout discounts. · `app/Domains/Coupon`
- [Shipping](https://github.com/jhongo201/tienda_laravel/tree/main/app/Domains/Shipping): domain · Shipping zone model used during checkout and fulfillment. · `app/Domains/Shipping`

### Back office

Privileged admin controllers and Livewire screens.

- [Admin HTTP](https://github.com/jhongo201/tienda_laravel/tree/main/app/Http/Controllers/Admin): admin controllers · Back-office controllers for dashboard, products, categories, orders, shipping, and users. · `app/Http/Controllers/Admin`
- [Admin Livewire](https://github.com/jhongo201/tienda_laravel/tree/main/app/Livewire/Admin): admin ui · Admin Livewire forms and tables for managing catalog and orders. · `app/Livewire/Admin`

### Platform

Framework configuration, async processing, data layer, and integrations.

- [Queue jobs](https://github.com/jhongo201/tienda_laravel/tree/main/app/Jobs): async workers · Background jobs for expiring pending orders and abandoned cart emails. · `app/Jobs`
- [Events](https://github.com/jhongo201/tienda_laravel/tree/main/app/Listeners): workflow events · Order-paid event and listeners that trigger side effects like confirmations and guest-cart merging. · `app/Listeners`
- [Wompi entry](https://github.com/jhongo201/tienda_laravel/blob/main/app/Http/Controllers/WompiController.php): payment boundary · Wompi controller and webhook controller that receive provider callbacks and return flow. · `app/Http/Controllers/WompiController.php`
- [Persistence](https://github.com/jhongo201/tienda_laravel/tree/main/database/migrations): relational db · Eloquent models and migrations for users, catalog, carts, orders, payments, and webhooks. · `database/migrations`
- [App config](https://github.com/jhongo201/tienda_laravel/tree/main/config): runtime config · Database, queue, session, auth, permission, media, telescope, and service configuration. · `config`
- [Feature tests](https://github.com/jhongo201/tienda_laravel/tree/main/tests/Feature): test suite · End-to-end tests covering auth, cart, order, payment, and profile journeys. · `tests/Feature`

## Connections

- Routes → Storefront: renders · Routes deliver the server-rendered storefront pages.
- Routes → Livewire UI: mounts · Public routes mount Livewire components for interactive pages.
- Livewire UI → Cart: uses · Cart drawer and checkout UI read and mutate cart state.
- Livewire UI → Catalog: browses · Product catalog UI queries catalog data and stock.
- Livewire UI → Orders: creates · Checkout UI converts cart state into orders.
- Livewire UI → Coupons: validates · Checkout applies coupon rules during purchase flow.
- Livewire UI → Shipping: prices · Checkout uses shipping zones to shape fulfillment cost.
- Cart → Persistence: persists · Cart state is stored in relational tables.
- Catalog → Persistence: persists · Catalog entities and stock are stored in the database.
- Orders → Persistence: persists · Orders, items, addresses, and status live in relational storage.
- Payments → Persistence: persists · Payments and webhook logs are recorded for reconciliation.
- Payments → Wompi entry: receives · Webhook and return flows enter through the payment boundary.
- Wompi entry → Queue jobs: queues · Webhook processing is delegated to the database queue.
- Queue jobs → Payments: processes · Webhook jobs update payment state asynchronously.
- Payments → Orders: confirms · Successful payment advances order lifecycle.
- Events → Orders: reacts · Order-paid events trigger order confirmation and guest-cart merge side effects.
- Admin HTTP → Admin Livewire: orchestrates · Back-office controllers and Livewire screens cooperate for admin workflows.
- Admin HTTP → Persistence: manages · Admin operations act on the same persisted commerce data.
- Admin Livewire → Persistence: edits · Admin forms and tables update catalog and order records.
- App config → Queue jobs: configures · Queue, session, and database drivers support async work.
- App config → Wompi entry: wires · Services configuration connects the payment provider boundary.
- Mail & views → Events: renders · Listeners trigger order confirmation and related emails.
- Feature tests → Livewire UI: covers · Feature tests exercise the public commerce journeys.
- Feature tests → Payments: covers · Feature tests cover payment and webhook behavior.
