Nielsen and Chuang Box 5.2 does indeed need more elaborate explanation.
I’m going to describe the architecture of efficient $O(n^3)$ modular exponentiation circuit from the paper ‘Quantum Networks for Elementary Arithmetic Operations’ – Vedral, Barenco, Ekert, 1995, for the case $n = 3$ using specific 3-bit numeric values in order to make general approach more illustrative. It seems to be exactly what you need, since
- The circuit's efficiency is $O(n^3)$
- The circuit is not subject to further lower-level optimization, but it is still efficient and replicates logic behind commonly used decomposition technique (you can find more elaborate comments on efficiency in the paper)
The Idea
Let’s first revisit the idea which is used to construct the circuit of the interest. Using the property of modular multiplication $(A\times B) \mod{N} = (A \mod{N}\times B \mod{N}) \mod{N}$, we can see that modular exponentiation is a succession of modular multiplications:
$$y^x \mod{N} =(y^{x_02^0}\times y^{x_12^1}\times ... \times y^{x_{n−1}2^{n−1}} ) \mod{N}=$$
$$=(...([(y^{x_02^0 }\times y^{x_12^1} ) \mod{N}] \times ... \times y^{x_{n−1}2^{n−1}} )\mod{N}...) \mod{N},$$
where $x = x_02^0 + x_12^1 + ... + x_{n-1}2^{n-1}$.
Now, any modular multiplication operation can be represented by modular additions in the following way:
$$zm \mod{N}=(z_0 2^0 m+z_1 2^1 m+..+z_{n−1}2^{n−1}m)\mod{N},$$
where $z = z_02^0 + z_12^1 + ... + z_{n-1}2^{n-1}$.
Finally, modular addition can be represented using addition and logical operations, as you will see later in the text.
The Circuit
Some comments on notations: wires marked in blue are auxiliary wires for lower-level operations. I decided to keep them in order for the reader not to lose track of what’s going on. Values and circuit elements corresponding to known-in-advance classical information are marked red.
Let’s go through the logic of building the circuit from the lowest level with elementary quantum operations to the highest level with modular multiplications
3-qubit addition circuit ADDER.
We will use circuits CARRY and SUM which implement bitwise carry and sum operations.
Note that thick black line on the right side of a block denotes operation itself, while thick black line on the left side of a block denotes reverse operation, i.e. operation with reverse order of all elementary operation for the block.
CARRY and SUM are used to construct 3-qubit addition transformation ADDER
Note that $a$ is the number decoded with 3 qubits, $b$ is the number decoded with 3 qubits, but the register $|b\rangle_b$ contains additional qubit to account for the possibility of 4-bit result of addition.
3-qubit modular addition circuit ADDER_MOD.
Modular addition has two blocks: Block 1 and Block 2.
The logic of the Block 1 is the following: firstly, ADDER acts
$$|a\rangle_a |b\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t \rightarrow |a\rangle_a |a+b\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t$$
Then 3 SWAP gates swap the register $a$ with the register $N$:
$$|a\rangle_a |a+b\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t \rightarrow |N\rangle_a |a+b\rangle_b |0\rangle_c |a\rangle_N |0\rangle_t$$
Then reverse ADDER extracts $N$:
$$|N\rangle_a |a+b\rangle_b |0\rangle_c |a\rangle_N |0\rangle_t \rightarrow |N\rangle_a |a+b-N\rangle_b |0\rangle_c |a\rangle_N |0\rangle_t$$
At that point we are interested in the sign of $a+b-N$. If it is greater than 0, we want to keep the result in the register $b$, but if it is less than 0, we want to make addition of $N$ once again to get $a+b$ in the register $b$, and this is why see CNOTs, the third ADDER and SWAPS in the rest of Block 1.
Note that CNOTs denoted by red color are there to make transformation $|N\rangle_a\rightarrow |0\rangle_a$ before ADDER if the value of register $t$ is $|1\rangle_t$, and then undo this operation after ADDER. This is the first time when classically known N affects configuration of the circuit itself: in the case of $N=5=101_2$ we need 2 CNOTs before ADDER and 2 CNOTS after ADDER, but if $N=6=111_2$, we would have to use 3 red CNOTs before ADDER and 3 red CNOTS after ADDER.
The role of the Block 2 is to uncompute the value $|1\rangle_t$ to $|0\rangle_t$, if it appears.
3-qubit controlled modular multiplication circuit Ctrl_MULT_MOD.
Block Ctrl_MULT_MOD implements the following transformation:
$$|c\rangle_x |z\rangle_z |0\rangle_a |0\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t\rightarrow |c\rangle_x |z\rangle_z |0\rangle_a |zm \mod{N}\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t, \text{ if } c = 1$$
$$|c\rangle_x |z\rangle_z |0\rangle_a |0\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t\rightarrow |c\rangle_x |z\rangle_z |0\rangle_a |z\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t, \text{ if }c=0$$
For this particular block we use $m=3=11_2, N=5=101_2$
The role of red Toffoli gates is to replace zeros in the register $|0\rangle_a$ with the state $|m\times z_i 2^𝑖 \mod{N}\rangle_a$ to further add up all this numbers to get $|z\times 𝑚 \mod{N}\rangle_b$. Red Toffoli gates put values $m\times 2^i \mod{N}$ in the register $a$ conditionally on values in registers $x$ and $z$. Note that numbers $m\times 2^i \mod{N}$ can be classically and efficiently computed. Also note that this is the second time when classically known information affects configuration of the circuit itself.
The last block of CNOTs is used to put value $z$ in the register $|0\rangle_b$ if control $|c\rangle_x$ is $|0\rangle_x$
3-qubit modular exponentiation circuit MODULAR_EXPONENTIATION.
Finally, using an array of controlled modular multiplications, we can implement modular exponentiation using known classical information for every step. It should be a succession of controlled modular multiplications with controls set on wires of the register $x$. But every Ctrl_MULT_MOD should be accompanied by SWAPs and reverse Ctrl_MULT_MOD to reset one of the registers to zero and free it for the next controlled modular multiplication (see the original paper for more details). Notation $(...)^{−1}\mod{N}$ is for modular inverse, which can be efficiently classically precomputed using Euclid’s algorithm.
To sum up, this Ctrl_MULT_MOD blocks implement the following chain of transformations which lead to the desired result:
$$|x\rangle_x |1\rangle_z |0\rangle_a |0\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t\rightarrow |x\rangle_x |1\times y^{x_0 2^0}\mod{N}\rangle_z |0\rangle_a |0\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t \rightarrow$$
$$\rightarrow |x\rangle_x |1\times y^{x_0 2^0}\times y^{x_1 2^1}\mod{N}\rangle_z |0\rangle_a |0\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t \rightarrow... \rightarrow$$
$$\rightarrow |x\rangle_x |y^x\mod{N}\rangle_z |0\rangle_a |0\rangle_b |0\rangle_c |N\rangle_N |0\rangle_t,$$

The last thing I want to mention is that if the size of the register $|N\rangle_N$ is n, then the size of the register $|x\rangle_x$ should be $2n$ to make MODULAR_EXPONENTIATION circuit usable in Shor's algorithm. As one can see from the last picture, going to $2n = 6$ qubits in $|x\rangle_x$ for this particular case requires just additional 3 wires for $|x\rangle$ and additional 3 blocks of [Ctrl_MULT_MOD - SWAPs - inverse Ctrl_MULT_MOD].
Regarding your question about changes which occur when we go from $11^x \mod{15}$ to $7^x \mod{21}$: for $N=15$ we need 4 bits to encode this number, so the current architecture requires 8 or less qubits for the register $x$, 4 qubits for the register $z$, 4 qubits for the register $a$, 4+1 qubits for the register $b$, 4 qubits for the register $c$, 4 qubits for the register $N$ and 1 qubit for control $t$. If we use $N=21$, then it will be 10 or less qubits for the register $x$, 5 qubits for the register $z$, 5 qubits for the register $a$, 5+1 qubits for the register $b$, 5 qubits for the register $c$, 5 qubits for the register $N$ and 1 qubit for control $t$. So one can see that number of qubits grows as $O(n)$, which is acceptable according to the original paper