change api to mongo and organize flask app