Split source into api and cli frontend