Firstly, you can’t patent just an idea. You need to have a solution to a problem that shows an “inventive step” from what already exists, and is non-obvious and there’s no relevant prior art.
The first thing to do is to research the hell out of your solution. Look on Google Patents, use all the possible key words, read all the existing patents that are out there. Then look elsewhere, do lots of web searches for things that might relate.
If you can’t find anything at all, talk to a patent person. My dealings are done through work so they will allocate some patent experts to repeat all the searches formally. They will then write it up – you won’t be able to do this yourself, the style and language is quite specific.
This costs money (thousands if you want decent protection worldwide), as will filing an application. Once you’ve got that far the patent office will do their own searches… Expect a good twelve months to get this far.
EDIT – Bear in mind a patent is useless unless you’ve got the finances to defend it in court when someone copies your idea.