The final component from our initial architectural diagram is the theme system.
Drupal separates the look-and-feel components of the system from the rest of
Drupal, and provides a programmatic way for theming data. The system for
handling this is collectively called the theme system.
Some of the theme system resides in the Drupal core libraries. This part is
responsible for initializing themes and locating what theme functions and
templates should be applied under certain circumstances.
However, the majority of the theme code resides in themes and modules.
A theme is a structured bundle of code (like a module) that provides tools
for transforming raw data into formatted output. Sites use at least one theme
to apply a consistent and custom look-and-feel to all of the pages on the site.
However, Not all theme code resides inside of a theme. One of the distinct
advantages offered by Drupal is the capability to define default theming inside
modules, and then provide mechanisms by which the theme layer can selectively
override those themes. In other words, a module might declare a rough layout for a
component, but Drupal provides the structure for a theme developer to later modify
the theme (not the module) to re-layout that component in a different way.