There’s a “Create Station” feature that might be what you’re looking for.
Additionally, for discovering new music, Apple Music has plenty of recommendations and curated playlists to check out. Like most machine-curated approximations of my taste, these never quite do it for me and I end up finding new music by exploring artists/producers/labels I’m interested in “by hand”.
But in any case, Apple Music is definitely a better choice over Spotify if you want to maintain a collection of personal media files while getting access to a big streaming catalogue and recommendations. If you use iCloud Music Library, your MP3s are cloud-synced to all your devices automatically. Spotify allows adding personal files, but it must be done manually per-device, so it’s quite a headache if you regularly listen to anything that isn’t available to stream (due to business, politics, or simply never having an official release).
You could patch something together using last.fm as the data source maybe, but I don’t think scrobbling to last.fm has been popular for many years at this point, which is going to severely limit the quality of generated playlists for newer music. Additionally, last I knew last.fm’s API was still XML based which makes it not so ergonomic to use in today’s JSON centric world.