The radiative capture cross sections for the 3He(alpha,gamma)7Be and 3H(alpha,gamma)7Li reactions are calculated in the fully microscopic fermionic molecular dynamics approach using a realistic effective interaction that reproduces the nucleon-nucleon scattering data. At large distances bound and scattering states are described by antisymmetrized products of 4He and 3He/3H ground states. At short distances the many-body Hilbert space is extended with additional many-body wave functions needed to represent polarized clusters and shell-model-like configurations. Properties of the bound states are described well, as are the scattering phase shifts. The calculated S factor for the 3He(alpha,gamma)7Be reaction agrees very well with recent experimental data both in absolute normalization and energy dependence. In case of the 3H(alpha,gamma)7Li reaction the calculated S factor is larger than available experimental data by about 15%.