Greenreader9 hello!
For a knowledge base, the paid extension is probably the best starting point.
If you just wanted to integrate the search with a custom API you implement elsewhere, it's definitely possible with the Flarum extension API. Unfortunately the search API isn't very well documented at this time. I'd refer to an example extension but I can't think of any open-source extension that adds a new search "source". I have done this many times in my private and paid extension so I can share some help if needed. You can see how a search source looks like in Flarum itself, for example the user source: https://github.com/flarum/core/blob/master/js/src/forum/components/UsersSearchSource.tsx There is then a bit of code needed to register the source but it's quite simple. It can query the Flarum REST API, but also any other API as long as CORS is configured correctly.
For the subdomain subfolder question, it's a bit tricky. Flarum is not designed to run at the same folder level as other apps, but it can be done. If you wanted to have the forum and the paid extension knowledge base on different apparent subdomains, you could use an extension like https://discuss.flarum.org/d/23872-custom-paths to keep Flarum at the root folder, but "fake" the Flarum paths to include the subfolder. The problem with this is that Flarum might try to execute links to your other non-Flarum subfolders inside of the Flarum single page app and fail. Also Flarum probably needs to be able to render /
because that's the fallback URL if a page cannot load, so if you have a different non-Flarum homepage, you might occasionally see the Flarum homepage if you're coming back from the forum and going to the homepage.
If the knowledge base and forum don't need to be connected, you could install Flarum 2 times in different subfolders. But you would probably need some sort of hack to integrate the search from one to another.
PS: I'm not entirely sure whether the paid extension integrates with Flarum search bar, it might only offer search on the knowledge base page itself.
An option to avoid the single page application issue could be to make the whole website Flarum-based. This won't always be an applicable option, but if your root website is static, you could replace the static website with custom Flarum pages for example. Something like this can be used to create additional pages in Flarum with custom URLs https://discuss.flarum.org/d/28770-pages-generator But if any of the pages are dynamic, you would have to use the Flarum extension API to make them into dynamic pages of the single page application.
Le me know if you need any more details. I realize my response talks about many different concepts 😅