how to make randomly generated caves and structures for starbound type game?

If anyone has played starbound, they know there are dips and caves in the ground, and underground chests. What is the generality of a method I could use to do this?

You’re looking to procedurally generate terrain; check out this question’s answer for some starting points: