It started with constipation and bloating. Positive helicobacter pylori test. Gastroscopy-gastritis and duodenitis. Could the bacteria be causing it?

Yes. Helicobacter pylori infection of the lining of the stomach is a well known cause of gastritis and indigestion. It would not be related to chronic constipation that needs lots of liquids to dink and increased fiber in the diet with fruits, vegetables ; maybe added metamucil. See a doctor to get medications to treat the h. Pylori infection.