(1) If there's no related note in the box, give it number $last_number+1 (2) If there's a related note in the box, say, number 103, file it 103/A, 103/B, 103/C, etc. (3) If some subtopic of 103/A comes up, file it 103/A/1, etc.
I did that with Markdown and an iPad app for a while. Now I have an actual paper slip box. It's very time-consuming but gives you space to think. Also it's interesting to see notes spatially over an entire living room once in a while.
--- I'm lost in a digression. But it seems rather trivial to use a system like that (maybe with dots -- 10.1.1 etc. -- ) and write a script that reads a list of chapters in the order they're going to be used eventually and assembles a book. Heck, from my system I may be able to sort, scan and have someone at Upwork type it.
A 4k monitor with 20 small windows would be me approach :)