refactoring rest api and add models