We argue that an astrophysical solution to the ultra high energy cosmic ray ( UHECR ) problem is viable . The detailed study of UHECR energy spectra is performed . The spectral features of extragalactic protons interacting with Cosmic Microwave Background ( CMB ) are calculated in model-independent way . Using the power-law generation spectrum \propto E ^ { - \gamma _ { g } } as the only assumption , we analyze four features of the proton spectrum : the GZK cutoff , dip , bump and the second dip . We found the dip , induced by electron-positron production on CMB , as the most robust feature , existing in energy range 1 \times 10 ^ { 18 } -4 \times 10 ^ { 19 } eV . Its shape is stable relative to various phenomena included in calculations : discreteness of the source distribution , different modes of UHE proton propagation ( from rectilinear to diffusive ) , local overdensity or deficit of the sources , large-scale inhomogeneities in the universe and interaction fluctuations . The dip is well confirmed by observations of AGASA , HiRes , Fly ’ s Eye and Yakutsk detectors . With two free parameters ( \gamma _ { g } and flux normalization constant ) the dip describes about 20 energy bins with \chi ^ { 2 } / { d . o . f . } \approx 1 for each experiment . The best fit is reached at \gamma _ { g } = 2.7 , with the allowed range 2.55 - 2.75 . The dip is used for energy calibration of the detectors . For each detector independently the energy is shifted by factor \lambda to reach the minimum \chi ^ { 2 } . We found \lambda _ { Ag } = 0.9 , \lambda _ { Hi } = 1.2 and \lambda _ { Ya } = 0.75 for AGASA , HiRes and Yakutsk detectors , respectively . Remarkably , that after this energy shift the fluxes and spectra of all three detectors agree perfectly , with discrepancy between AGASA and HiRes at E > 1 \times 10 ^ { 20 } eV being not statistically significant . The excellent agreement of the dip with observations should be considered as confirmation of UHE proton interaction with CMB . The dip has two flattenings . The high energy flattening at E \approx 1 \times 10 ^ { 19 } eV automatically explains ankle , the feature observed in all experiments starting from 1980s . The low-energy flattening at E \approx 1 \times 10 ^ { 18 } eV provides the transition to galactic cosmic rays . This transition is studied quantitatively in this work . Inclusion of primary nuclei with fraction more than 20 \% upsets the agreement of the dip with observations , which we interpret as an indication to acceleration mechanism . We study in detail the formal problems of spectra calculations : energy losses ( the new detailed calculations are presented ) , analytic method of spectrum calculations and study of fluctuations with help of kinetic equation . The UHECR sources , AGN and GRBs , are studied in a model-dependent way , and acceleration is discussed . Based on the agreement of the dip with existing data , we make the robust prediction for the spectrum at 1 \times 10 ^ { 18 } -1 \times 10 ^ { 20 } eV to be measured in the nearest future by Auger detector . We also predict the spectral signature of nearby sources , if they are observed by Auger . This paper is long and contains many technical details . For those who are interested only in physical content we recommend to read Introduction and Conclusions , which are written as autonomous parts of the paper .