Recurrent kidney infection can be due to diabetes, some anomaly or defect in the
kidney or due to the organisms developing antibiotic resistance. Recurrent
kidney stones are found renal tubular acidosis, medullary sponge kidney, Dent's disease (genetic disease of the kidney), hyperparathyroidism, primary hyperoxaluria and Crohn's disease.
Since the pain comes before periods too, it can also be due to endometriosis.