Cyber-Physical Systems (CPS) are the complex systems that control and coordinate physical infrastructures, which may be geographically apart, via the use of Information and Communication Technology (ICT). One such application of CPS is smart microgrids. Microgrids comprise both power consuming and power producing infrastructure and are capable of operating in grid connected and disconnected modes. Due to the presence of heterogeneous smart devices communicating over multiple communication protocols in a distributed environment, a system architecture is required. The objective of this paper is to approach the microgrid architecture from the software and systems’ design perspective. The architecture should be flexible to support various multiple communication protocols and is able to integrate various hardware technologies. It should also be modular and scalable to support various functionalities such as island mode operations, energy efficient operations, energy trading, predictive maintenance, etc. These requirements are the basis for designing the software architecture for the smart microgrids that should be able to manage not only electrical but all energy related systems. In this work, we propose a distributed, hybrid control architecture suited for microgrid environments, where entities are geographically distant and need to operate in a cohesive manner. The proposed system architecture supports various design philosophies such as component-based design, hierarchical composition of components, peer-to-peer design, distributed decision-making and controlling as well as plug-and-play during runtime. A unique capability of the proposed system architecture is the self-similarity of the components for the distributed microgrids. The benefit of the approach is that it supports these design philosophies at all the levels in the hierarchy in contrast to a typical centralized architectures where decisions are taken only at the global level. The proposed architecture is applied to a real system of 13 residential buildings in a low-voltage distribution network. The required implementation and deployment details for monitoring and controlling 13 residential buildings are also discussed in this work.