Sharing PS4 games between 2 consoles
Solution 1:
According to this site, you are able to do what you described for you and your friend to share games. However, in order to play your own games, you will be required to have an active connection to the internet at all times, which is less than ideal.
However, because your own PS4 will not be registered as your primary PS4, no one besides you can access your games on your PS4. However, everyone who has access to your console will be able to play your friend's games, since that would be the account with your PS4 listed as its primary. Likewise, anyone that plays on your friend's PS4 could access games that you have purchased on your account.
Savefiles are kept on a per-account basis, so any games that your brother plays on his account will not affect you or your friend's savefiles in any way.