What do each of the files do inside of an iPhoto Library? Inside my iPhoto library, there are many files and directories.

-rw-r--r--@  1 kevin  staff   3.9M Jul 10 21:10 AlbumData.xml
drwxr-xr-x   2 kevin  staff    68B Dec 23  2013 Attachments
drwxr-xr-x   2 kevin  staff    68B Dec 23  2013 Auto Import
drwxr-xr-x  21 kevin  staff   714B Jul 10 21:10 Database
-rw-r--r--@  1 kevin  staff   324B Dec 23  2013 Info.plist
drwxr-xr-x   3 kevin  staff   102B Jan  9  2014 Masters
drwxr-xr-x   3 kevin  staff   102B Jan  9  2014 Previews
-rw-r--r--@  1 kevin  staff   341B Dec 23  2013 ProjectDBVersion.plist
-rw-r--r--@  1 kevin  staff   576K Jul 10 21:10 Projects.db
drwxr-xr-x   4 kevin  staff   136B Jan  9  2014 Thumbnails
drwxr-xr-x   4 kevin  staff   136B Jul 10 21:10 iLifeShared
-rw-r--r--@  1 kevin  staff     1B Jul 10 21:10 iPhotoLock.data
drwxr-xr-x@ 55 kevin  staff   1.8K Jul  7 10:00 iPod Photo Cache


Inside the Database folder:

drwxr-xr-x  801 kevin  staff    27K Jul 10 21:10 Albums
lrwxr-xr-x@   1 kevin  staff    18B Dec 23  2013 BigBlobs.apdb -&gt; apdb/BigBlobs.apdb
-rw-r--r--@   1 kevin  staff   2.4K Jul 10 21:10 DataModelVersion.plist
drwxr-xr-x    6 kevin  staff   204B Dec 23  2013 Faces
lrwxr-xr-x@   1 kevin  staff    13B Dec 23  2013 Faces.db -&gt; apdb/Faces.db
drwxr-xr-x  800 kevin  staff    27K Jul 10 21:10 Folders
drwxr-xr-x    3 kevin  staff   102B Dec 23  2013 History
lrwxr-xr-x@   1 kevin  staff    17B Dec 23  2013 History.apdb -&gt; apdb/History.apdb
lrwxr-xr-x@   1 kevin  staff    22B Dec 23  2013 ImageProxies.apdb -&gt; apdb/ImageProxies.apdb
-rw-r--r--@   1 kevin  staff   1.5K May 21 18:22 Keywords.plist
lrwxr-xr-x@   1 kevin  staff    17B Dec 23  2013 Library.apdb -&gt; apdb/Library.apdb
drwxr-xr-x    2 kevin  staff    68B Dec 23  2013 Places
lrwxr-xr-x@   1 kevin  staff    20B Dec 23  2013 Properties.apdb -&gt; apdb/Properties.apdb
-rw-r--r--@   1 kevin  staff    42B Mar 15 20:31 SpanCache.plist
drwxr-xr-x    2 kevin  staff    68B Dec 23  2013 Vaults
drwxr-xr-x    3 kevin  staff   102B Jan  9  2014 Versions
drwxr-xr-x    3 kevin  staff   102B May 21 18:21 Volumes
drwxr-xr-x    9 kevin  staff   306B Jul 10 21:10 apdb
-rw-r--r--@   1 kevin  staff   304B Jul 10 21:10 tmSync.plist


What parts of iPhoto are these files and directories responsible for?
Basically, all the files like xml, db and such help different softwares like iPhoto, iMovies etc gain information about your photos.

Excerpted from Fat Cat Software: iPhoto Library Internals help page:


  AlbumData.xml
  
  This file is written out by iPhoto as a way for other applications
  (such as iMovie and iDVD) to be able to easily access the contents of
  your iPhoto library. You can read in more detail about this file here.
  
  AlbumData2.xml
  
  This file is only created by iPhoto 8. It is a smaller version of the
  AlbumData.xml file that only contains information for the library's
  albums and events, and none of the actual photos. This file is faster
  to read for programs that only need to get the list of albums and
  events in the library.
  
  Attachments
  
  This folder is used by iPhoto 9 as a temporary holding place for
  photos that are being sent using iPhoto's built-in email features.
  
  Auto Import
  
  This folder is created by iPhoto 7 and later. There does not seem to
  be any mention of this folder in iPhoto's documentation, but if you
  put some photos into it, then quit and reopen iPhoto, it will
  automatically import those photos into the iPhoto library and then
  delete them from the Auto Import folder. There is also an "auto
  import" Applescript command which does not appear to do anything when
  called. It's not clear if this was a planned feature for iPhoto 7 that
  ended up getting pulled out (but not completely, apparently), and it
  doesn't seem to be very useful for anything, especially since that
  folder is buried inside a package now, but that's what it does if
  anyone is curious.
  
  Backup
  
  If a library has been upgraded from an earlier version of iPhoto to
  iPhoto 9, a copy of the original database files from the library are
  stored in this folder before performing the upgrade.
  
  Caches
  
  Only present in iPhoto 8 or later, this folder contains additional
  data for the iPhoto library. Unlike some other Caches folders that can
  be safe to delete, this one is not, so don't go deleting it in an
  attempt to clear up disk space.
  
  com.apple.iPhoto.plist
  
  This file is actually not written out by iPhoto itself, but rather by
  iPhoto Library Manager. It is a copy of the preferences file that is
  associated with this library. When you switch between different iPhoto
  libraries, iPhoto Library Manager will swap out this preference file
  for the existing preferences before opening the library up.
  
  Contents/PkgInfo
  
  This is part of the new package structure in iPhoto 7 that gives the
  package a type and creator code so that the Finder knows what
  application the package belongs to.
  
  face.db, face_blob.db
  
  Contains the data for faces identified by the face recognition feature
  added in iPhoto 8.
  
  iLifeShared
  
  Starting in iPhoto 9, the AlbumData2.xml file is now stored within
  this folder rather than at the root level of the library package.
  
  Info.plist
  
  iPhoto 9 added this file, containing basic version information about
  the library
  
  iPhoto.ipspot
  
  This file is written out by iPhoto and read in by Spotlight in order
  to index the information about the photos in your photo library. You
  must have iPhoto 5.0.2 or later for this file to be present.
  
  iPhotoLock.data
  
  This file is used by iPhoto to help prevent more than one copy of
  iPhoto from accessing the library at one time.
  
  iPod Photo Cache
  
  This folder is created by iTunes if you choose to sync your iPhoto
  library with a photo capable iPod. It contains cached information
  about the last time the photos were synced and help speed up the
  syncing process, allowing iTunes to tell which photos have changed
  since the last sync and only update those ones. You can delete it if
  you want to clear up space, but iTunes will have to create it all over
  again the next time you sync your iPod's photos.
  
  Library.data, Dir.data (iPhoto 2), Library.iPhoto, iPhoto.db (iPhoto 4, &amp; 5), Library.iPhoto6 (iPhoto 6 &amp; 7), iPhotoMain.db, iPhotoAux.db
  (iPhoto 8), Database (iPhoto 9)
  
  These files/folders serve as the central database where iPhoto stores
  your library information. All your event, album, and photo metadata is
  stored in these files.
  
  Data, Originals, and Modified
  
  iPhoto 6 organizes its photos fairly differently that previous
  versions. Imported photos will initially be stored inside the
  "Originals" folder. Within that folder, photos are organized into
  subfolders based on the roll that they are in, so each roll gets its
  own folder. Those rolls are then sorted by date (2006, 2005, etc.) and
  put into dated folders accordingly. So, if you had a photo in a roll
  named "Vacation" and dated February 24, 2004, to find that photo, go
  into the "Originals" folder, then into "2004", then into the folder
  named "Vacation". When you edit a photo in iPhoto, the original stays
  where it is, and the edited photo is placed in the "Modified" folder,
  which has the same per-roll organization scheme within it as the
  "Originals" folder does. The "Data" folder contains all the scaled
  down thumbnail version of photos in your library. If you upgrade to
  iPhoto 6 from a previous version, iPhoto will rearrange all your
  photos from the old scheme into the new scheme. After upgrading, you
  may still see one or more leftover folders named "2004" and such.
  These folders should no longer contain any files being used by iPhoto
  6, and can be disposed of safely.
  
  Thumbnails, Masters, and Previews
  
  iPhoto 9 organizes photos in much the same way as iPhoto 6-8, but uses
  the folder names Thumbnails, Masters, and Previews instead of Data,
  Originals, and Modified
  
  Metadata Backup
  
  Created by iPhoto 8, containing backup copies of the metadata for your
  photos, events, albums, and other library content. This information
  can be used by iPhoto to recover a library whose main database has
  been corrupted.
  
  ProjectDBVersion.plist, Projects.db, Projects.db-journal, SharingActivity.db
  
  These additional data files exist only in iPhoto 9 and contain
  information relating to "keepsake" items such as books and slideshows,
  and information for albums published on MobileMe, Flickr, or Facebook.
  
  ThemeCache
  
  A cache file used by iPhoto to store theme data used to make books,
  calendars, and cards
  
  Thumb32Segment.data, Thumb64Segment.data, ThumbJPGSegment.data
  
  In order to improve performance, when you add photos to your library,
  iPhoto creates small "thumbnail" versions of your photos and caches
  them in these files. In iPhoto 5 and earlier, these files are instead
  called Thumb32.data, Thumb64.data, and ThumbJPG.data.


Note that there are some small and some large differences in the folder structure depending on what version of iPhoto you're using.