refactored single file into modules and added api routes