I have heard many exchange works like, Holds all their users funds into the exchange main wallet not directly to their user's wallet. These exchange just provide a deposit address to their users for depositing BTC or ETH and their users are never given private keys. So when a deposit is done under any user's address, Its actually transferred into the exchange main wallet at the same time or at the time of selling coin? Selling coins to exchange does not cost any fee for miners?
I want to learn more regarding this matter, Can anyone redirect me to any link that can explain this in easy words and easy way to setup such wallet?
There is no "user's wallet" when you are using an exchange. What you might think is a "user's wallet" is actually the exchanges wallet. When you deposit any cryptocurrency into an exchange, you are not depositing to "your exchange address", you are depositing to an address owned by the exchange (thus part of the exchange's wallet) and the exchange promises to give you the same amount of cryptocurrency that you deposited to that address if you want to withdraw from the exchange.
When you buy or sell on the exchange, no actual transactions happen; they just update some entries in a database. No money is transferred anywhere; it is all held by the exchange in their wallet.