Read
http://manual.calibre-ebook.com/develop.html for setting up a development environment for calibre
This
http://doc.bazaar.canonical.com/latest/en/user-guide/ might also be helpful for you.
Read
http://diveintopython.org/ for learning about python.
For the web interface calibre uses cherrypy. You will find the necessary files in src/routes. However, you can connect to calibre directly using another language for the web interface. Search for the PHP interface by CHaley.