Skip to content

Gateway

@nx/gatewayedge gateway của nền tảng, không phải một microservice IGNIS. Nó ship cấu hình proxy (Traefik v3.6 + một bảng route Nginx cục bộ) và một developer portal tĩnh Astro + React (@nx/gateway-portal). Nó không có database, không thực thể domain, không Kafka, không migrationpackage.json gốc chỉ mang metadata.

1. Tham khảo nhanh

Thuộc tínhGiá trị
Package@nx/gateway
TypeAPI Gateway (edge proxy + bảng route dev + portal) — không phải dịch vụ IGNIS
Runtime (prod proxy)Traefik v3.6 (traefik:v3.6)
Runtime (dev proxy)Nginx (nginx:1.27-alpine, host networking, chỉ Linux)
Runtime (portal)Astro 5 + React 19 + Tailwind 4 (tĩnh), phục vụ bởi nginxinc/nginx-unprivileged:1.27-alpine
Traefik entrypointsweb (:80), traefik (:8080 dashboard + Prometheus metrics)
HTTPS entrypointKhông — TLS được kết thúc tại edge Nginx, không phải Traefik
Portal dev port3003 (astro dev)
Portal container port8080
DB schemaN/A — không có datastore
Snowflake IDN/A — không sinh ID
Thực thể domain / KafkaN/A — xem Domain Model, API Events
Locationpackages/gateway
OwnerPlatform / Infra

2. Mục đích & Phạm vi

Bao gồmLoại trừ
Edge routing tới các dịch vụ backend (Traefik khám phá qua Docker-label)TLS termination (edge Nginx sở hữu)
Resilience: circuit breaker, rate limiting, security headersBusiness logic / dữ liệu domain (dịch vụ sở hữu)
Observability: Prometheus metrics, JSON access logs, Traefik dashboardPersistence — không DB, không migration
Bảng route một-cổng cho dev native (Nginx cục bộ)Event streaming — không Kafka producer/consumer
Developer portal: sức khỏe dịch vụ + trình khám phá OpenAPICấp phát auth — identity sở hữu JWT/JWKS

3. Tech Stack

Lớp proxy (chỉ config, không build):

ComponentMục đích
Traefik v3.6Reverse proxy production; Docker + File provider; resilience + metrics
Nginx 1.27-alpineBảng route trung tâm dev cục bộ (local/); đứng trước các dịch vụ native 127.0.0.1:31xx

Portal (@nx/gateway-portal):

Thư việnMục đích
astro ^5.7Trình build static-site (output: 'static')
react / react-dom ^19.1Island tương tác (bảng sức khỏe, trình khám phá endpoint)
tailwindcss ^4.2Styling qua @tailwindcss/vite
lucide-reactIcons
sonnerThông báo toast
clsx, tailwind-mergeTổ hợp class

Portal có bun.lock và cây phụ thuộc riêng — không thuộc chuỗi build backend. Config Traefik/Nginx không cần bước build.

4. Cấu trúc dự án

packages/gateway/
├── config/
│   ├── traefik.yml                 # Config tĩnh Traefik (entrypoints, providers, log, metrics)
│   └── dynamic/
│       └── middlewares.yml         # Router dashboard + middleware dùng chung (file provider)
├── local/
│   ├── docker-compose.yml          # local-nx-gateway (nginx, host networking)
│   └── nginx.conf                  # Bảng route dev trung tâm (/v1/api/<svc>/ + /stream)
├── portal/                         # @nx/gateway-portal — Astro 5 + React 19 + Tailwind 4
│   ├── src/
│   │   ├── components/             # Portal UI (home, services, monitor)
│   │   ├── pages/                  # index.astro
│   │   ├── hooks/                  # use-health-check.ts
│   │   ├── helpers/                # openapi-parser.helper.ts
│   │   ├── interfaces/             # IService, IApp, IEndpoint, ...
│   │   └── constants/              # services.constant.ts, apps.constant.ts
│   ├── astro.config.ts             # dev server :3003, output tĩnh
│   ├── nginx.conf                  # Config phục vụ (HTML no-cache, asset immutable)
│   ├── Dockerfile                  # Build tĩnh → nginx-unprivileged :8080
│   └── package.json                # @nx/gateway-portal
├── AGENTS.md
└── package.json                    # @nx/gateway (chỉ metadata — không script, không deps)

5. Kiến trúc

C4 đầy đủ + luồng request-routing: xem Kiến trúc.

6. Ảnh chụp Domain

N/A — gateway không có datastore và không có thực thể domain. Quy tắc routing và định nghĩa middleware là "model" duy nhất; chúng nằm trong config, không phải database. Xem Domain Model.

7. Tóm tắt Bề mặt

Gateway không phơi bày REST API riêng — nó proxy bề mặt của các dịch vụ khác. Các endpoint duy nhất do gateway sở hữu là vận hành:

EndpointLớpMục đích
/__gateway_healthLocal NginxLiveness probe gateway dev (trả về JSON {status:ok})
/dashboard, /apiTraefik :8080Traefik dashboard + API nội bộ (basic-auth)
/metricsTraefik :8080Prometheus metrics

Async topics: N/A — gateway không phát/tiêu thụ sự kiện Kafka, BullMQ, hay WebSocket. Xem API Events.

8. Components

ComponentNguồnMục đích
Config tĩnh Traefikconfig/traefik.ymlEntrypoints, Docker + File provider, JSON logs, Prometheus metrics
Config động Traefikconfig/dynamic/middlewares.ymlRouter dashboard + middleware dùng chung (file provider)
Bảng route Nginx cục bộlocal/nginx.confBảng route dev trung tâm cho dịch vụ native
Portalportal/src/SPA service-catalog tĩnh (sức khỏe + trình khám phá OpenAPI)

Chi tiết: xem Cấu hình.

9. Services

N/A — không có dịch vụ IGNIS. Gateway không có backend TypeScript. Logic của portal nằm trong React hooks/helpers (use-health-check.ts, openapi-parser.helper.ts), không phải các lớp IGNIS BaseService.

10. Repositories

N/A — không có datastore, không có repository.

11. Điểm vào

FileMục đích
config/traefik.ymlBootstrap Traefik (config tĩnh)
local/docker-compose.ymlContainer gateway dev cục bộ (local-nx-gateway)
portal/astro.config.tsDev server portal (:3003) + build tĩnh
portal/DockerfileImage production portal (nginx :8080)

Không có src/index.ts / migrate.ts — gateway không phải một ứng dụng IGNIS.

12. Cấu hình

Config tĩnh/động Traefik, upstream Nginx cục bộ, env portal, và danh sách hằng số service/apps: xem Cấu hình.

13. Vận hành

Deploy Traefik + portal, observability (metrics trên :8080), bảo mật (rate limit, circuit breaker), và runbook: xem Vận hành.

14. Trang liên quan

Khái niệm

Tham khảo

Tính năng

Quyết định

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.