integration-design
Design integration between two services — sync vs async, API gateway / BFF placement, anti-corruption layer, contract + versioning, ports-and-adapters, and backpressure handling.
- License 许可
- MIT
- 最近更新
- 2026-10-29
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- integration-design
- description
- Design integration between two services — sync vs async, API gateway / BFF placement, anti-corruption layer, contract + versioning, ports-and-adapters, and backpressure handling.
02 资源文件 1
- 参考文档routing.yaml499 B
03 SKILL.md 正文
integration-design
The contract between two services outlives both implementations. Design the seam — sync or async, who owns the schema, how it evolves — before the first call is wired.
Mode: analytical — judgment inside a fixed frame. Keep the output shape; every verdict cites its evidence; unknowns are marked [TBD] or [VERIFY], never filled in.
When to use
- Two services (or a client tier and services) need to talk and you are choosing the integration style.
- A client is making many chatty calls, or an upstream model is leaking into a downstream service.
- A workflow invokes
polymath-architecture:integration-design.
Not this when: the flow is an asynchronous business process with compensation — that is event-driven-design. For the REST resource/verb/status-code details of one endpoint, that is polymath-backend:api-design-rest.
Inputs
- The two parties, what data/operations cross the boundary, and the coupling/latency tolerance.
- Whether either party is legacy or third-party (drives the anti-corruption layer).
Procedure
- Sync vs async: request/response (REST/gRPC) when the caller needs an answer now and the callee is fast and available; messaging/events when you want temporal decoupling, buffering, or fan-out. State the choice per interaction, not per system.
- Place a gateway / BFF where it earns its keep: an API gateway for cross-cutting concerns (auth, rate-limit, routing) at the edge; a Backend-for-Frontend when distinct clients (web/mobile) need tailored aggregation — avoids chatty clients and leaking N services to the UI.
- Add an anti-corruption layer whenever you integrate with a legacy or third-party model: translate at the boundary so their model never becomes your model. This is the ports-and-adapters / hexagonal seam — the domain talks to a port, the adapter speaks their dialect.
- Define the contract explicitly: schema (OpenAPI/protobuf/event schema), ownership (who can change it), and a compatibility rule (additive-only, consumer-driven contracts, or versioned). Breaking changes need a versioning + deprecation path.
- Decide error & partial-failure semantics: timeouts, retries, and what a caller does when the callee is degraded (hand off to
resilience-designfor the parameters). - Handle backpressure for async edges: bounded queues, consumer lag monitoring, and what happens when the consumer can't keep up (drop, slow the producer, scale out) — never an unbounded buffer.
- Minimize coupling: prefer a narrow, stable contract over a wide one; flag any integration that requires sharing a database.
Output
Integration spec: mobile app ↔ order platform ↔ legacy ERP
Interaction Sync/async Why
app → order status sync REST user waits for an answer; p99 120 ms
order → ERP invoice async ERP is slow (p99 4 s) and down nightly; buffer it
Gateway/BFF: mobile BFF aggregates order + shipment + payment (3 calls → 1); auth + rate-limit at the edge gateway
ACL: erp-adapter translates ERP "DocType 14" ↔ our Invoice; the domain only sees the InvoicePort
Contract: orders API OpenAPI v2 · owner: checkout team · additive-only, breaking → /v3 + 6-month deprecation
Errors: BFF timeout 800 ms per downstream; partial response with `shipment: unavailable` (see resilience-design)
Backpressure: invoice queue bounded at 50k; consumer-lag alert at 10 min; on full → producer gets 503, retries later
Coupling flags: none — no shared database
Inline by default; when a workflow step or the user wants it kept, write it to docs/architecture/<slug>-integration.md (slug from the system or context name, lowercased, non-a-z0-9 runs → -).
Quality bar
- Each interaction's sync/async choice is justified by need, not habit.
- Every cross-boundary contract names an owner and an evolution rule.
- Integration with legacy/third-party goes through an anti-corruption layer.
- No async edge has an unbounded queue; backpressure behavior is defined.
04 同仓库更多 Skills
runbook
Write or refresh an operational runbook for an alert/symptom; structured as TL;DR + Pre-checks + Steps + Verification + Rollback + Escalation.
rfc
Draft a lightweight design RFC to docs/rfcs/<slug>.md; Summary, Motivation, Detailed design, Drawbacks, Alternatives, Unresolved questions. A proposal to debate, not a recorded decision (adr).
editorial-pass
Review and tighten prose in a Markdown artifact for a target tone (terse, formal, friendly) without dropping information; preserve quotations and load-bearing constraints.
architecture-review-facilitation
Run an architecture review as a process — entry criteria, reviewer checklist, decision log, and follow-up actions — pairing the design artifact with a red-team pass.
architecture-doc
Write a C4-style architecture document; System Context + Containers (+ Components when interesting) with mermaid diagrams. Describes structure, not a decision (adr) or proposal (rfc).
adr
Write an Architecture Decision Record (Michael Nygard format) to docs/adrs/NNNN-<slug>.md; frontmatter validated by the ADR artifact schema. Records a made decision, not a proposal to debate (rfc).