diff --git a/AGENTS.md b/AGENTS.md index d649640..e346753 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -45,6 +45,7 @@ Top-level source/documentation directories: `docs`, `src`. - `src/main/mule/eip//`: one folder per EIP pattern, holding its flows and its own global elements (object stores); `src/test/munit/eip/-test-suite.xml` is its suite. - `src/main/mule//`, `src/test/munit//`, `docs/contracts//`: flows, MUnit suites and contracts of one series (`solid`, `eip`). - [README.md](README.md). +- [docs/architecture.md](docs/architecture.md): keep it in step with a change of structure or CI. - [mule-artifact.json](mule-artifact.json). - [pom.xml](pom.xml). diff --git a/README.md b/README.md index a04cdc1..d42bfef 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ A catalogue of design and integration patterns applied to Mule 4, one series at Everything runs in one Mule application and needs no external systems: ERPs, databases and payment providers are simulated with synthetic data, so it runs anywhere. +## Documentation + +- [Architecture](docs/architecture.md): context, main flow, module map and CI. + ## Run Requirements: Java 17, Maven 3.9+, Mule runtime 4.9 (Anypoint Studio or a standalone runtime). diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..9fa7424 --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,71 @@ +# Architecture + +One Mule 4 application that holds runnable examples of design and integration patterns, one folder per series. External systems are simulated inside the application with synthetic data. + +## Context + +```mermaid +flowchart LR + Client[requests.http, curl or MUnit] -->|HTTP, port 8081| App[Mule application] + App --> Solid[SOLID flows] + App --> Eip[Integration pattern flows] + Solid --> Sim[Simulated systems inside the app] + Eip --> Sim + Eip --> Store[(Object stores)] + Config[config/app.yaml] -.-> App + Articles[Articles on brunosouzas.com] -.->|cite paths and endpoints| App +``` + +## Main flow + +Each SOLID principle has a `before` flow, which breaks it, and an `after` flow, which follows it, on separate paths (`//before/...` and `//after/...`). The dependency inversion example, `after` version, shows configuration choosing an implementation: + +```mermaid +sequenceDiagram + participant C as Client + participant F as dip-after-get-order + participant R as Repository sub-flow + participant B as dip-after-apply-order-rules + C->>F: GET /dip/after/orders/{orderId} + F->>R: flow-ref named by orders.repository + alt order found + R-->>F: order in the canonical shape + F->>B: apply the business rule + B-->>F: order with canCancel + F-->>C: 200 + else unknown order + R-->>F: APP:NOT_FOUND + F-->>C: 404 from the global error handler + end +``` + +The open/closed example uses the same idea: `payment.flow.` in `app.yaml` names the sub-flow of each payment method. + +## Module map + +| Path | Content | +|---|---| +| `src/main/mule/global.xml` | HTTP listener, configuration properties and the global error handler | +| `src/main/mule/solid//` | `-before.xml` and `-after.xml` for `srp`, `ocp`, `lsp`, `isp` and `dip` | +| `src/main/mule/eip/` | One folder per runnable integration pattern, plus `eip-global.xml` (the requester that calls this same app) | +| `src/main/resources/config/app.yaml` | Port, OCP payment routing, DIP repository choice and the EIP settings | +| `src/main/resources/dwl/` | DataWeave modules of the translation examples | +| `src/test/munit/solid/`, `src/test/munit/eip/` | MUnit suites, one per principle or pattern | +| `docs/contracts/solid/` | RAML types of the LSP and ISP examples; documentation, not loaded by the app | +| `requests.http` | Sample requests | + +The global error handler answers `APP:BAD_REQUEST` with 400, `APP:NOT_FOUND` with 404, `APP:CONFLICT` with 409, `APP:SERVICE_UNAVAILABLE` with 503, `APP:COMPENSATION_FAILED` and any other error with 500, as JSON. + +What each pattern example does is described in the [README](../README.md). + +## Build, test and CI + +[`.github/workflows/ci.yml`](../.github/workflows/ci.yml) runs on every pull request and on pushes to `main`: Java 17 and a checksum-verified Maven 3.9.11, then `mvn -B -ntp clean package -DskipMunitTests`. It uses no secrets. + +CI does not run MUnit, which needs the Mule Enterprise runtime and credentials of the MuleSoft Enterprise repository. Run `mvn clean test` locally; the POM fails the build below 80% application coverage. + +Nothing is deployed. + +## Decision records + +None in this repository.