Applying a unified approach, we study the integer quantum Hall effect (IQHE) and fractional quantum Hall effect (FQHE) in the Hofstadter model with short range interactions between fermions. An effective field, that takes into account the interaction between fermions, is determined by both amplitude and phase. Its amplitude is proportional to the interaction strength, the phase corresponds to the minimum energy. In fact, the problem is reduced to the Harper equation with two different scales: the first is a magnetic scale with the cell size corresponding to a unit quantum magnetic flux, the second scale determines the inhomogeneity of the effective field, forms the steady fine structure of the Hofstadter spectrum and leads to the realization of fractional quantum Hall states. In a sample of finite size with open boundary conditions, the fine structure of the Hofstadter spectrum consists of the Dirac branches of the fermion excitations and includes the fine structure of the edge chiral modes. The Chern numbers of the topological Hofstadter bands are conserved during the formation of their fine structure. The edge modes are formed into the Hofstadter bands. They connect the nearest-neighbor subbands and determine the conductance for the fractional filling.