BackgroundMajor depressive disorder (MDD) is a life-threatening, debilitating mental health condition. An important factor in the development of depression is endoplasmic reticulum stress (ERS). However, their roles in MDD have not yet been established. The goal of this study was to examine ERS and its underlying molecular mechanisms in MDD.MethodsWe used data from two microarray datasets (GSE98793 and GSE39653) and the GeneCards database to examine the reticulum stress-related differentially expressed genes (ERSR-DEGs) associated with MDD. Gene Ontology (GO), Kyoto Encyclopedia of Genes and Genomes (KEGG), Gene Set Enrichment Analysis (GSEA), and Gene Set Variation Analysis (GSVA) were used to further investigate the function and mechanism of ERS in MDD. Moreover, we constructed protein-protein interaction (PPI) networks to identify hub genes as well as the regulatory network of microRNAs (miRNAs), transcription factors (TFs), and potential drugs related to ERSR-DEGs. CIBERSORT was then used to evaluate the immune activity of MDD samples and conduct a correlation analysis between the hub genes and immune cells.ResultsIn total, 37 ERSR-DEGs and five hub genes were identified (NCF1, MAPK14, CASP1, CYBA, and TNF). Functional enrichment analysis revealed that ERSR-DEGs were predominantly enriched in inflammation-and immunity-related pathways, such as tumor necrosis factor signaling, NF-κB signaling, and Toll-like receptor signaling pathways. Additionally, 179 miRNAs, 25 TFs, and 15 potential drugs were tested for their interactions with the ERSR-DEGs. CIBERSORT found high proportions of Tregs, monocytes, and macrophages M0 in the MDD samples. Among these, hub genes showed a significant correlation with immune cell infiltration in patients with MDD.ConclusionsNCF1, MAPK14, CASP1, CYBA, and TNF are potential ERS-related biomarkers for the diagnosis of MDD. Our research has revealed a significant correlation between immune cells and ERS-related genes with MDD. Not only did our study contribute to a better understanding of the regulatory mechanisms of ERS in underlying MDD pathology, but it also established a paradigm for future studies on ERS.