How can a website detect when bitcoins have been deposited? If I want to have a website that can credit bitcoins to a user's account when they deposit bitcoins, how can I have the website automatically detect when the bitcoins have been received into to the wallet address given to that customer (belonging to me), and consequently update the website to reflect their new balance automatically - without having to manually check my wallet.

I'm not interested in using existing payment services for this, but rather I'm interested in the coding principles required.
If you're going to be running bitcoind, what you're looking for is the walletnotify configuration setting in bitcoin.conf.

If you enable walletnotify, you run an app like curl to post the data to a web page.  The data that you'll receive is the transaction id of an incoming transaction for an address in your wallet.  From that you can use bitcoind's json-rpc commands to get the address that received the transaction as well as other transaction details like the amount.

Walletnotify will execute twice.  It will execute the first time that a transaction appears, and then will get called again when a block is published that includes the transaction. You can use either or both of these notifications depending on your needs.

This is the curl command that I use in walletnofify.  You should make any changes for your own environment.

curl -X POST -H "Content-Type:application/json" -d '{"transactionId":"%s"}' http://127.0.0.1:81/api/v1/transactions