Restructure api rest, rpc & model