You need to discuss with the customer his exact requirements, down to the last detail. Then you need to estimate the time it will take for you to meet those requirements, not forgetting to include time needed for testing purposes. I have found writing unit tests takes almost as long as writing the code for the project. Then, depending on what you think your time is worth, you can come up with an estimate for the project. My advice would be to add an extra 25% on the estimate of time you think it will take, as I found it is always better to over estimate than the other way around.
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman