If you want to learn more about query based compilers as a concept, I highly recommend ollef's aritcle: https://ollef.github.io/blog/posts/query-based-compilers.htm...
If you want to learn how to implement a query based compiler, I have a tutorial on that here: https://thunderseethe.dev/posts/lsp-base/ (which I also highly recommend but that might be more obvious since I wrote it)