Microservices Overview

From Monolith to Services

A monolith is one deployable app (what we built so far). Microservices split it into small services that own their data and talk over the network. NestJS has a package, @nestjs/microservices, that lets you write services with the same controllers and decorators, but over TCP, Redis, Kafka, RabbitMQ, NATS or gRPC instead of HTTP.

Next.js storefront / mobile app
                         |  HTTP
                         v
                 API Gateway (NestJS, HTTP)
          /            |               \
   TCP/RMQ        Kafka events        TCP
     v                 v                v
 Catalog svc      Orders svc  ---> Payments svc
 (Postgres)       (Postgres)  event (Postgres)
                       |
                       +--> Notifications svc (consumes events)

Note: Microservices add network failures, distributed data and harder debugging. Start with a well-structured modular monolith; split out a service when a team or a scaling need clearly asks for it.