I'm not sure what level of detail you are looking for, but in simple terms they have a database that keeps track of how much of each coin is owned by each account. When you deposit USDT, they credit your account. When you withdraw USDT, they debit your account.
I assume that exchanges use proprietary software, but you might try looking at the open source payment processor
BTCPay ServerThank you for the reply, I was wondering if there's a pre-built system out there ready to be played with. I've looked into
btcpayserver but unfortunately it's BTC only.