Modules
In IntelliJ IDEA, a module is an essential part of any project – it's created automatically together with a project. Projects can contain multiple modules – you can add new modules, group them, and unload the modules you don't need at the moment.
Generally, modules consist of one or several content roots and a module file, however, modules can exists without content roots. A content root is a folder where you store your code. Usually, it contains subfolders for source code, unit tests, resource files, and so on. A module file (the .iml file) is used for keeping module configuration.
Modules allow you to combine several technologies and frameworks in one application. In IntelliJ IDEA, you can create several modules for a project and each of them can be responsible for its own framework. For more information, refer to Add frameworks (facets).

tip
For more information on how modules are used in projects, refer to Configure projects.
IntelliJ IDEA modules vs Java modules
In version 9, Java introduced the Java Platform Module System. IntelliJ IDEA had already had a concept of modules: every IntelliJ IDEA module built its own classpath. With the introduction of the new Java platform module system, there appeared two systems of modularity: the IntelliJ IDEA modules, and the new Java 9 modules that are configured using module-info.java. This documentation section describes IntelliJ IDEA modules.
For more information on Java 9 support in IntelliJ IDEA refer to the Support for Java 9 Modules in IntelliJ IDEA 2017.1 and Java 9 and IntelliJ IDEA blog posts.
Projects with multiple modules
IntelliJ IDEA allows you to have many modules in one project, and they shouldn't be just Java. You can have one module for a Java application and another module for a Ruby on Rails application or for any other supported technology.
An application that consists of a client side and a server side is a good example a two-module project.
Add a new module to your project
Right-click the top-level directory in the Project tool window and select New | Module. The New Module wizard opens.
From the list on the left, select a module type.
In the right-hand part of the dialog, select an SDK that you want to use from the Module SDK list. You can use the project SDK or specify a new one.
In the Additional Libraries and Frameworks section, select additional assets that you want to use in this module.
On the next step, name the module and specify the location of the content root and the .iml file. You can place them within or outside of the project.
Click Finish.
Gif
Import an existing module
You can import a module to your project by adding the .iml file from another project:
From the main menu, select File | New | Module from Existing Sources.
In the dialog that opens, specify the path the .iml file of the module that you want to import, and click Open.
By doing so, you are attaching another module to the project without physically moving any files. If you don't need the modules to be located in one folder, the module import is finished, and you can start working with the project normally.
tip
If you want the modules in the same folder, in the Project tool window, drag the imported module to the top-level directory. In this case, the contents of the imported module will be physically transferred to your project's folder.
note
For information on how to attach a Maven or Gradle project to your current project, refer to Link a Gradle project to an IntelliJ IDEA project and Link and unlink a Maven project.
Group modules
In IntelliJ IDEA, you can logically group modules. If you have a large project with multiple modules, grouping will make it easier to navigate through your project. Module groups can be nested: a group can contain other subgroups.
Group modules by fully qualified names
IntelliJ IDEA 2017.3 and later uses fully qualified names to group modules. For example, if you want to group all CDI modules, add the cdi
prefix to their names.
Open the Project Structure dialog Ctrl+Alt+Shift+S and click Modules.
Select the modules you want to group, open the context menu, and click Change Module Names.
Specify a prefix and apply the changes.
To view all modules on the same level in the Project Structure dialog, use the Flatten Modules context menu option.
tip
Module groups won't be visible in the Project tool window (Alt+1) if the Flatten Modules option is enabled there. You can disable it via the
button in the tool window header.
Gif