Installing an Unifi controller on a Raspberry Pi seems like a straightforward task until you notice the section with system requirements.
The software requires a MongoDB version before 4.0. The last version that satisfies this is 3.7.9 which is almost four years old at the time of writing. You may find old versions packaged on the MongoDB website or in other repositories but certainly not for ARM. The second problem is that MongoDB dropped 32-bit support in version 3.4 so the latest we can actually use is 3.2.22 (also 4 years old).
In the end I was unable to find a build of MongoDB 3.2 that could run on a Pi which leaves only the option of compiling from source. This is what I ended up doing, it required lots of trial and error  before it succeeded. To (hopefully) save someone else time I put up the final Debian package for download.
Raspberry Pi OS Lite 11 (bullseye)
Add the Unifi repository
Install required packages.
Create a mongod wrapper script
Enable and start the Unifi service:
systemctl enable --now unifi
Wait a while, it can take about 5 minutes until the controller is reachable at
Not actually using a Raspberry Pi?
On a normal amd64 Debian system this whole ordeal gets much simpler:
Unifi installation works as described as above
mongodb-org-server_3.6.23_amd64.debcan be downloaded from the MongoDB website and runs out-of-the-box
OpenJDK 8 can be pulled from AdoptOpenJDK's repo since it's not available on recent Debian versions anymore
As of Unifi 7.3 the JDK support has changed to version 11, so you don't need a separate repo anymore.