CRT & NTT implementation in CKKS

Hello!

Some implementation questions of the encoding using CRT and NTT.

Given an input, what are the high level steps to the encoding?
It first make the naive encoding like here and then that is transform multiple encodings with CRT, and then each of them are transformed using NTT? Or first NTT then CRT? Or something else?

Also to ask for a particular question of CRT, for each polynomial coefficient of the naive encoding, x it calculates the CRT coeffitients a_i using something like this? x=(a_1M_1M_1^{-1}+a_2M_2M_2^{-1}+...+a_nM_nM_n^{-1})\text{ mod } M

If this so, how openFHE computes or select M and the M_i's?

Also if someone has some source of information of all these will be well received.