How to define common behaviour for umbrella apps

I split an app in multiple umbrella apps for domain separation.
For having a specific example let’s say that I have an API (phoenix) app and an SERVICE (db) app.
The api will call services from db app. If I call ServiceModule.service_name(params) then it’s clear and simple to do. But I can not swap the service with a fake one during testing and neither can I replace it with a different implementation.

What I want to do is to make the service app like a plugin, interchangeable. This means that I want to define a behaviour for this app, a specification. Then the service app will implement this behaviour.
My question is where do I define this behaviours? If I define them in service app then they are nor reusable by other service implementation. I need another umbrella app just to define behaviours?

I hope my question is clear.

You could write a ‘core’ app / library that the other libraries depends from.

Then in the other apps you’d add it as a dependency:

defp deps do
  [{:core_lib, in_umbrella: true}]