How does app forking works exactly (ex: forkgram)? - eviltoast

More specifically, I’m thinking about forkgram, a telegram fork. I get that open source app make their code public therefore people can use it and build from it, but I thought it allowed for creating a separate app. Forkgram however still has all my chats so it must be able to connect to telegram servers and both apps must be somehow intertwined. Since telegram is only partly open sourced, I don’t understand how this is possible and why telegram would allow this?