refactored code to two modules -- one for API and another for web