Hi Devs,
I’m happy about the progress the Gramps ecosystem is making this year. Lots of improvements in Gramps itself and also in Gramps Web, plus Gramps Web API (the REST API Gramps Web uses as backend) is finally growing the ecosystem that was intended from the start. In addition to Gramps Web and the Web Sync Addon, there is now also Gramps Connect, GrampsWebApiDb, and several Gramps MCP projects building on it.
Progress on Gramps Web API is accelerating by a concurrence of ever growing AI coding capabilities and increasing popularity of Gramps Web (more than 2000 deployments, double the Github stars of Webtrees), both effects increasing the number of contributors. For illustration, the last four releases of the Gramps Web frontend each had two new first-time contributors!
What I’d like to discuss against this background is how to better define the scope of Gramps Web API vs. what I call Gramps core (essentially, the gramps.gen library and the core database plugins). Gramps Web API essentially has two separate roles to fulfill:
- Wrap Gramps’ genealogical and database functions in a way to make them accessible via HTTP requests
- Provide scaffolding that is needed for a web-based application - authentication, permissions, background tasks, search indices, caching, etc.
What was never the goal was to reimplement the genealogical and database functionality in Gramps core - in fact, I’ve always seen it as the big plus of Gramps Web API compared to other web-based genealogy apps that we are building on a well-tested foundation and can focus on the two points above. What I absolutely do not want is for Gramps Web API to become a web wrapper around a Gramps fork!
While that sounds good in theory, in practice there are parts of Gramps core that don’t/didn’t work well for a web-based app; for instance, there used to be for-loops over SQL queries that were reasonably fast on SQLite-on-HDD, but prohibitively slow when used with a database over the network. Since Gramps Web API has always had a very different release cadence than Gramps core, in the past we’ve often patched things in Web API, not always contributing the changes/improvements back to Gramps core. Examples include Web API’s ModifiedPrivateProxyDb or CachePeopleFamiliesProxy, which are not much more than ugly monkey-patches.
The problem with each performance optimization or feature addition that shadows one of Gramps core’s database or genealogy functions is that it leads to drift, which generates a maintenance burden and potential security risks. I noticed that already any time there was a major/minor version bump in Gramps and I had to adapt the patches accordingly.
Triggered by the fantastic efforts of @dsblank to remove performance bottlenecks in both Gramps core and Gramps Web API, I think it’s time to formally define the scope of the two libraries and to define a process to upstream improvements from Gramps Web API to Gramps core.
Ideally, I think all database specific code should live in Gramps core, except for the parts that are Web API specific (that is, not needed for Gramps desktop). As for defining what is Web API specific, I think we shouldn’t be too strict: for instance, Gramps desktop might not need the get_dbname or get_summary methods on PrivateProxyDb, but adding them doesn’t hurt and doesn’t require a lot of maintenance (compared to patching the class in Web API just for this purpose).
What is more important, in my mind, is to define how changes that should live in Gramps core should be contributed to Gramps Web API, without having to wait for a new minor release of Gramps core. Here are the requirements I think such a process should have:
- It should not require the Gramps project to change its release cadence or development process
- It should allow timely adoption of changes by the Gramps Web API project
- It should not inflict an undue maintenance burden on the Gramps core maintainer or the Gramps Web API maintainer
- It should not inflict an undue bureaucratic burden on the contributor or the maintainers
- It should ensure long-term drift between Gramps Web API and Gramps core is minimized for database-access and genealogical functions
Here is the process I propose to meet those requirements:
- Contributor opens a proposal (could be in Discourse or the Web API repo - let me know what makes most sense in your opinion) requesting an improvement to a database or genealogical function that benefits Gramps core and Gramps Web API
- The Gramps core maintainer and the Gramps Web API maintainer independently confirm they agree with the proposed change. If the Gramps core maintainer disagrees, the change can still be reviewed as a normal contribution to Gramps Web API.
- The change is implemented as a patch of the current Gramps core version and contributed to a new module,
gramps_webapi.future_gramps. A PR is opened against the next Gramps minor version. - The change goes live in the next Gramps Web API minor release
- When the change in Gramps core is merged and released, the patch in Gramps Web API is removed by the original contributor.
I think this process would be better than things we did in the past - such as monkey patching without upstreaming at all (my own sins) or moving changes into an external library to keep them out of Web API (as we did in PR 913), because neither of those prevent the drift that I’d like to minimize.
One possible issue with the approach could be that the patching in step 4 might not be feasible if the change in core is too extensive. But I suspect this wouldn’t be a problem most of the time.
Let me know what you think.