# Modules

Modules group sets of functions and structures together in a namespace. Each source file is a separate module. Modules must be explicitly declared to be available for use. A module declaration is denoted by the keyword `module` followed by the module name.

```
module module_name
```

Modules can only be declared in the source root `main.lx` or in a `module.lx` file that is placed in a folder. Lexica will look for either a file or folder with the module name from the declaration location.

```
main.lx
module_name/
    module.lx
```

```
main.lx
module_name.lx
```

If both the file and folder exist then both sets of declarations in them will be processed.

Modules may also be declared inline inside a single file. The beginning of the module body is denoted by a colon.

```
module module_name:
    data Structure:
        field: Type,
```

External modules are not allowed to be declared inside a nested module.

```
module module_name:
    // This is NOT allowed.
    module external
```

