add db connection to server file  and refactor mongoose files