Initial draft solution - much could be refactored/changed, but given the nature of the exercise I think it's a good starting point inviting discussion.