A layer cake. One of the biggest hurdles you'll encounter when learning Drupal is trying to figure out what goes where, what gets executed when, what makes a module truly modular, and what makes a theme a theme. It all gets jumbled around in your mind at first and it makes for a difficult time when trying to implement an idea. It leads to the dreaded question 'where do I start?'.
The layers of Drupal make sense in theory but it really doesn't become completely clear until you've had some good challenging hands-on experience. What is important to know is that Drupal keeps markup, data, and functionality all separate. The foundation of Drupal is the database layer. It holds all content, module, theme and block settings. Above the database layer are modules. The modules act as a revolving door between the data and the theme. They either receive user input, process it, and store it in the database; or they retreive data from the database, process it, and pass it to the theme.