Restructuring app to use entities and ports