The architecture of Firefox OS is a bit different from other mobile operating systems. There are three levels of abstraction in Firefox OS: Gonk, Gecko, and Gaia.
Mobile hardware refers to the various components present in a mobile, such as the battery, sensors, camera, GPS, Bluetooth, and other things, that are crucial for the interaction of the operating system with the device and environment. The interaction of these various components with the operating system is what makes the experience of smartphones unique compared to the previous generation of phones, called feature phones.
Firefox OS's kernel is built in the Android Open Source Project, which itself is a Linux kernel, and is the lowest level in the abstraction structure of the operating system. Gonk acts as the interface between the underlying hardware and Gecko. It deals with all the complex tasks of abstracting the hardware such that the components of the mobile device such as Bluetooth, camera, and sensors can be accessed via Gecko. Thus, Gonk is responsible for exposing the features of the chipset to be used via the WebAPIs to Gecko.
Gecko is the web engine that connects components such as HTML and JavaScript to the underlying low-level layer of Gecko. Gecko is the same HTML parsing and rendering engine that is used in the Firefox web browser. However, a certain web renderer of Gecko is used for this project just as different variants of Gecko are used for Firefox, Windows, Android, and OS X. Gecko is responsible for handling details such as providing access to the hardware via secure APIs. It consists of a robust security framework and it also handles the update management, along with various other core services. It is basically an application runtime layer.
Gaia is the user interface part of Firefox OS. It is what we actually see in the OS. The app launcher and all the default applications such as camera, dialer, and settings are part of Gaia, and are completely built using HTML, CSS and JavaScript. This is the final layer of Firefox OS. Gaia exposes the WebAPIs for developers to interact with Gecko and the underlying hardware. As Firefox OS is completely open source and available online on GitHub (Gaia) and Mercurial (Gecko and Gonk), it gives full access to the user so that they can tweak the default look and feel of Firefox OS to suit their personal or organizational needs.