can't reply to your question so doing it here.
the code is OS so you can look it up :)
the idea is this
- detect table relations based on FK
- for each view check where each column comes from (view column usage)
based on the info above you know all the relations in the system, even view to view
also there is a way to do it in a single query but that is not yet implemented in postgrest