rrousselGit / riverpod

A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.
https://riverpod.dev
MIT License
5.82k stars 888 forks source link

Feature to automatically create a Mermaid.js diagram showing all providers and relationships #3442

Closed colin-young closed 1 month ago

colin-young commented 1 month ago

For any moderately complex data model, it's very easy to lose track of exactly what providers you have created and how they relate and depend on each other. Being able to automatically generate a class diagram in Mermaid.js from the code would help manage this complexity and produce a useful documentation artifact that would be kept up-to-date automatically.

Some thoughts: using ref.watch/read/listen and @riverpod annotations would probably be the easiest path. It would also have the side-effect of also detecting widgets that depend on each provider. This would help identify duplicate/similar providers and assist in optimizing data access code.

rrousselGit commented 1 month ago

This is already in progress: https://github.com/rrousselGit/riverpod/tree/master/packages/riverpod_graph

colin-young commented 1 month ago

Excellent!

colin-young commented 1 month ago

And my project breaks riverpod_graph with Bad state: No element. Let me know if you want me to open a new issue and provide details.

rrousselGit commented 1 month ago

It's in progress afterall.

colin-young commented 1 month ago

It's in progress afterall.

Yes, although I figure it's always good to have examples of how to break it. Assuming you're not already able to do so :)

I'll probably take a peek at the code and try to debug (for my own education) to see if I can figure anything out. But I can't give any timeline when I might get to that.