Detection Engine Workflow

How can I get to know more about detection engine workflow? How are the detection rules executed? Are there any resources available to understand its workflow as well as code?