Generate main controller