dotnet / aspire

Tools, templates, and packages to accelerate building observable, production-ready apps
https://learn.microsoft.com/dotnet/aspire
MIT License
3.95k stars 485 forks source link

Graph view of resource relationships #2595

Open JamesNK opened 9 months ago

JamesNK commented 9 months ago

I think it would be pretty useful to see what resources a resource is referencing in the dashboard.

builder.AddProject<Projects.MyFrontend>("frontend")
       .WithReference(basketService)
       .WithReference(catalogService.GetEndpoint("http"));

In the example above, the frontend resource would have two references. A reference would have:

The resource model today doesn't have references, just the env vars used by the app. You could try to reverse engineer references by looking at environment variables, but it would be a pain in the butt. It is much easier to model it explicitly and display values from the model.

Edit: We could also display the reverse. What resources reference the current resource, e.g. basketservice is referenced by frontend and apigateway.

In the UI, call it dependencies and used by? That's what NuGet does:

JamesNK commented 9 months ago

Note: I looks like the app model doesn't have this information (just env vars are added). Edit: Actually, EndpointReferenceAnnotation is added sometimes and other times (for connection strings?) it isn't.

It would need to be added to the app model, returned in the resource service (I added a comment to https://github.com/dotnet/aspire/issues/2415), the added to the resource detail UI.

JamesNK commented 9 months ago

cc @davidfowl @DamianEdwards

davidfowl commented 9 months ago

Here is the original issue and PR for modeling dependencies:

This is the latest PR: https://github.com/dotnet/aspire/pull/2594. The goal is to move to a richer way of modeling references in things like environment variables and connection strings. Are you thinking we only show connection string references and endpoint references or more?

davidfowl commented 9 months ago

Also related https://github.com/dotnet/aspire/issues/1436

davidfowl commented 9 months ago

cc @IEvangelist was interested in this as well.

IEvangelist commented 8 months ago

Yeah, I had imagined that we should display a visual representation of the network topology.

image

This was drafted up with mermaid, assuming that we might want to use that in the dashboard. I wrote a Razor library POC to test out using mermaid.js, with the idea that it might be used for something like this. Ideally, we could either query the App Model or maybe even the manifest. With the dependency graph and some other runtime data, we could create a mermaid chart and render it like that. All of this was just an idea though...

dahlsailrunner commented 4 months ago

Love this thought / direction and it would be super helpful!!!

JamesNK commented 1 week ago

Remaining work here is to add a graph view of resource relaitonships.