These are referred to as 'prefabs'. They're used a lot in roguelikes, and the community over at reddit.com/r/roguelikedev recently had a Q&A on this very subject, it's well worth a read here ( https://www.reddit.com/r/roguelikedev/c ... p_prefabs/ )
Your shopping list should be:
1. A way of writing prefabs to storage
It depends on how you want to build your world. If you can use tiles to build your world, brilliant - you can use a multi-line string to represent your prefabs. If not, you're in for a rockier ride which will likely involve writing a basic level-editor to save the correct metadata for you.
2. Storage device for holding your prefabs in your project
Again, assuming a tile-based world, I would use an array for this. Fill the array with a different prefab on each Z-index from (1).
3. A way of stitching them together into rooms
In its simplest form, this would probably look a lot like Primm's maze generating algorithm. ( https://en.wikipedia.org/wiki/Maze_generation_algorithm ) Essentially you start from a given point, and continue adding prefabs into vacant spaces in the world until it's large enough for you. As you go, connect each new prefab to an existing prefab placed before it. Et voila.
I am aware this is a vast over-simplification, but a full explanation would be... lengthy. Good luck!