The Internet of Things is expected to contribute to a ‘smarter world’ by connecting the physical to the virtual, i.e., enabling advanced knowledge engineering over the big data gathered about the physical world. However, such a promise comes along with high resource consumption, spanning the network, storage and computational resources, not to mention possible security and privacy threats. As a result, it tends to be admitted that the IoT smartness will not be accommodated at scale by a centralized cloud-based approach. Instead, the deployment of IoT systems needs to leverage a highly distributed system architecture, which optimizes the distribution of the computation-from the edge to the cloud-according to the unique business requirements in terms of financial cost, latency, availability, etc. Toward that goal, this paper introduces the LATTICE framework, which aims at taming the complexity of configuring edge-based IoT systems. LATTICE builds upon ontologies that have proven useful to characterize the constituents of IoT systems in the required domain-specific way. However, LATTICE also revisits the exploitation of ontologies-i.e., the formal description of the real world, spanning the physical and cyber entities-across the development life-cycle of the IoT systems. As a first evidence, this paper introduces an automated approach to the optimization of IoT system configurations at the edge, provided the ontological description of the target IoT system.