Chuyển đến nội dung chính

Lesson 3: Full-Stack overview architecture — Microservices + Micro Frontend + BFF

Comprehensive architectural blueprint: Frontend (Micro Frontend Shell + Remote Apps), BFF Layer, API Gateway, Backend Microservices, Message Broker, Database per Service. End-to-end request flow and key integration points.

🏗️ Architecture — Lesson 3 Lesson 3: Full-Stack overview architecture — Microservices + Micro Frontend + BFF

Microservices & Micro Frontend system design — From basics to Production

Part 1: Foundation — Evolution of Architecture

xdev.asia

Introduction

After understanding the architectural and DDD evolution roadmap, this article draws the overall blueprint for the Full-Stack Microservices + Micro Frontend system — an architectural map that we will dive into in detail throughout the series.

Full-Stack Architecture Blueprint — Microservices + Micro Frontend


1. Architecture Overview

1.1 Full-Stack Architecture Blueprint

┌─────────────────────────────────────────────────────┐
│                    CLIENTS                          │
│            (Browser, Mobile, IoT)                   │
└──────────────────────┬──────────────────────────────┘
                       │
┌──────────────────────┴──────────────────────────────┐
│              CDN (Static Assets)                    │
│         CloudFront / CloudFlare / Vercel            │
└──────────────────────┬──────────────────────────────┘
                       │
┌──────────────────────┴──────────────────────────────┐
│           MICRO FRONTEND LAYER                      │
│  ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────────┐  │
│  │Shell │ │Produc│ │ Cart │ │Order │ │ Account  │  │
│  │ App  │ │ MFE  │ │ MFE  │ │ MFE  │ │   MFE    │  │
│  └──┬───┘ └──┬───┘ └──┬───┘ └──┬───┘ └────┬─────┘  │
└─────┼────────┼────────┼────────┼──────────┼─────────┘
      └────────┴────────┴────────┴──────────┘
                       │
┌──────────────────────┴──────────────────────────────┐
│              BFF LAYER (Optional)                   │
│        Backend for Frontend Aggregation             │
└──────────────────────┬──────────────────────────────┘
                       │
┌──────────────────────┴──────────────────────────────┐
│              API GATEWAY                            │
│     (Kong / APISIX / Envoy Gateway)                 │
│  Auth │ Rate Limit │ Routing │ Load Balance         │
└──┬────────┬────────────┬────────────┬───────────────┘
   │        │            │            │
┌──┴──┐ ┌───┴───┐  ┌────┴────┐  ┌────┴────┐
│User │ │Product│  │  Cart   │  │  Order  │
│ µS  │ │  µS   │  │   µS    │  │   µS    │
│     │ │       │  │         │  │         │
│┌───┐│ │┌────┐ │  │ ┌─────┐ │  │ ┌─────┐ │
││PG ││ ││PG  │ │  │ │Redis│ │  │ │ PG  │ │
│└───┘│ │└────┘ │  │ └─────┘ │  │ └─────┘ │
└─────┘ └───────┘  └─────────┘  └────┬────┘
                                     │
┌────────────────────────────────────┴────────────────┐
│              MESSAGE BROKER                         │
│         (Kafka / RabbitMQ / NATS)                   │
│    Events: OrderPlaced, PaymentConfirmed, etc.      │
└─────────────────────────────────────────────────────┘

2. Main layers

2.1 Micro Frontend Layer

Shell Application (Container) coordinates Remote Micro Frontend applications. Each MFE is an independent application, built and deployed separately.

Shell App Responsibilities:

  • General layout (Header, Footer, Sidebar)
  • Routing & Navigation
  • Authentication state
  • Error boundaries

2.2 BFF Layer

Backend for Frontend aggregates data from many microservices, transforming it into a suitable format for each micro frontend. Especially useful when:

  • Frontend needs data from many services in one request
  • Mobile vs Web needs different data formats
  • Need separate caching layer for frontend

2.3 API Gateway

Entry point for all API calls. Handling cross-cutting concerns:

  • Authentication/Authorization: Verify JWT tokens
  • Rate Limiting: Protects the backend from abuse
  • Request Routing: Route to the correct service
  • Load Balancing: Traffic distribution
  • SSL Termination: Handles HTTPS

2.4 Microservices Layer

Each microservice owns a Bounded Context, has its own database, and deploys independently. Communicate via REST/gRPC (sync) or Message Broker (async).

2.5 Message Broker / Event Bus

Backbone for async communication between services. Ensure loose coupling and event-driven data flow.


3. Request Flow End-to-End

User clicks "Add to Cart" trên Product MFE:

1. Product MFE → Shell App (event: addToCart)
2. Shell App → API Gateway (POST /api/cart/items)
3. API Gateway → Auth check → Route đến Cart Service
4. Cart Service → Validate product (call Product Service via gRPC)
5. Cart Service → Save to Redis
6. Cart Service → Publish event "ItemAddedToCart" lên Kafka
7. Response → API Gateway → Shell App
8. Shell App → Cart MFE (update cart badge via custom event)
9. Recommendation Service (async) → Listen event → Update recommendations

4. Technology Stack Overview

LayersTechnologyWhy
Micro FrontendReact + Module FederationMature ecosystem, large community
Shell AppReact + React RouterSPA routing, lazy loading
Design SystemTailwind CSS + StorybookConsistent UI, component library
BFFNode.js (Fastify)Same language as frontend, fast I/O
API GatewayKong / APISIXPlugin ecosystem, high performance
MicroservicesNode.js/GoNode for CRUD, Go for high-perf
Message BrokerApache KafkaDurability, replayability, high throughput
DatabasesPostgreSQL, Redis, ElasticsearchPolyglot persistence
AuthKeycloakOpen-source, full OAuth2/OIDC
CI/CDGitHub Actions + ArgoCDGitOps, Kubernetes-native
ObservabilityOpenTelemetry + Grafana StackVendor-neutral, full-stack tracing

Summary

This article provides an overview architectural map for the entire series. Each layer will be delved into in the following sections. Understanding big picture helps you not get lost when going into the details of each component.


Next article: Lesson 4: Service Decomposition — Bounded Context & Service Boundaries