Abstract common app code

@lingyan @redonkulus @vijar