The conversion process is described here:
http://manual.calibre-ebook.com/conv...tml#conversion
To abbreviate that discussion even further, Calibre takes any of the input formats it supports, converts that input to OEB, and then converts from OEB to the specified output format.
In terms of where the code is - the starting point of the code for the CLI utilities is in calibre.ebooks.conversion.cli, as described here:
http://manual.calibre-ebook.com/deve...ml#code-layout
Since you specifically mentioned converting html to mobi, the two main bits of code you may want to check out are the html input plugin and the mobi output plugin. The format plugin folders are under calibre.ebooks.format_name, i.e.:
calibre.ebooks.mobi.writer2 (or writer8 for KF8) - mobi output, many other files relating to mobi support are in the mobi folder.
and:
calibre.ebooks.html.input - html input.
There are many steps in between input and output, so you'll need more specific questions regarding other aspects of the code.