Joomla 3.9.12
I've been using Sourcerer in order to place custom code throughout my site, it's working well so far. I've created a custom html module, within this I have added PHP, JS, HTML and CSS. The purpose of the module is to select data from the database and display this information in a 'Customers' datatable.
I have duplicated this module and placed it on various pages and positions throughout my site. The issue I am having now is that when I need to make a change, I have to update the code manually within each custom html module. Ideally I'd like to make the change in one place.
For example, in the Joomla back-end I'd like to create new module > select type 'Customers Table' > select a position and page > save. I can duplicate this module as required. If at some stage I want to add an additional column to the 'Customers' table, I should be able to edit the PHP in one place, and the changes reflect across all the modules.
Should I be looking at creating a module, plugin or component? I'm not sure how to approach this. Never attempted custom Joomla development before, although I have read a lot of tutorials I'm not fully understanding the difference in modules, plugins and components.
My PHP code is accessing the database using JDatabase if that helps.