As far as I understood so far, B and T cells are produced in the bone marrow, and during their maturing process in the bone marrow or Thymus, the are "programmed" to react to certain proteins. It is like giving them a particular key.
As I also understood, these "keys" are entirely created by random. Which means, that also "keys" are generated that match cells of the "host body." Hence, if released into the bloodstream/lymph system, those B and T cells would attack the cells of the "host body."
As I understood further, there is a kind of a "security system" which checks if B and T cells are produced that would attack cells of the "host body." This security system would intervene and destroy those B and T cells before they are released into the bloodstream/lymph system.
As read lately - and I am not sure if I did understand this correctly - it is also possible, that B and T cells could also react to other cells even if the key doesn't match perfectly.
Now my questions.
Firstly, being an SW engineer interested in this topic is my understanding above correct?
Secondly, is it correct to say that autoimmune diseases are mainly caused by the following two points:
1. the "security system" in the bone marrow / Thymus failed, and therefore "bad" B and T cells were released into the bloodstream/lymph system
2. B and T cells react to other cells, even if the "key" does not match perfectly.