Can someone help me better understand .cursorrules?

I've been using the pro version of cursor while developing a small flask web application. It's been amazing, I love using composer and the tab feature. I've already finished the prototype.

My issue is I have a very complex set of algorithms for generating item codes for a database. There are several "special cases" that complicate the item code generation exponentially, and so far I've had to fix the functions about a dozen times after composer has made minor edits and messed them up a little bit.

Is this where I would want to use cursorrules? I know people are putting a .cursorrule file in the project root directory with more general information like "you are an expert in...." etc. But can I make a .cursorrule that describes in great detail the process for generating item codes, and save that file in the sub-directory (instead of the roof folder) that contains the relevant files?

Are all .cursorrule files automatically loaded into context every time? Or only those in the root folder? If accessing a file in a sub-folder, will cursor automatically refer to the cursorrule located in that sub-folder?

Thank you for your help!