Disclaimer: complex apps only
Repository pattern is hard
Follow Arkency blog post for a starting point
but keep in mind that this is not a perfect solution