Skip to content

[Feature] Integration with DbGate and WhoDB applications #415

@jakoss

Description

@jakoss

Related to an existing integration?

No

Existing integration

No response

Overview

DbGate and WhoDB are small and fast web-based database management tools (think of PgAdmin, PgWeb, or Mongo Express). The advantage over mentioned applications is that both DbGate and WhoDB can support multiple databases.

My scenario

I'm currently working on a huge microservice system. We have some microservices based on Mongo, other on Postgres, but (since it's partly white-label tool) we want to support more SQL variants like SqlServer and Oracle soon. Also we use redis for caching and few message brokers. For all our local development needs we are using Aspire and it's being super helpful.

After we hit a 20 microservice mark we spot one common issue people had - computers started running out of memory. The amount of containers was getting too big, CPUs were getting swetty, annoying stuff. Aspire is great, so we could run some containers optionally limiting the issue.

But there is one issue that is still there and we did not had a great solution for that - until now. The problem - each database needs to have it's own management ui. Need to spin postgres? Add PgWeb to that (PgAdmin is so slow we gave up on it very fast). Want to add Mongo? Sure, add express. Redis? Redis insights come in. So we have this issue where number of containers is growing with no gain. Each of those tools have the same reason to exists - manage data.

Hence the idea to use DbGate or WhoDB. Effectively we are able to replace all those additional containers with a single one. We can manage the data in a single place. We are using it a single day so far and already love it.

Why both?

DbGate and WhoDB have the same purpose, but different set of features:

DbGate seems to be more mature and have a lot more database supported

WhoDB looks and feels much better, and have some interesting AI features (even supporting local LLMs)

Supporting both is not a big overhead, since the implementation will be very similar.

Moving forward I will describe API from a perspective of DbGate, but the WhoDB API will be pretty much identical to use.

Usage example

Nuget

Most of the implementation will live in the CommunityToolkit.Aspire.Hosting.DbGate.Core, but user won't be using that. Instead, there will be bunch more nugets for each database user wants to use, for example:

  • CommunityToolkit.Aspire.Hosting.DbGate.Postgres
  • CommunityToolkit.Aspire.Hosting.DbGate.MySql
  • CommunityToolkit.Aspire.Hosting.DbGate.MongoDB
  • CommunityToolkit.Aspire.Hosting.DbGate.Redis
    etc

Those packages are necessary, because if we just integrate with everything in a single nuget - user will bring whole bunch of dependencies with DbGate, which, we probably can all agree, is a bad thing :)

API

API will be very simple. Sample usage for 3 databases can look like this:

var postgresServer = builder.AddPostgres("postgres");
var database1 = postgresServer.AddDatabase("database1");
var mongoDbServer = builder.AddMongoDB("mongodb");
var database2 = mongoDbServer.AddDatabase("database2");
var redis = builder.AddRedis("redis");

builder.AddDbGate("dbgate")
    .WithDbReference(database1)
    .WaitFor(database1)
    .WithDbReference(redis)
    .WaitFor(redis)
    .WithDbReference(database2)
    .WaitFor(database2);

I think pretty much everything is self-explanatory besides the WithDbReference. Why not keep with WithReference?

Let's say user wants to add MySql to that. He adds server, then database and then adds WithReference(mysqlDatabase) to the AddDbDate. The compiler won't shout, but.. nothing will happen. Because user forgot to add the CommunityToolkit.Aspire.Hosting.DbGate.MySql NuGet. I think introducing new function will help avoiding mistakes like this.

Under the hood all references will be translated to bunch of environment variables that then will be used by DbGate to populate connections.

What do you all think?

Breaking change?

No

Alternatives

An alternative is to keep using dedicated database management tools for each database

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

Labels

integrationA new .NET Aspire integration

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions