split client into a repository/factory/connection model