We develop a mathematical framework for modeling regulatory mechanisms in the immune system. The model describes dynamics of key components of the immune network within two compartments: lymph node and tissue. We demonstrate using numerical simulations that our system can eliminate virus-infected cells, which are characterized by a tendency to increase without control (in absence of an immune response), while tolerating normal cells, which are characterized by a tendency to approach a stable equilibrium population. We experiment with different combinations of T cell reactivities that lead to effective systems and conclude that slightly self-reactive T cells can exist within the immune system and are controlled by regulatory cells. We observe that CD8+ T cell dynamics has two phases. In the first phase, CD8+ cells remain sequestered within the lymph node during a period of proliferation. In the second phase, the CD8+ population emigrates to the tissue and destroys its target population. We also conclude that a self-tolerant system must have a mechanism of central tolerance to ensure that self-reactive T cells are not too self-reactive. Furthermore, the effectiveness of a system depends on a balance between the reactivities of the effector and regulatory T cell populations, where the effectors are slightly more reactive than the regulatory cells.