Objective. This study aims to investigate the functional gene network in gastric carcinogenesis by using bioinformatics; besides, the diagnostic utility of key genes and potential active ingredients of traditional Chinese medicine (TCM) for treatment in gastric cancer have been explored. Methods. The Cancer Genome Atlas and Gene Expression Omnibus databases have been applied to analyze the differentially expressed genes (DEGs) between gastric cancer and normal gastric tissues. Then, the DEGs underwent Gene Ontology and Kyoto Encyclopedia of Genes and Genomes enrichment analyses using the Metascape database. The STRING database and the Cytoscape software were utilized for the protein-protein interaction network of DEGs and hub genes screening. Furthermore, survival and expression analyses of hub genes were conducted using Gene Expression Profiling Interactive Analysis and Human Protein Atlas databases. By using the Comparative Toxicogenomics Database, the hub genes interconnected with active ingredients of TCM were analyzed to provide potential information for the treatment of gastric cancer. After the molecular docking of the active ingredients of TCM to specific hub gene receptor proteins, the molecular dynamics simulation GROMACS was applied to validate the conformation of the strongest binding ability in the molecular docking. Results. A total of 291 significant DEGs were found, from which 12 hub genes were screened out. Among these hub genes, the expressions of five hub genes including COL1A1, COL5A2, MMP12, SERPINE1, and VCAN were significantly correlated with the overall survival. Furthermore, four potential therapeutic active ingredients of TCM were acquired, including quercetin, resveratrol, emodin, and schizandrin B. In addition, the molecular docking results exhibited that the active ingredients of TCM formed stable binding with the hub gene targets. SERPINE1 (3UT3)-Emodin and COL1A1 (7DV6)-Quercetin were subjected to molecular dynamics simulations as conformations of continuing research significance, and both were found to be stably bound as a result of the interaction of van der Waals potentials, electrostatic, and hydrogen bonding. Conclusion. Our findings may provide novel insights and references for the screening of biomarkers, the prognostic evaluation, and the identification of potential active ingredients of TCM for gastric cancer treatment.