There is an open source project here:
https://github.com/co-cell/ccm that attempts to provide a system for doing the kind of coordination between independent community networks. It is based on Osmocom under the hood, but uses the older osmo-nitb stack (before components were split). The networks are able to operate independently offline, and use a combination of sip call routing as suggested by Neels above, SMPP, and a web api to synchronize usage when connected to the cloud for centralized billing and to interconnect through the cloud for community to community, or community to public voip network communication. The project was originally run by the Telecom Infra Project, but was abandoned by them last year after they moved to a new (unfortunately private) internal tool
https://github.com/facebookarchive/CommunityCellularManager . CCM is still actively used by the PCARI Vbts project (
https://www.up.edu.ph/index.php/up-globe-sign-moa-for-village-base-station-project/) with a number of local communities in the Philippines, and they run and maintain their own instance of the CCM cloud. It might be something to look at as a potential starting point, or something to learn from if you want to make different architectural decisions when connecting the networks!
-Matt J.