Nextcloud can do this and replace a bunch of other google services in the process.
Looking at what you said so far though I am not entirely sure if you want to go down the route of self hosting yet. Which is okay, it involves a lot of work and knowledge to do right. Something you might not want to risk your contacts for if you are still learing. There are services that provide nextcloud hosting. Personally I am using Hetzner, a Germany based hosting provider: https://www.hetzner.com/storage/storage-share
Nextcloud can do this and replace a bunch of other google services in the process.
Looking at what you said so far though I am not entirely sure if you want to go down the route of self hosting yet. Which is okay, it involves a lot of work and knowledge to do right. Something you might not want to risk your contacts for if you are still learing. There are services that provide nextcloud hosting. Personally I am using Hetzner, a Germany based hosting provider: https://www.hetzner.com/storage/storage-share
Edit:
I forgot to mention, you’ll also need to do some fiddling with your phone to sync things: https://docs.nextcloud.com/server/latest/user_manual/en/groupware/sync_android.html