Documenting business logic

We are often implementing business logic in code. However, after a few years, the code becomes the canonical source of that logic, which can be a pain to read and modify.

To get around this, I suggest documenting the logic before writing the code. That way, you always have an updated reference when you need a reminder or you're making a change or extension.

I'm looking for tools or techniques to assist with this process.

Mermaid looks like a good option: https://knsv.github.io/mermaid/