That exists: https://nostr.watch/relays/find
Ditto can import all relays from this API too:
deno task relays:sync https://api.nostr.watch/v1/online
Then they go into a big SQLite table (pic 1). The problem with this is that it’s centralized.
Instead, the “natural” way Ditto discovers new relays is by analyzing events, trying to find references to relays. If it finds one, it connects to it. (pic 2)
That can probably be abused, so in the future I’m planning to have a relay discovery flow where admins can review and manually approve any relays that have been discovered automatically: https://gitlab.com/soapbox-pub/ditto/-/issues/62

