Typically, inventors automatically assume that they need to file a patent application on their invention before they actually start selling it. That's not a bad thought in many cases, however, filing a patent application before an invention is brought to market may not be necessary, and in some cases, may not even be the best course of action.
The US patent system is a first-to-file system, which is to say that the first inventor who files a patent application on an invention will receive a patent on that invention. So if you sell an invention that can be easily duplicated or reverse engineered, a potential competitor could simply write a patent application on your invention, and you could be barred from getting a patent on your invention as a result.
As a matter of law, per se, a person simply copying your invention is not an inventor and should not receive a patent on your invention. However this can create a very difficult situation in which you would need to prove that such a person copied your invention, as opposed to independently inventing the same thing. The whole situation could get very muddy if a person copying your invention modified it to some degree, even possibly improving it.
So then, if a person can easily duplicate your invention or figure out how it is structured or how it works, then you are well advised to file a patent application on your invention before someone is able to purchase it. In some cases, you may be able to safely market your invention using marketing materials that do not reveal the structure of your invention or how it works.
However, there are some inventions that are difficult or impossible to reverse engineer without resorting to actual theft of intellectual property. An example could be an Internet-based service that includes a server-based process that implements highly inventive and unique ways of acquiring, storing, or analyzing data relating to potential customers for businesses. With proper security, all customers of the service will see is the interface to the server process, and the actual structure and operation of the server-based process will be out of reach.
In such a case, the service and its inventive server-based process can be sold without much danger of a competitor duplicating the system or filing a patent on its core, inventive components. However, bear in mind that once the inventive server-based process is out of testing, in use, and made accessible to the public, or even used internally with the company that developed the process, a patent application must be filed for the server-based process within one year. This is commonly referred to as the on sale bar for filing a patent application.
One other point to keep in mind is that when a unique process, product, or composition of matter is developed, and where such unique process, product, or composition of matter is not visible to the public, or not easily reverse engineered, the inventor may choose not to file a patent application at all, and maintain the invention as a trade secret. The advantage to a trade secret is that a trade secret does not expire and the nature of the trade secret is never disclosed to the public, thereby making it much more difficult to duplicate.
If you have any questions, please feel free to give me a call.