The bacterium that causes tuberculosis (TB), Mycobacterium tuberculosis, is still a significant global public health problem due to its contagious nature and the emergence of drug-resistant variants. This study leverages network pharmacology and computational drug discovery to identify genes linked to TB using the GSE54992 and GSE62525 datasets. In active tuberculosis patients, it identifies 162 DEGs that are not present in healthy people. The research includes an investigation of gene ontology (GO) and protein–protein interaction (PPI) networks to provide a comprehensive understanding of these DEGs. Crucially, it identifies ten hub genes: IL7R, CCR7, CXCR5, CCR6, CCR9, S1PR1, BACH2, CXCL5, SPIB, and EBF. The research suggests IL7R as a potential therapeutic target because of its essential role in FoxO signalling pathways and cytokine-cytokine receptor interaction. IL7 and its receptor (IL7R) are vital for T cell functionality and essential in combating TB. The study explores novel small-molecule activators for IL7R (IL7Rα), aiming to boost the immune response against TB. The following four compounds were found using molecular dynamics simulation, virtual screening, computational pharmacophore modelling, and MM/GBSA analytical techniques: ZINC02131028, ZINC02135418, ZINC46007405, and ZINC59273354. These activators may enhance the IL7 signalling pathway, potentially strengthening the immune fight against M. tuberculosis. Among these ZINC02131028 showed the best results to activate IL7 by binding to its active site, stabilizing its active conformation and enhancing its interaction with the IL7 receptor (IL7R). The findings encourage experimental validation of these IL7 activators, marking a significant step towards innovative TB treatment strategies.