Your question looks like a perfect fit for the Group module, which can be used to create collections of content (nodes) that can be accessed by sets of users and with variations of access levels, such as none, read only, edit, etc.
Have a look at the answer to "What are the alternatives for the Organic groups module?" for a brief introduction to the Group module.
For this specific question, here is a blueprint of how it could be used/configured:
- Group Type: Teams
- Group Roles (refer to "What are the various roles supported by the Group module?" for more details):
- Team Member (or whatever fits), used for those who have access to a Team's content.
- Groups: 1 such group for each team (simple as that ...).
- Optional (not sure if you want this): If a user creates a new group, then automatically assign the "Group Owner"-role to the user who created the group.
- Group permissions: grant permission to the user with role "Group Owner" to perform actions like "Add members" or "Invite members to join".
Special case: "If the coordinator were to change" (as in your question), then simply tune the permissions to grant the "Coordinator" role to another appropriate user (how easy can it be ...).
To use the Group module from within a custom module, start from its Development guide and/or have a look at its API for D7 or API for D8.
PS: Even though this question is related to D8, this answer applies for either D7 ...