Extract mongodb and api to separate files