Stars are fossils that retain the history of their host galaxies. Elements heavier than helium are created inside stars and are ejected when they die. From the spatial distribution of elements in galaxies, it is therefore possible to constrain the physical processes during galaxy formation and evolution. This approach, Galactic archaeology, has been popularly used for our Milky Way Galaxy with a vast amount of data from Gaia satellite and multi-object spectrographs to understand the origins of sub-structures of the Milky Way. Thanks to integral field units, this approach can also be applied to external galaxies from nearby to distant universe with the James Webb Space Telescope. In order to interpret these observational data, it is necessary to compare with theoretical predictions, namely chemodynamical simulations of galaxies, which include detailed chemical enrichment into hydrodynamical simulations from cosmological initial conditions. These simulations can predict the evolution of internal structures (e.g., metallicity radial gradients) as well as that of scaling relations (e.g., the mass-metallicity relations). After explaining the formula and assumptions, we will show some example results, and discuss future prospects.