Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Top-level source/documentation directories: `docs`, `src`.
- `src/main/mule/eip/<pattern>/`: one folder per EIP pattern, holding its flows and its own global elements (object stores); `src/test/munit/eip/<pattern>-test-suite.xml` is its suite.
- `src/main/mule/<series>/`, `src/test/munit/<series>/`, `docs/contracts/<series>/`: 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).

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
71 changes: 71 additions & 0 deletions docs/architecture.md
Original file line number Diff line number Diff line change
@@ -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 (`/<principle>/before/...` and `/<principle>/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.<method>` 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/<principle>/` | `<principle>-before.xml` and `<principle>-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.