Is Gii an extension or a module?

What I actually ask is, what the difference between extension and module is. When I saw Gii in " Official Extensions", I thought it must be an extension. But when I read the source code of yii\gii\Module, it says:“This is the main module class for the Gii module.” So, I got confused. If I want to build something myself. When should I build it as a module? And when should I build it as an extension? The Guide even don’t give definitions for them.

Everything that is build outside of core framework to improve the framework or add new functionality is an extension.

Module is a structure term. In Yii 2 it is described in the Guide.