Couldn't you just buy a premade door sensor? They're like $12 and will have an app that notifies you when the door is opened.
https://www.amazon.com/Door-Sensor-Window-Batteries-Compatible/dp/B0BJ343N7F/