This repository contains a micro frontend shell architecture integrating Angular, React, and Vue applications using iframes. Routing is centralized through a custom Gateway app, which decides whether to serve static builds or proxy to local dev servers. Traefik v2 is used for routing incoming traffic to the gateway.
- Architecture
- Tech Stack
- Setup
- Folder Structure
- Running the Project
- Gateway Configuration
- Traefik Configuration
- Known Limitations
- Future Improvements
┌───────────────┐
│ Traefik │
│ (port 8082) │
└──────┬────────┘
│
▼
┌───────────────┐ ┌────────────────┐
│ Gateway │───────▶ shell (dev or static)
│ (port 9000) │───────▶ angular-app
└───────────────┘───────▶ react-app
└▶ vue-app
Each app can run in one of two modes:
- Serve mode: Gateway proxies requests to local development servers (e.g.,
localhost:500X
). - Static mode: Gateway serves built static files from
dist/[appName]
.
Modes are controlled via app-mode-config.json
:
{
"shell": "serve",
"angular-app": "serve",
"react-app": "serve",
"vue-app": "serve"
}
- Angular (Shell + App)
- React (Vite + Nx)
- Vue (Vite + Nx)
- Express.js (Gateway)
- Traefik v2 (Reverse proxy)
- Docker & Docker Compose
- Nx Monorepo
- Node.js (LTS)
- Docker & Docker Compose
- Nx CLI (optional)
npm install
nx build shell
nx build angular-app
nx build react-app
nx build vue-app
/apps
/shell
/angular-app
/react-app
/vue-app
/gateway
Dockerfile
main.ts
/docker compose.yml
/traefik.yml
/app-mode-config.json
- Ensure
app-mode-config.json
has apps set to"serve"
. - Run apps locally:
nx serve shell nx serve angular-app nx serve react-app nx serve vue-app
- Start Traefik + Gateway:
docker compose up
- Browse to http://localhost:8082/shell.
- Build all apps (see Build Micro Apps above).
- Set apps to
"static"
inapp-mode-config.json
. - Start Traefik + Gateway:
docker compose up
- Browse to http://localhost:8082/shell.
The Gateway (Express.js) reads app-mode-config.json
and for each route:
- Serve mode: Proxies to
http://host.docker.internal:500X
. - Static mode: Serves files from
dist/[appName]
, with SPA fallback.
Example app-mode-config.json
:
{
"shell": "static",
"angular-app": "serve",
"react-app": "static",
"vue-app": "serve"
}
version: '3.8'
services:
traefik:
image: traefik:v2.10
command:
- '--api.insecure=true'
- '--providers.docker=false'
- '--entrypoints.web.address=:80'
- '--providers.file.directory=/traefik/'
- '--providers.file.watch=true'
ports:
- '8082:80' # User traffic
- '8090:8080' # Dashboard
volumes:
- ./traefik.yml:/traefik/traefik.yml
extra_hosts:
- 'host.docker.internal:host-gateway'
gateway:
build:
context: .
dockerfile: apps/gateway/Dockerfile
ports:
- '9000:9000'
extra_hosts:
- 'host.docker.internal:host-gateway'
http:
routers:
gateway:
rule: |
PathPrefix(`/`) ||
PathPrefix(`/shell`) ||
PathPrefix(`/angular-app`) ||
PathPrefix(`/react-app`) ||
PathPrefix(`/vue-app`)
service: gateway
entryPoints:
- web
services:
gateway:
loadBalancer:
servers:
- url: 'http://gateway:9000'
- Route synchronization between shell and micro apps is not implemented.
- SEO and SSR are not fully supported due to iframe-based architecture.
- Sync routes between shell and iframe apps via
postMessage
. - Propagate auth tokens securely.