refactor api-stub

Refactor the api-stub to support dynamic segments and a slightly more real backend.