How to share internet with WiFiP2P

I want to make an app that is able to share the internet from one android device to other android device using WiFiP2P. The app I'm talking about should work like OpenGarden app on playstore.

I have figured out how to send text messages between devices using WiFiP2P.

After researching about how I can share the internet connection, I found that I need to create a VPN server on one device and connect to the server from the other device. But I'm stuck at this process as I can't seem to figure out the exact architecture of the code (where VPN is initiated and how are the data packets passed)

Please point me to some good resources or examples for hosting vpn server and connecting to it.