Some basic structure, still needs refactoring, to make this more testable, adding tests. For that I need to have postgress runing locally.