If you can run gramps, you already have the Python source on your computer. The first time you run Gramps, it is the slowest start. That’s because it compiles each Python module into a __pycache__ for faster future use. The (free) addons are the same. You are welcome to hack any part of the program that doesnt suit your liking.
Most likely, you will be tweaking plugins: reports, import/export, gramplets, tools, filter rules… either built-in or add-on. For all of these, you can quickly located the module filepath and filename using the info section of Plugin Manager Enhanced addon. In debug mode, it even has a shortcut button to load the module into whatever editor you have associated with .py file type.
If you go to the Help category in this forum, there is a Manual subcategory. Pinned near the top is a thread with links to the various resources. Including a Developers Guide to the Gramps API in a Sphinx doc management system. It gives good insight into the parameter passing. And the “Simple” library offers a framework for GUI (tables, print formatting) and database access. If you want to bypass the GUI entirely, there are plugin shells for SQL queries, Python scripts and more. The SuperTool (contributed by the Isotammi group of Finland) does most of the include necessary to work with data in the active category. And its Help catalog is excellent. As is the collection of sample scripts.
You would do well to download the PDFs of the User Guides: for Gramps and for the Addons. If is FAR easier to search those 2 files than the thousands of Wiki pages.
Regarding AIs, I was alerted today when trying to submit a Gramplet update that the rules changed a bit again. But that might have been triggered by my use of GitHub’s Copilot. Apparently Copilot is unlikely to generated code compatible with the GPL licensing. So now I have to learn what will be necessary to become compliant.