We study the Hubbard model with time-reversal invariant flux and spin-orbit coupling and position-dependent onsite energies on the kagome lattice, using numerical and analytical methods. In particular, we perform calculations using real space dynamical mean-field theory (R-DMFT). To study the topological properties of the system, we use the topological Hamiltonian approach. We obtain a rich phase diagram: for weak and intermediate interactions, depending on the model parameters, the system is in the band insulator, topological insulator, or metallic phase, while for strong interactions the system is in the Mott insulator phase. We also investigate the magnetic phases that occur in this system. For this purpose, in addition to R-DMFT, we also use two analytical methods: perturbation theory for large interactions and onsite energies, and stochastic mean-field theory.