The best way to understand Pants is to look at the Plugin API, which is a bit of a misnomer. It’s the exact same API we use to build core Pants functionality.
https://www.pantsbuild.org/docs/plugins-overview
Deeper down, there’s the Rust engine. That should be entirely abstracted away, though, unless you want to change how the engine itself works.