Nowadays, integration of more renewable energy resources into distribution systems to inject more clean energy introduces new challenges to power system planning and operation. The intermittent behaviour of variable renewbale resources such as wind and PV generation would make the energy balancing more difficult, as current forecasting tools and existing storage units are insufficient. Transmission system operators may withstand some level of power imbalance, but fluctuations and noise of profiles are undesired. This requires local management performed or encouraged by distribution system operators. They could try to involve aggregators to exploit flexibility of loads through demand response schemes. In this paper, we present an optimal power flow-based algorithm written in Python which reads flexibility of different loads offered by the aggregators from one side, and the power flow deviation with respect to the scheduled profile at transmission-distribution coupling point from the other side, to define where and how much load to adjust. To demonstrate the applicability of this core, we setup a realtime simulation-based test bed and realised the performance of this approach in a real-like environment using real data of a network.