# danielfv0510/laravel-microservice-products architecture

> Architecture diagram of the GitHub repository danielfv0510/laravel-microservice-products, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danielfv0510/laravel-microservice-products
- Repository: https://github.com/danielfv0510/laravel-microservice-products

## Overview

##### Project type and purpose
- This is a microservices-based system composed of three independent services—**Products** (Laravel/PHP), **Orders** (Node.js/Express), and **Inventory** (Node.js/Kafka)—all containerized via Docker Compose.
- Purpose:
- Products service exposes a REST API backed by a MySQL database for CRUD on products.
- Orders service exposes a REST API for order management and publishes order events to Kafka.
- Inventory service consumes order events from Kafka to adjust stock levels and can emit further events.
- Ancillary infrastructure: Nginx reverse-proxy, MySQL, and Apache Kafka broker, all defined in top-level `docker` and `docker-compose.yml`.

##### File structure
- Top-level:
- `.github/workflows`: CI pipelines for Node.js and PHP.
- `docker-compose.yml` + `docker/`: service definitions (MySQL, Nginx, PHP-FPM).
- `inventory/`, `orders/`, `products/`: each subfolder is its own microservice, complete with Dockerfiles, source, configs, tests, and package manifests.
- Pattern:
- Each service follows a clear separation: HTTP entrypoints (controllers/routes) → core/business logic → data layer (DB or event broker) → event routers/dispatchers (Kafka).
- Shared event-driven communication between Orders and Inventory via Kafka topics.
- Products service uses a monolithic MVC pattern (Laravel) with REST endpoints on top of MySQL.

##### Key insights from README
- Products microservice: Laravel 12, PHP-FPM, MySQL, Nginx reverse proxy, Docker Compose, GitHub Actions CI.
- Orders service: Node.js + Express, in-memory store (planned for MySQL), Kafka producer/consumer, Docker Compose, CI to come.
- Kafka topic “orders” carries events that Inventory consumes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    ExternalClient["External Client"]:::external

    subgraph "Docker Compose"
        direction TB

        Nginx["Nginx (API Gateway)"]:::infra
        MySQL["MySQL Database"]:::db
        Kafka["Kafka Broker"]:::infra

        subgraph "Products Service"
            direction TB
            ProdApp["Products Service (Laravel)"]:::prod
            ProdDB["Products MySQL"]:::db
        end

        subgraph "Orders Service"
            direction TB
            OrdersApp["Orders Service (Express)"]:::orders
        end

        subgraph "Inventory Service"
            direction TB
            InventoryApp["Inventory Service"]:::inventory
        end
    end

    subgraph "CI Pipelines"
        direction TB
        CI_PHP["CI Pipeline (PHP)"]:::ci
        CI_Node["CI Pipeline (Node.js)"]:::ci
    end

    ExternalClient -->|"HTTP GET/POST"| Nginx
    Nginx -->|"Route /api/products"| ProdApp
    Nginx -->|"Route /api/v1/orders"| OrdersApp
    ProdApp -->|"JDBC/MySQL"| ProdDB
    OrdersApp -->|"Publish orders"| Kafka
    InventoryApp -->|"Subscribe orders"| Kafka
    InventoryApp -->|"Publish stock_updated"| Kafka
    InventoryApp -->|"HTTP API call"| ProdApp

    click Nginx "https://github.com/danielfv0510/laravel-microservice-products/tree/master/docker/nginx/"
    click MySQL "https://github.com/danielfv0510/laravel-microservice-products/blob/master/docker/mysql/init.sql"
    click Kafka "https://github.com/danielfv0510/laravel-microservice-products/blob/master/docker-compose.yml"
    click ProdApp "https://github.com/danielfv0510/laravel-microservice-products/tree/master/products/src/"
    click OrdersApp "https://github.com/danielfv0510/laravel-microservice-products/tree/master/orders/src/"
    click InventoryApp "https://github.com/danielfv0510/laravel-microservice-products/tree/master/inventory/src/"
    click CI_PHP "https://github.com/danielfv0510/laravel-microservice-products/blob/master/.github/workflows/ci.yml"
    click CI_Node "https://github.com/danielfv0510/laravel-microservice-products/blob/master/.github/workflows/node.yml"

    classDef external fill:#f2f2f2,stroke:#666,stroke-width:1px;
    classDef infra fill:#cccccc,stroke:#666,stroke-width:1px;
    classDef db fill:#e0e0e0,stroke:#666,stroke-width:1px;
    classDef prod fill:#93c5fd,stroke:#1e40af,stroke-width:1px;
    classDef orders fill:#86efac,stroke:#15803d,stroke-width:1px;
    classDef inventory fill:#fdba74,stroke:#c2410c,stroke-width:1px;
    classDef ci fill:#e9d5ff,stroke:#6b21a8,stroke-width:1px;
```
