How's the blockchain connected to a Bitcoin Wallet I am thinking about buying some bitcoin buy first I want to understand some theoretical aspects of the technology behind it.

The wallet holds my private keys right? But how s me wallet connected to the blockchain?

Thanks,
Blockchain is the state of the bitcoin network. It is unanimously accepted as the correct state. 

Each bitcoin full node stores its own copy of the blockchain. These copies can rarely differ in couple of last blocks, so bitcoin full nodes can have slightly different view of the same blockchain (only of couple of last blocks though). By adding new blocks on the end of the blockchain (this happens every 10 minutes) any possible differences in blockchain copies resolve (full nodes come to consensus about the state of the blockchain). Bitcoin full nodes are connected in a network and exchange their copies regularly.

The wallet is either implemented as part of the bitcoin full node application or as a separate small application that is then connected via Internet to some bitcoin full node. 

Bitcoin wallet must be able to:

a) Generate public address and respective private key.

b) Calculate the balance of public addresses you control. To do this bitcoin wallet must read one small part of the blockchain, the one that holds unspent transactions (and possibly a pool of unconfirmed transactions - the transactions that are broadcasted but not yet added on the blockchain).

c) make a transacion using coins from your public addresses, sign those coins with private keys related to public addresses used, and broadcast this transaction to the bitcoin node that will spread this transaction to other full nodes in bitcoin network. This transaction will eventually end on the blockchain.



So b) requires reading data stored on the blockchain, and c) requires sending new data on the blockchain. Remember that the blockchain is a copy in a bitcoin full node. So the wallet reads from and writes to the blockchain by either communicating internally when being part of the full node application or communicating through Internet with some full node. 

Full nodes communicate between themselves to spread and gather blockchain changes.