Deposit flow, user balances
These are indeed hard problems, but luckily already served by BTCPay Server, with extra features like lightning payments: https://github.com/btcpayserver/btcpayserver.

You can just run it via the included docker recipe (https://github.com/btcpayserver/btcpayserver-docker) and communicate with it via its API.

Or if you really want to reimplement the nitty gritty stuff yourself, look at its code or architecture documentation.