Well first start with setting up a calibre development environment
https://manual.calibre-ebook.com/develop.html
Then understand the existing calibre plugin framework, maybe create a small plugin as feet wet exercise.
Then familiarise yourself with the viewer codebase (see in src/calibre/gui2/viewer and src/pyj/read_book). Then try to compe up with some set of integration points at which to call plugin code in the python part.
Then craeate a viewerplugin class in customize/__init__.py and some functions for loading and calling them in customize/ui.py and implement those integration points.
Once you get there we can talk about the best ways to enable loading of rapydscript in plugins and communication between the rapydscript and python parts of the plugin.