Nx · Laravel · Apache Kafka

Build scalable microservices with NestLaravel.

NestLaravel brings together Nx, Laravel and Apache Kafka — organised with a NestJS-style modular architecture — into a structured development platform for building modular, scalable and event-driven backend systems.

terminal
$ npx nestlaravel create my-project

Ready to build

Nx workspace layer and framework layer feed Laravel microservices (users, orders, payments) which communicate through Kafka NxWorkspace layer NestJS-styleFramework layer Laravel microservices Users Orders Payments Apache Kafka Event-driven system

Built on proven technologies

NestLaravel does not replace these technologies. It gives you a structured, tested way to combine them.

Nx

Monorepo and workspace orchestration: project graph, cached and affected builds and tests.

NestJS-style architecture

Module structure and dependency-injected contracts (Domain / Application / Infrastructure / Presentation) behind a single gateway. NestJS itself is not a runtime dependency.

Laravel

The backend microservices and gateway: APIs, business logic, queues and the Laravel ecosystem.

Apache Kafka

Event-driven communication between services with an outbox, retries and dead-letter topics.

Nx+NestJS-style+Laravel+Kafka=NestLaravel

What is NestLaravel?

NestLaravel is a hybrid microservice development framework. It combines Nx workspace management and a NestJS-style modular architecture with Laravel-based backend microservices and Kafka-based event communication.

You organise several backend services inside one consistent workspace while each service keeps Laravel's mature ecosystem. A single API gateway is the only public interface; services are internal and trust only signed gateway calls.

Read the architecture →

Developer
   │
   ▼
NestLaravel CLI
   │
   ▼
Nx workspace
   ├── apps/api              gateway (public)
   ├── apps/users-service
   ├── apps/orders-service
   ├── apps/payments-service
   └── other Laravel services
             │
             ▼
           Kafka

Why NestLaravel?

Modular microservices

Independent Laravel services in a structured workspace, each with its own database and secrets.

Nx workspace

Applications and packages managed from one workspace with cached, affected-only tasks.

Event driven

Connect services with Kafka events using one versioned envelope.

Laravel backend

Use Laravel for business logic and APIs; keep the packages you already know.

Developer CLI

Create projects and services, generate Kafka topics and events, run, test, build and upgrade.

Standardised architecture

Every generated service follows the same conventions, so teams can move between services.

Built to grow

Start with one gateway and add services as the system grows; deploy and scale them independently.

Production practices included

Docker images, health probes, tests, CI templates, security controls and a documented upgrade path.

Start building in minutes

  1. Create a project
    npx nestlaravel create my-project
  2. Enter the workspace
    cd my-project
  3. Start development
    npx nestlaravel dev

What you will see

✓ Workspace files written to my-project/
✓ .env files created with fresh random secrets
✓ Dependencies installed (Composer + npm)
✓ Workspace validated

my-project is ready.

The dev command starts Kafka, PostgreSQL and Redis with Docker when it is available and serves every app through Nx. Output above is what create prints; see the full installation guide.

Requirements

Versions come from the framework's supported runtime matrix (packages/cli/src/versions.js) and are checked by npx nestlaravel doctor.

ToolVersionNotes
Node.js≥ 20.11.0Tested on 20, 22, 24
npm≥ 10.0.0Ships with Node.js
PHP≥ 8.3.0Tested on 8.3, 8.4; extensions: mbstring, openssl, pdo, tokenizer, xml, ctype, json, fileinfo, bcmath
Composer≥ 2.6.0
Laravel / Nx^13.30 / ^23.2Installed for you
DatabaseSQLite, PostgreSQL >=15 (dev image 16) or MySQLSQLite needs no setup
Apache Kafka>=3.6 (KRaft; dev image apache/kafka 4.0)Bundled dev broker via Docker; php-rdkafka to reach a broker from PHP outside Docker
Redis>=7Required for queues/cache in production; optional locally

Create a microservice

Generate a standardised Laravel microservice inside the workspace. It is registered with the gateway, Nx and Docker in one step.

npx nestlaravel generate service users
  • Own .env, APP_KEY and database credentials
  • Gateway route /api/v1/users, protected by signed requests
  • Nx targets: serve, test, lint, migrate, build

Microservices guide →

apps/
└── users-service/
    ├── app/
    │   ├── Http/Middleware/VerifyGatewaySignature.php
    │   └── Modules/Users/{Domain,Application,Infrastructure,Presentation}
    ├── bootstrap/
    ├── config/        (kafka.php, internal.php, …)
    ├── database/
    ├── routes/
    ├── tests/
    ├── .env.example
    ├── composer.json
    └── project.json   (Nx targets)

Event-driven microservices

Services never read each other's databases. They publish events; other services react.

Users service
     │  users.user.created
     ▼
  Kafka topic
     │
     ├──────────────┐
     ▼              ▼
Orders service   Notifications service
  • Producers write events to a transactional outbox; a publisher ships them after broker confirmation.
  • Consumers & groups run in a consumer group per service; offsets are committed only after success.
  • Topics & events use one envelope: event_id, event_type, version, source, correlation_id, payload.
  • Retries & dead letters: exponential backoff, then <topic>.dlq; poison messages skip retries.
  • Versioning: consumers dead-letter events newer than the schema they support.
  • Correlation IDs flow from the gateway request into events and logs.

Learn Kafka Architecture →

See it in code

Examples are taken from the framework's generators and documentation.

# service + topic + event (with a consumer handler)
npx nestlaravel generate service orders
npx nestlaravel generate kafka-topic order-events --service orders --create
npx nestlaravel generate kafka-event order.created --service orders --consumer

Architecture

Laravel is used for the backend microservices. Nx and the modular architecture organise them; they do not compete with Laravel.

Nx workspace
│
├── apps/api                  gateway: auth, throttling, routing (Laravel)
├── apps/<name>-service      Laravel microservices
│      ├── Users
│      ├── Orders
│      └── Payments …
├── packages/laravel-kafka    shared Kafka kit
├── packages/laravel-tenancy  optional multi-tenancy
└── infrastructure/           Dockerfile, scripts, Postgres init
                               │
                             Kafka
NxTask graph, caching, affected builds/tests.
Modular architectureDomain / Application / Infrastructure / Presentation modules; controllers call actions only.
LaravelGateway and every microservice.
KafkaAsynchronous service-to-service integration.
CLIScaffold, generate, develop, upgrade.

Full architecture guide →

Documentation portal

Searchable documentation generated from the repository's own guides. Press / or Ctrl+K anywhere to search.

Open documentation

CLI

Only commands that exist in the shipped CLI are listed. Full reference.

CommandPurpose
npx nestlaravel create my-projectNew workspace with gateway, Kafka kit, secrets and validation
npx nestlaravel generate service usersNew Laravel microservice wired into gateway, Nx and Docker
npx nestlaravel generate kafka-topic|kafka-eventRegister a topic / create a domain event (and consumer)
npx nestlaravel devStart infrastructure and serve all apps
npx nestlaravel test / lintRun every app's tests / style checks via Nx
npx nestlaravel buildBuild production Docker images
npx nestlaravel updateSafe, backed-up upgrade (--dry-run first)
npx nestlaravel add tenancyInstall the optional multi-tenancy package
npx nestlaravel doctorCheck Node, PHP, Composer, Docker

Examples

Worked examples that exist in the documentation today.

Multiple microservices

Generate services, register them on the gateway and call them.

Open documentation

Kafka events

Topics, events, consumers, retries and dead letters.

Open documentation

Authentication

Sanctum tokens and role-based access on the gateway.

Open documentation

Docker deployment

Compose stack and per-service images.

Open documentation

Production deployment

Docker, Linux/VPS, optional Kubernetes and CI/CD.

Open documentation

Multi-tenancy

Tenant-scoped data, jobs, cache and events.

Open documentation

From development to production

DevelopTestBuildContaineriseDeployMonitor

Docker

One production image per Laravel app, with ext-rdkafka, run as web, worker, outbox publisher or consumer.

Linux / VPS

Supervisor programs and nginx; firewall services to the gateway host.

CI/CD

GitHub Actions templates for tests, audits and image builds.

Kubernetes (optional)

Not required. Guidance for Deployments, probes and network policies is in the deployment guide.

Deployment guide →

Security by design

Controls are documented and covered by tests. No system is perfectly secure — the guide lists known limitations too.

Authentication & authorization

Sanctum tokens with expiry; roles and permissions; privileged roles cannot be self-assigned.

Service isolation

Internal services accept only HMAC-signed gateway calls and fail closed when unconfigured.

Secrets & databases

Generated per-app secrets, git-ignored env files, one database and role per service.

Validation & rate limiting

Form requests, path sanitising, per-IP and per-account throttling.

Kafka security

TLS/SASL settings, acks=all with idempotence, ACL guidance.

Secure deployment

Pinned images, private networks, no published service ports.

Security Documentation →

Built for developers. Open to exploration.

View on GitHub Read Documentation Report an Issue Contribute

About NestLaravel

NestLaravel is developed by Intelfric Technology Limited as a developer-focused framework for building structured, modular and event-driven backend systems.

Developed by

Dr. Constantino Msigwa

Company

Intelfric Technology Limited