Add routing and query generation