move DB factory out of course repo