Refactor api app configuration and setup