How does the API extension work

I would like to know how the API extension works from a technical point of view. I know that I can define my own routes and they work in a magical way. I assume that the NextCloud has a Core API and my own endpoints will be attached when loading.

I imagine the whole thing to be complex, but maybe you can easily extend the core API with external files (my own NextCloud app) using PHP…Would anyone be kind enough to explain this mechanism to me?

Thanks in advance :slight_smile: