what I have seen in the documentation for Bafang systems, is a mounting tray that is mounted below the top plane of a bike carrier. See:
Which is taken from this document:
https://bafang-e.com/uploaded/manual/BF-DM-C-BT%20C01-EN.pdf
I don’t know if such a solution would provide enough space...