Refactor code and group api + manage databases