Add basic server structure

It's working but it's ugly and needs so much refactoring, with pinches
of OOP.