Thank you!
the gravity simulation part is very straightforward, in godot c# it looks something like this:
https://gist.github.com/gabtorok/a13c8522c4b17f8fe020403dd82e62ba
Bit crude, but it's fast enough, basically it's high-school physics: to calculate the acceleration for each object I calculate how every other object's gravity affects them.