This invention relates to a system and method for sensing respiratory phases and controlling the gas supply for the same to a patient. The system is having a pressure sensing device to sense the respiratory activities vis- -vis an inhalation and exhalation respiratory phase of a patient, on sensing these phases, the patient needs to be provided the gas supply according to that, which is further delivered under the controlled mechanism by a control module, this control module under supervision of a microcontroller. The microcontroller is also adapted to receive the input from a machine learning interface to deliver controlled gas supply to the patient, which works in case the microcontroller is not able to receive the input values from the pressure sensing device. In addition, a portable computing device for keeping records of the respiratory phases in graphical form and can also interact with the microcontroller to determine the plurality of parameters for controlling gas supply to the patient is also used.