I've noticed that if no heroes and defense modules are present in the room with the Artifact, it doesn't get attacked. Is this just luck or it's the way to go?
Most monsters will ignore the artifact, which is basically considered a large module. Only certain monsters that are dedicated to attacking large modules directly will attack it. However monsters that deal area damage can also destroy it, for example the monsters that explode near small modules/heroes will also damage the large one. Early game there are few to zero module attacking enemies, with ones that attack the small modules more likely to show up before your first encounter with the ones that attack large modules. So yeah, so far it's likely just luck. You will eventually see them be focused down by certain mobs especially towards the later end of a run.