{"id":"6b09a4bcff996234422a271a","slug":"sa-integrations-and-contracts","title":"Integracje i kontrakty: API, zdarzenia i zależności między zespołami bez niespodzianek","summary":"Integracje to miejsce, w którym projekty najczęściej się sypią. Jak architekt rozwiązań wybiera między komunikacją synchroniczną i asynchroniczną, projektuje kontrakty w OpenAPI i AsyncAPI, wersjonuje je bez łamania konsumentów, zapewnia idempotencję i niezawodne publikowanie zdarzeń (outbox), planuje zależności między zespołami (RACI, harmonogram) i weryfikuje kontrakty testami (Pact) – na przykładzie systemu zamówień marketplace.","servedLang":"pl","availableLangs":["pl","en"],"topics":["solution-architecture","event-driven-architecture","swagger-openapi","microservices","circuit-breaker"],"techs":["general","typescript","dotnet","java"],"tags":["solution-architect","integration","openapi","asyncapi","idempotency","outbox","contract-testing","api-versioning"],"level":"intermediate","kind":"article","access":"members","status":"published","cover":null,"author":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","community":false},"readingMinutes":18,"stats":{"views":0,"likes":0,"bookmarks":0,"comments":0},"publishedAt":"2026-11-27T15:41:48.695Z","updatedAt":"2026-11-27T16:10:15.923Z","requestedLang":"pl","theme":{"hero":"classic","heroMedia":null,"accent":"teal","background":"hex","weaveResources":true,"toc":"right"},"seoDescription":"Integracje systemów dla architekta: REST czy Kafka, dostępność łańcucha wywołań, contract-first z OpenAPI 3.1 i AsyncAPI 3.0, wersjonowanie API i zdarzeń, Idempotency-Key, transactional outbox, idempotentny konsument, RACI i plan zależności, testy kontraktowe Pact.","wordCount":3419,"doc":{"type":"doc","content":[{"type":"paragraph","content":[{"type":"text","text":"Trzy tygodnie przed startem produkcyjnym zespół ERP mówi: „wasze zdarzenie ma kwotę jako liczbę zmiennoprzecinkową, a my księgujemy w groszach – i tak w ogóle nasz konsument będzie gotowy w maju”. Każdy, kto prowadził projekt integracyjny, zna tę scenę. Kod poszczególnych zespołów zwykle działa – sypie się to, co "},{"type":"text","text":"pomiędzy","marks":[{"type":"bold"}]},{"type":"text","text":": kontrakty, terminy, założenia o dostępności. Dlatego integracje i zależności to jeden z głównych obowiązków architekta rozwiązań: uzgodnić kontrakty API i zdarzeń z innymi zespołami i systemami oraz pilnować, "},{"type":"text","text":"kto komu co dostarcza i kiedy","marks":[{"type":"bold"}]},{"type":"text","text":"."}]},{"type":"callout","attrs":{"variant":"tip","title":"W skrócie"},"content":[{"type":"bulletList","content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Synchronicznie pytaj, asynchronicznie informuj.","marks":[{"type":"bold"}]},{"type":"text","text":" Każde wywołanie synchroniczne mnoży ryzyko niedostępności – łańcuch dziesięciu usług po 99,9% ma tylko ok. 99,0%."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Kontrakt najpierw","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"contract-first","marks":[{"type":"italic"}]},{"type":"text","text":"): OpenAPI dla REST, AsyncAPI dla zdarzeń – w repozytorium, z review konsumentów, zanim powstanie kod."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Ponowienia są pewne, więc "},{"type":"text","text":"idempotencja","marks":[{"type":"bold"}]},{"type":"text","text":" jest obowiązkowa; zdarzenia publikuj przez "},{"type":"text","text":"outbox","marks":[{"type":"bold"}]},{"type":"text","text":", a zależności między zespołami prowadź jak plan projektu: RACI, daty, kamienie milowe."}]}]}]}]},{"type":"stats","attrs":{"items":[{"value":"99,0%","label":"dostępność łańcucha 10 usług po 99,9%","hint":"0,999¹⁰ – iloczyn dostępności"},{"value":"3.0","label":"aktualna główna wersja AsyncAPI","hint":"kanały i operacje opisane osobno"},{"value":"RFC 9457","label":"Problem Details dla HTTP API","hint":"wspólny format błędów"}]}},{"type":"heading","attrs":{"level":2,"id":"mapa-integracji-pierwszy-artefakt"},"content":[{"type":"text","text":"Mapa integracji – pierwszy artefakt"}]},{"type":"paragraph","content":[{"type":"text","text":"Zanim zaczniesz dyskusję o REST-cie i Kafce, zrób "},{"type":"text","text":"mapę integracji","marks":[{"type":"bold"}]},{"type":"text","text":": każdy system, z którym rozmawiasz, w jednym wierszu. Dla OrderFlow – nowego systemu zamówień marketplace Bazario z poprzednich artykułów – wygląda tak:"}]},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"System"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Kierunek"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Styl"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Kontrakt"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Właściciel"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Termin"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Kanały (aplikacja, strona, konsultant)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"→ OrderFlow"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"REST, synchronicznie"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OpenAPI "},{"type":"text","text":"orderflow-api","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zespół checkoutu"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"15.12 (v1)"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Operator płatności"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OrderFlow →"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"REST, synchronicznie, limit 900 ms"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"specyfikacja operatora"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"dostawca zewnętrzny"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"jest"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Antyfraud"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OrderFlow →"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"REST, synchronicznie"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OpenAPI "},{"type":"text","text":"fraud","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zespół płatności"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"jest (limit 20/s)"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"WMS (stany)"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"→ OrderFlow"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zdarzenie, Kafka"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"AsyncAPI "},{"type":"text","text":"stock-levels","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zespół magazynu"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"15.01"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"ERP"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OrderFlow →"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zdarzenie, Kafka"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"AsyncAPI "},{"type":"text","text":"order-events","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zespół ERP"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"konsument do końca Q1"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"WMS, panel sprzedawcy, powiadomienia, hurtownia"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"OrderFlow →"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zdarzenie, Kafka"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"AsyncAPI "},{"type":"text","text":"order-events","marks":[{"type":"code"}]}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zespoły konsumentów"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"przed go-live"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"Już ta tabela odpowiada na pytania, które za trzy miesiące będą bolały: kto jest właścicielem kontraktu, gdzie on leży i na kiedy jest potrzebny."}]},{"type":"heading","attrs":{"level":2,"id":"synchronicznie-czy-asynchronicznie"},"content":[{"type":"text","text":"Synchronicznie czy asynchronicznie"}]},{"type":"paragraph","content":[{"type":"text","text":"Reguła kciuka: "},{"type":"text","text":"synchronicznie pytaj, asynchronicznie informuj","marks":[{"type":"bold"}]},{"type":"text","text":". OrderFlow potrzebuje autoryzacji płatności "},{"type":"text","text":"teraz","marks":[{"type":"italic"}]},{"type":"text","text":" – bez niej nie potwierdzi zamówienia. Ale ERP, magazyn, panel sprzedawcy i powiadomienia nie muszą odpowiadać, zanim klient zobaczy potwierdzenie – wystarczy, że dowiedzą się o zamówieniu."}]},{"type":"diagram","attrs":{"kind":"mermaid","code":"sequenceDiagram\n  participant O as OrderFlow\n  participant P as Operator płatności\n  O->>P: POST /authorizations (limit 900 ms)\n  alt odpowiedź w czasie\n    P-->>O: 201 autoryzowano\n    O->>O: potwierdzenie zamówienia\n  else przekroczony limit lub błąd 5xx\n    O->>O: status „płatność w toku”, ponowienie w tle, potwierdzenie e-mailem\n  end","caption":"Synchronicznie: wołający czeka na odpowiedź – i na każdą awarię po drodze"}},{"type":"diagram","attrs":{"kind":"mermaid","code":"sequenceDiagram\n  participant O as OrderFlow\n  participant K as Kafka\n  participant E as ERP\n  participant W as WMS\n  participant S as Panel sprzedawcy\n  participant N as Powiadomienia\n  O-)K: OrderConfirmed (z outboxa)\n  K-)E: faktura (po nocnym zamknięciu dnia)\n  K-)W: zlecenie kompletacji\n  K-)S: nowe zamówienie dla sprzedawcy\n  K-)N: e-mail i push do klienta","caption":"Asynchronicznie: nadawca publikuje fakt, odbiorcy reagują we własnym tempie"}},{"type":"table","content":[{"type":"tableRow","content":[{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Cecha"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Synchronicznie (REST, gRPC)"}]}]},{"type":"tableHeader","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Asynchronicznie (zdarzenia, kolejki)"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Sprzężenie w czasie"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"obie strony muszą działać jednocześnie"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"odbiorca może być chwilowo niedostępny"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Odpowiedź"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"od razu, z wynikiem"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"brak – albo osobnym kanałem ("},{"type":"text","text":"async request-reply","marks":[{"type":"italic"}]},{"type":"text","text":")"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Spójność"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"natychmiastowa w ramach wywołania"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"ostateczna – z opóźnieniem"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Awarie"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"propagują się w górę łańcucha"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"buforowane w brokerze"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Nowy odbiorca"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"zmiana u nadawcy"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"podłącza się do tematu, nadawca bez zmian"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Diagnostyka"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"prosta: żądanie i odpowiedź"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"trudniejsza: śledzenie rozproszone, opóźnienia konsumentów"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"Koszt operacyjny"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"niski"}]}]},{"type":"tableCell","attrs":{"colspan":1,"rowspan":1},"content":[{"type":"paragraph","content":[{"type":"text","text":"broker, schematy, outbox, deduplikacja"}]}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"Dlaczego tak ostrożnie z łańcuchami wywołań synchronicznych? Bo dostępność łańcucha to w przybliżeniu "},{"type":"text","text":"iloczyn","marks":[{"type":"bold"}]},{"type":"text","text":" dostępności jego ogniw. Dziesięć usług po 99,9% daje 99,0% – czyli zamiast 43 minut przestoju w miesiącu ponad 7 godzin. Z zależnościami po 99,5% jest jeszcze gorzej:"}]},{"type":"chart","attrs":{"type":"line","title":"Dostępność łańcucha wywołań synchronicznych","caption":"Wyliczenie: dostępność ogniwa podniesiona do potęgi liczby ogniw (przy założeniu niezależnych awarii). Ścieżki awaryjne i asynchroniczność przerywają ten iloczyn.","unit":"% dostępności","data":{"labels":["1","2","3","4","5","6","7","8","9","10"],"series":[{"name":"Ogniwa po 99,9%","values":[99.9,99.8,99.7,99.6,99.5,99.4,99.3,99.2,99.1,99]},{"name":"Ogniwa po 99,5%","values":[99.5,99,98.51,98.02,97.52,97.04,96.55,96.07,95.59,95.11]}]}}},{"type":"paragraph","content":[{"type":"text","text":"Każde wywołanie synchroniczne w projekcie potrzebuje więc trzech rzeczy: "},{"type":"text","text":"limitu czasu","marks":[{"type":"bold"}]},{"type":"text","text":" (nigdy nie czekaj w nieskończoność), "},{"type":"text","text":"decyzji, co robimy przy awarii","marks":[{"type":"bold"}]},{"type":"text","text":" (ścieżka awaryjna, a nie wyjątek do klienta) i często "},{"type":"text","text":"wyłącznika obwodu","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"circuit breaker","marks":[{"type":"italic"}]},{"type":"text","text":"), który przestaje męczyć niedziałającą zależność."}]},{"type":"heading","attrs":{"level":2,"id":"kontrakt-najpierw-openapi-i-asyncapi"},"content":[{"type":"text","text":"Kontrakt najpierw: OpenAPI i AsyncAPI"}]},{"type":"paragraph","content":[{"type":"text","text":"Kontrakt to umowa między zespołami – i jak każda umowa powinien powstać "},{"type":"text","text":"przed","marks":[{"type":"bold"}]},{"type":"text","text":" pracą, a nie po niej. Podejście "},{"type":"text","text":"contract-first","marks":[{"type":"italic"}]},{"type":"text","text":" wygląda tak:"}]},{"type":"orderedList","attrs":{"start":1},"content":[{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Dostawca przygotowuje szkic kontraktu jako pull request w repozytorium kontraktów."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Konsumenci robią review: czy mają wszystkie pola, czy rozumieją znaczenie, czy formaty pasują (kwoty, daty, strefy czasowe)."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Po akceptacji z kontraktu powstaje "},{"type":"text","text":"serwer zastępczy","marks":[{"type":"bold"}]},{"type":"text","text":" ("},{"type":"text","text":"mock","marks":[{"type":"italic"}]},{"type":"text","text":") – konsumenci mogą pracować, zanim dostawca skończy."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Lintery (np. Spectral) pilnują firmowych reguł stylu, a w CI sprawdzane są zmiany łamiące zgodność."}]}]},{"type":"listItem","content":[{"type":"paragraph","content":[{"type":"text","text":"Implementacja jest weryfikowana względem kontraktu – testami kontraktowymi."}]}]}]},{"type":"paragraph","content":[{"type":"text","text":"Dla REST standardem jest "},{"type":"text","text":"OpenAPI","marks":[{"type":"bold"}]},{"type":"text","text":" (wersja 3.1 jest zgodna z JSON Schema 2020-12), dla zdarzeń i kolejek – "},{"type":"text","text":"AsyncAPI","marks":[{"type":"bold"}]},{"type":"text","text":" (wersja 3.0 opisuje osobno kanały i operacje). Poniżej kompletne, poprawne kontrakty OrderFlow: API składania zamówień z nagłówkiem "},{"type":"text","text":"Idempotency-Key","marks":[{"type":"code"}]},{"type":"text","text":" i błędami w formacie Problem Details (RFC 9457) oraz zdarzenie "},{"type":"text","text":"OrderConfirmed","marks":[{"type":"code"}]},{"type":"text","text":" w Kafce:"}]},{"type":"codeGroup","attrs":{"title":"Kontrakty OrderFlow: OpenAPI 3.1 i AsyncAPI 3.0"},"content":[{"type":"codeBlock","attrs":{"language":"yaml","filename":"contracts/orderflow-api.openapi.yaml"},"content":[{"type":"text","text":"openapi: 3.1.0\ninfo:\n  title: OrderFlow Orders API\n  version: 1.2.0\n  description: Placing orders on the Bazario marketplace and reading their status.\nservers:\n  - url: https://api.bazario.example/orderflow/v1\npaths:\n  /orders:\n    post:\n      operationId: placeOrder\n      summary: Place an order and receive a confirmation\n      security:\n        - oidc: [orders:write]\n      parameters:\n        - $ref: '#/components/parameters/IdempotencyKey'\n      requestBody:\n        required: true\n        content:\n          application/json:\n            schema:\n              $ref: '#/components/schemas/PlaceOrderRequest'\n      responses:\n        '201':\n          description: Order stored; the confirmation (or \"payment pending\") is included\n          headers:\n            Location:\n              description: URL of the created order\n              schema: { type: string, format: uri-reference }\n          content:\n            application/json:\n              schema:\n                $ref: '#/components/schemas/Order'\n        '409':\n          description: The same Idempotency-Key was used with a different body, or the first request is still running\n          content:\n            application/problem+json:\n              schema: { $ref: '#/components/schemas/Problem' }\n        '422':\n          description: Validation failed or an item is out of stock\n          content:\n            application/problem+json:\n              schema: { $ref: '#/components/schemas/Problem' }\n  /orders/{orderId}:\n    get:\n      operationId: getOrder\n      summary: Current state of an order\n      security:\n        - oidc: [orders:read]\n      parameters:\n        - name: orderId\n          in: path\n          required: true\n          schema: { type: string, format: uuid }\n      responses:\n        '200':\n          description: The order with its current status\n          content:\n            application/json:\n              schema: { $ref: '#/components/schemas/Order' }\n        '404':\n          description: No such order (or no access to it)\n          content:\n            application/problem+json:\n              schema: { $ref: '#/components/schemas/Problem' }\ncomponents:\n  parameters:\n    IdempotencyKey:\n      name: Idempotency-Key\n      in: header\n      required: true\n      description: Client-generated UUID. Repeating the request with the same key returns the original response.\n      schema: { type: string, format: uuid }\n  schemas:\n    Money:\n      type: object\n      required: [amount, currency]\n      properties:\n        amount: { type: string, pattern: '^\\d+\\.\\d{2}$', examples: ['249.90'] }   # decimal as text, never float\n        currency: { type: string, pattern: '^[A-Z]{3}$', examples: ['PLN'] }      # ISO 4217\n    OrderLine:\n      type: object\n      required: [offerId, quantity]\n      properties:\n        offerId: { type: string, format: uuid }        # a seller's offer of a product\n        quantity: { type: integer, minimum: 1, maximum: 99 }\n    PlaceOrderRequest:\n      type: object\n      required: [customerId, lines, delivery, paymentToken]\n      properties:\n        customerId: { type: string, format: uuid }\n        lines:\n          type: array\n          minItems: 1\n          items: { $ref: '#/components/schemas/OrderLine' }\n        delivery: { type: string, enum: [COURIER, PARCEL_LOCKER, PICKUP_POINT] }\n        paymentToken: { type: string, description: Token issued by the payment operator – never a card number }\n    Order:\n      type: object\n      required: [orderId, status, total, placedAt]\n      properties:\n        orderId: { type: string, format: uuid }\n        status: { type: string, enum: [CONFIRMED, PAYMENT_PENDING, PENDING_REVIEW, REJECTED] }\n        total: { $ref: '#/components/schemas/Money' }\n        placedAt: { type: string, format: date-time }\n        confirmedAt: { type: string, format: date-time }\n    Problem:   # RFC 9457 Problem Details for HTTP APIs\n      type: object\n      properties:\n        type: { type: string, format: uri-reference }\n        title: { type: string }\n        status: { type: integer }\n        detail: { type: string }\n        instance: { type: string, format: uri-reference }\n  securitySchemes:\n    oidc:\n      type: openIdConnect\n      openIdConnectUrl: https://login.bazario.example/.well-known/openid-configuration"}]},{"type":"codeBlock","attrs":{"language":"yaml","filename":"contracts/order-events.asyncapi.yaml"},"content":[{"type":"text","text":"asyncapi: 3.0.0\ninfo:\n  title: OrderFlow order events\n  version: 1.0.0\n  description: Events published by OrderFlow whenever an order is confirmed.\ndefaultContentType: application/json\nservers:\n  production:\n    host: kafka.bazario.example:9093\n    protocol: kafka-secure\n    description: Company Kafka cluster (TLS + SASL)\nchannels:\n  orderEvents:\n    address: orders.events.v1\n    messages:\n      orderConfirmed:\n        $ref: '#/components/messages/OrderConfirmed'\n    bindings:\n      kafka:\n        partitions: 12\n        replicas: 3\noperations:\n  publishOrderConfirmed:\n    action: send\n    summary: OrderFlow publishes every confirmed order through the transactional outbox.\n    channel:\n      $ref: '#/channels/orderEvents'\n    messages:\n      - $ref: '#/channels/orderEvents/messages/orderConfirmed'\ncomponents:\n  messages:\n    OrderConfirmed:\n      name: OrderConfirmed\n      title: Order confirmed\n      headers:\n        type: object\n        required: [eventId, eventType, occurredAt]\n        properties:\n          eventId: { type: string, format: uuid, description: Unique per event – consumers deduplicate on it }\n          eventType: { type: string, const: OrderConfirmed }\n          occurredAt: { type: string, format: date-time }\n          correlationId: { type: string }\n      payload:\n        $ref: '#/components/schemas/OrderConfirmedPayload'\n      bindings:\n        kafka:\n          key:\n            type: string\n            description: orderId – keeps all events of one order in order\n  schemas:\n    OrderConfirmedPayload:\n      type: object\n      required: [orderId, customerId, lines, total, paymentStatus, confirmedAt]\n      properties:\n        orderId: { type: string, format: uuid }\n        customerId: { type: string, format: uuid, description: Internal id only – no address, phone or e-mail }\n        lines:\n          type: array\n          items:\n            type: object\n            required: [offerId, sellerId, quantity]\n            properties:\n              offerId: { type: string, format: uuid }\n              sellerId: { type: string, format: uuid }\n              quantity: { type: integer, minimum: 1 }\n        total:\n          type: object\n          required: [amount, currency]\n          properties:\n            amount: { type: string, pattern: '^\\d+\\.\\d{2}$' }\n            currency: { type: string, pattern: '^[A-Z]{3}$' }\n        paymentStatus: { type: string, enum: [AUTHORISED, PENDING] }\n        confirmedAt: { type: string, format: date-time }"}]}]}]},"toc":[{"id":"mapa-integracji-pierwszy-artefakt","text":"Mapa integracji – pierwszy artefakt","level":2,"locked":false},{"id":"synchronicznie-czy-asynchronicznie","text":"Synchronicznie czy asynchronicznie","level":2,"locked":false},{"id":"kontrakt-najpierw-openapi-i-asyncapi","text":"Kontrakt najpierw: OpenAPI i AsyncAPI","level":2,"locked":false},{"id":"wersjonowanie-kontraktow","text":"Wersjonowanie kontraktów","level":2,"locked":true},{"id":"idempotencja","text":"Idempotencja","level":2,"locked":true},{"id":"outbox-zdarzenia-ktore-nie-gina","text":"Outbox – zdarzenia, które nie giną","level":2,"locked":true},{"id":"zaleznosci-miedzy-zespolami-kto-komu-co-dostarcza-i-kiedy","text":"Zależności między zespołami: kto komu co dostarcza i kiedy","level":2,"locked":true},{"id":"testy-kontraktowe","text":"Testy kontraktowe","level":2,"locked":true},{"id":"powiazane","text":"Powiązane","level":2,"locked":true},{"id":"sprawdz-sie","text":"Sprawdź się","level":2,"locked":true}],"locked":true,"paywall":null,"previewRatio":0.3,"totalBlocks":57,"visibleBlocks":20,"resources":[{"id":"6b0857b23c96f2d34d0b3514","type":"repo","provider":"github","url":"https://github.com/asyncapi/spec","embedUrl":null,"title":"asyncapi/spec","description":"The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.","author":"asyncapi","thumbnailUrl":"https://opengraph.githubassets.com/1/asyncapi/spec","durationSec":null,"lang":"en","topics":["event-driven-architecture"],"techs":["javascript"],"tags":["asyncapi","reactive","specification","websockets","amqp","mqtt","messaging","stomp","kafka","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"github","publishedAt":"2016-11-18T22:06:50.000Z","popularity":72,"verifiedAt":"2026-11-26T10:56:00.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:50.215Z","updatedAt":"2026-11-26T16:00:50.215Z"},{"id":"6b0857bf3c96f2d34d0b4281","type":"article","provider":"web","url":"https://microservices.io/patterns/data/transactional-outbox.html","embedUrl":null,"title":"Microservices Pattern: Pattern: Transactional outbox","description":"First, write the message/event to a database OUTBOX table as part of the transaction that updates business objects, and then publish it to a message broker.","author":"Chris Richardson (microservices.io)","thumbnailUrl":null,"durationSec":null,"lang":"en","topics":["event-driven-architecture","microservices"],"techs":["general"],"tags":["databases","messaging","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":65,"verifiedAt":"2026-11-26T11:25:55.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857be3c96f2d34d0b41ed","type":"article","provider":"web","url":"https://martinfowler.com/bliki/ContractTest.html","embedUrl":null,"title":"bliki: Contract Test","description":"Test Doubles avoid non-deterministic errors, but you need Contract Tests to ensure they remain consistent with the real services.","author":"Martin Fowler","thumbnailUrl":"https://martinfowler.com/bliki/images/contractTest/sketch.png","durationSec":null,"lang":"en","topics":[],"techs":["general"],"tags":["martin-fowler","testing"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":75,"verifiedAt":"2026-11-26T11:07:18.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:00:59.965Z","updatedAt":"2026-11-26T16:00:59.965Z"},{"id":"6b0857bf3c96f2d34d0b4250","type":"article","provider":"web","url":"https://learn.microsoft.com/en-us/azure/architecture/microservices/design/api-design","embedUrl":null,"title":"API Design","description":"Learn about API design for microservices, including REST and RPC trade-offs, versioning strategies, and mapping REST to domain-driven design.","author":"Microsoft Azure Architecture Center","thumbnailUrl":"https://learn.microsoft.com/en-us/media/open-graph-image.png","durationSec":null,"lang":"en","topics":["microservices","ddd-strategic-design"],"techs":["general"],"tags":["azure","cloud","api-design","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":68,"verifiedAt":"2026-11-26T11:07:35.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857bf3c96f2d34d0b4253","type":"article","provider":"web","url":"https://learn.microsoft.com/en-us/azure/architecture/microservices/design/interservice-communication","embedUrl":null,"title":"Interservice communication in microservices","description":"Learn about the tradeoffs between asynchronous messaging versus synchronous APIs for communication between microservices and some challenges in communication.","author":"Microsoft Azure Architecture Center","thumbnailUrl":"https://learn.microsoft.com/en-us/media/open-graph-image.png","durationSec":null,"lang":"en","topics":["microservices"],"techs":["general"],"tags":["azure","cloud","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"manual","publishedAt":null,"popularity":68,"verifiedAt":"2026-11-26T11:07:35.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:02.417Z","updatedAt":"2026-11-26T16:01:02.417Z"},{"id":"6b0857c93c96f2d34d0b4aaa","type":"video","provider":"youtube","url":"https://www.youtube.com/watch?v=w1P7FBBrrig","embedUrl":"https://www.youtube-nocookie.com/embed/w1P7FBBrrig","title":"Idempotent Requests in Microservices (Minute Engineering)","description":"In this story, I discuss Idempotency and its importance in Microservices 🏭 Software Architecture Videos https://www.youtube.com/playlist?list=PLQnljOFTspQXNP6mQchJVP3S-3oKGEuw9 💾 Database Engineering Videos https://www.youtube.com/playlist?list=PLQnljOFTspQXjD0HOzN7P2tgzu7scWpl2 🛰 Network…","author":"Hussein Nasser","thumbnailUrl":"https://i.ytimg.com/vi/w1P7FBBrrig/hqdefault.jpg","durationSec":null,"lang":"en","topics":["microservices"],"techs":["general"],"tags":["databases","software-architecture"],"price":"free","featured":false,"featuredOrder":0,"packageName":null,"source":"youtube-rss","publishedAt":"2020-06-02T13:45:01.000Z","popularity":54,"verifiedAt":"2026-11-26T10:55:18.000Z","curated":false,"addedBy":"6b0857a15a2625e44ecaabe6","createdAt":"2026-11-26T16:01:12.872Z","updatedAt":"2026-11-26T16:01:12.872Z"}],"challenges":[{"id":"6b093dc291bd8fbaf2a0c8d8","slug":"payment-circuit-breaker","title":"Bezpiecznik przed bramką płatności","summary":"Circuit breaker ze stanami zamknięty, otwarty i półotwarty, wstrzykiwanym zegarem, progiem prób testowych i filtrem błędów biznesowych – żeby awaria bramki płatności nie położyła całego sklepu.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"architecture","status":"published","difficulty":"hard","topics":["circuit-breaker","microservices"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["circuit-breaker","resilience","fault-tolerance","state-machine","payments"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":40,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:26.251Z"},{"id":"6b093ddfbd4755deb67ee092","slug":"retry-with-backoff","title":"Ponawianie z wykładniczym opóźnieniem","summary":"Funkcja ponawiająca nieudaną operację z opóźnieniem 100, 200, 400… ms, z górnym limitem i filtrem błędów. Zegar wstrzykiwany, więc testy nie czekają ani milisekundy.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"algorithms","status":"published","difficulty":"easy","topics":["circuit-breaker"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["resilience","backoff","higher-order-functions","dependency-injection","async"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":10,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:55.300Z"},{"id":"6b093dc191bd8fbaf2a0c8d0","slug":"inventory-cqrs","title":"Magazyn z CQRS – osobny model zapisu i odczytu","summary":"Komendy magazynowe walidowane na własnym modelu zapisu, zdarzenia na szynie i projekcja budująca model odczytu z raportem niskich stanów. Model odczytu da się odtworzyć z samych zdarzeń.","servedLang":"pl","availableLangs":["pl","en"],"kind":"code","category":"architecture","status":"published","difficulty":"medium","topics":["cqrs","event-driven-architecture"],"techs":["typescript","javascript","python","dotnet","java","go"],"tags":["cqrs","read-model","projection","events","inventory"],"languages":["typescript","javascript","python","csharp","java","go"],"questionCount":null,"xp":20,"stats":{"attempts":0,"solves":0,"solutions":0,"comments":0},"solveRate":null,"publishedAt":"2026-11-27T08:22:25.519Z"}],"attachments":[],"hasCode":true,"repoUrl":null,"series":[{"slug":"solution-architect-path","title":"Jak zostać Solution Architectem","items":[{"slug":"solution-architecture","title":"Kim jest Solution Architect? Rola, odpowiedzialność i mapa kariery","current":false},{"slug":"sa-daily-duties","title":"Dzień z życia Solution Architecta: obowiązki, rytm pracy i priorytety","current":false},{"slug":"sa-requirements-and-nfr","title":"Wymagania i NFR: jak wyciągnąć od biznesu liczby, które naprawdę projektują system","current":false},{"slug":"sa-hld-step-by-step","title":"HLD krok po kroku: od pustej kartki do zaakceptowanej architektury","current":false},{"slug":"hld-complete-example","title":"Kompletny HLD na przykładzie: sieć ładowarek VoltGo – dokument, diagramy, ADR i narzędzia","current":false},{"slug":"poc-guide","title":"PoC, spike, prototyp, MVP – jak zaplanować i przeprowadzić PoC (z działającym przykładem)","current":false},{"slug":"sa-decisions-and-adr","title":"Decyzje architektoniczne i ADR: jak wybierać, liczyć kompromisy i zapisywać „dlaczego”","current":false},{"slug":"sa-integrations-and-contracts","title":"Integracje i kontrakty: API, zdarzenia i zależności między zespołami bez niespodzianek","current":true},{"slug":"sa-security-and-operations","title":"Bezpieczeństwo i operacje w projekcie: STRIDE, OAuth2, SLO i runbooki","current":false},{"slug":"sa-estimation-cost-tco","title":"Szacowanie, koszty i TCO: ile to kosztuje i ile serwerów naprawdę potrzeba","current":false},{"slug":"sa-governance-and-reviews","title":"Governance i przeglądy: jak obronić projekt przed Architecture Review Board","current":false},{"slug":"sa-migrations-as-is-to-be","title":"Migracja AS-IS → TO-BE bez przestoju: architektura przejściowa, strangler fig i CDC","current":false},{"slug":"sa-how-to-become","title":"Jak zostać Solution Architectem: kompetencje, ścieżka, rozmowa i pierwsze 90 dni","current":false}]}],"prev":{"slug":"sa-decisions-and-adr","title":"Decyzje architektoniczne i ADR: jak wybierać, liczyć kompromisy i zapisywać „dlaczego”"},"next":{"slug":"sa-security-and-operations","title":"Bezpieczeństwo i operacje w projekcie: STRIDE, OAuth2, SLO i runbooki"},"featured":false,"authorCard":{"id":"6b08bd2e80884893657cc8cf","name":"Redakcja Art of Devs","avatar":null,"handle":"redakcja","headline":"Wzorce projektowe · Architektura · AI i LLM","community":false,"reputation":{"points":3900,"level":{"key":"mentor","label":"Mentor"}},"articles":104,"skills":[{"key":"typescript","title":"TypeScript","level":5,"levelLabel":"Autorytet","articles":90},{"key":"dotnet","title":".NET","level":5,"levelLabel":"Autorytet","articles":61},{"key":"python","title":"Python","level":5,"levelLabel":"Autorytet","articles":59},{"key":"java","title":"Java","level":5,"levelLabel":"Autorytet","articles":46}]}}