Refactor backend structure

by storing route logic into controller