Skip to content

Conversation

@RoRoche
Copy link

@RoRoche RoRoche commented Aug 2, 2025

Hello,

This Pull Request includes:

  • Contracts to define an ADR and its content
  • Concrete implementation in Markdown using toString method overriding
  • Unit test of a Markdown ADR generation

Resolves #1495

Thank you for reviewing.

Regards.

@RoRoche RoRoche force-pushed the feature/add-adr branch 3 times, most recently from 3dcf31a to f770ab3 Compare August 3, 2025 00:06
@hankem
Copy link
Member

hankem commented Aug 3, 2025

Thanks for your contribution! While I think it's nice to be able to define MADRs programmatically, this feature seems to be quite independent of ArchUnit. (The only dependency of your classes on ArchUnit is the com.tngtech.archunit.PublicAPI annotation...) Why do you think it should be in ArchUnit and not a separate library?

@RoRoche
Copy link
Author

RoRoche commented Aug 3, 2025

ArchUnit rules reflect key architectural decisions, but the rationale behind those decisions is typically buried in code or comments.

This feature would allow automatic generation of Markdown Architecture Decision Records (ADRs) directly from ArchUnit rules, capturing why a rule exists—not just what it enforces.

Benefits:

  • Makes architectural intent and context explicit
  • Promotes consistent and visible decision-making
  • Helps teams trace rules back to their original reasoning
  • Encourages writing meaningful descriptions alongside rules

This would bring ArchUnit closer to being not only a verification tool, but also a lightweight architectural documentation aid.

What is your mind about this explanation?

@hankem
Copy link
Member

hankem commented Aug 3, 2025

I fully agree that ArchRules should document the reasoning for the constraints they encode. 👍
(It was probably me who suggested to add the because clause to ArchRule in the early days of ArchUnit...)

This feature would allow automatic generation of Markdown Architecture Decision Records (ADRs) directly from ArchUnit rules

I see that you could use an adr in

ArchRule = /* rule definition */.because(adr.toString());

(which you can already do with any adr defined outside of ArchUnit),
but I didn't see how you could generate an ADR from an ArchUnit rule. 🤔

@RoRoche
Copy link
Author

RoRoche commented Aug 3, 2025

Yes, you're right, it would be more complicated than I think to generate ADR from ArchUnit rule 😢

RoRoche added 17 commits August 3, 2025 10:27
Signed-off-by: Romain Rochegude <[email protected]>
Signed-off-by: Romain Rochegude <[email protected]>
Signed-off-by: Romain Rochegude <[email protected]>
Signed-off-by: Romain Rochegude <[email protected]>
Signed-off-by: Romain Rochegude <[email protected]>
Signed-off-by: Romain Rochegude <[email protected]>
Signed-off-by: Romain Rochegude <[email protected]>
@RoRoche
Copy link
Author

RoRoche commented Aug 9, 2025

But you are right, the typical use case I target is the following:

ArchRule = /* rule definition */.because(adr.toString());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use an Architecture Decision Record (ADR) as a reason for a ArchRule

2 participants