darlingserver is Darling's userspace kernel server, much like wineserver for Wine.
It implements services that the XNU kernel would normally provide on macOS.
Because of the types of services it provides and the way it implements some of those services, darlingserver is very low-level and is a fairly complex system. The documentation explains its architecture and implementation to make it easier to understand and work on.
The first and most important thing to understand about darlingserver's architecture is that it includes part of the XNU kernel as part of its sources. The reasoning behind this decision can be summed up as "why reinvent the wheel when you can just use it instead?"
XNU is open-source and implements many of the services darlingserver needs to provide, so we can just use it to implement them. In fact, we've actually already tried reinventing the wheel in the past with an older version of the LKM by implementing those services ourselves. It turned out to be much easier to just duct-tape the necessary XNU code, which was the approach used in the now-defunct LKM.
This is a conscious design choice that must be kept in mind for all design and implementation decisions. While darlingserver strives to avoid wasting resources like file descriptors, CPU time, threads, and memory, among other things:
For example, rather than create a real Linux thread for each thread the server manages, we use userspace threads called microthreads (a.k.a. fibers) and perform cooperative scheduling between them ourselves. Using real Linux threads would greatly simplify thread management within darlingserver, but Linux threads are much heavier resource-wise and creating one for each thread the server manages would waste too many resources unnecessarily.
Detailed documentation on darlingserver's internals is available in the Darling Documentation: