Stiffened shells and plates are widely used in engineering. Their performance is highly influenced by the arrangement, or layout, of stiffeners on the base shell or plate and the geometric features, or topology, of these stiffeners. Moreover, modular design is beneficial, since it allows for increased quality control and mass production. In this work, a method is developed that simultaneously optimizes the topology of stiffeners and their layout on a base shell or plate. This is accomplished by introducing a fixed number of modular stiffeners, which are subject to density-based topology optimization and a mapping of these modules to a ground structure. To illustrate potential applications, several stiffened plates and shell examples are presented. All examples demonstrated that the proposed method is able to generate clear topologies for any number of modules and a distinct layout of the stiffeners on the base shell or plate.