Extracting client code into separate module.

- renamed protocol -> api