I need to patent the idea and code if possible.
I need to know the cost and where to start?
And does patent really would make a market entry barrier for my competitors who might try to copy/streal the idea?
Thanks in advance
Onec you go down thae path of patents, it is going to cost your dearly - lawyers, patent office fees and there is no guarentee that you will ever get any return on your time and effort.
Unless you are a extremely cany business person who is able to manage all the various aspects of the entire process, stick with being the best there is in your very specific field and use that for sales and support.
You have built on what others have done before you and there will be others who build on what you have done. Trying to stop this is like trying to stop the tide coming in.
In my own personal case, any new ways of doing something or developing something are given way to anyone who wants them. I get the kudos of that work and I get further work out of my abilities, not that that is any consideration today as I am effectively no longer in any industry.
As far as patents I would only find them interesting if they can be used to secure you more funding. Some sources may consider it a plus if you have something patentable.
Probably for a startup however the cost of patents will be more than they're worth, just like for a startup having a dedicated devops team and onsite servers probably isn't worth it.
In most jurisdictions "ideas" are not patentable and a lot of jurisdictions place strict limitations on software patents.
Consult a patent attorney.