Controlling access to your source code will vary depending on where you are hosting your code and what version control system you are using. You would have to consult the documentation associated with your tools.
However, restricting access to pieces of a system that must be integrated to be delivered is the opposite of what you want to do to streamline your workflow and allow the team to move faster. By restricting people to only viewing and editing part of the code, they will have to document the interfaces, implement against the documented interface, and add additional steps to integrate and test at those interfaces. It is much faster to have a single team that is able to view, edit, build, and test the entire system without needing to communicate via documents when they need to share information.