# Blueprint Modules

## What is a Blueprint Module?

A **Blueprint module** is a node module that contains a reusable Blueprint entities that can be applied to a Blueprint application. The goal of a Blueprint module is to provide functionality that address a certain application concern. For example, a Blueprint module many provide support for MongoDB, or it may implement a solution for integrating a paywall into your application. This way, the Blueprint application developer does not have to implement the solution themselves.

## Creating a Blueprint Module

It is not hard to create a Blueprint module. First, you need to create a standard Blueprint application.

```bash
blueprint new [name]
```

After the Blueprint application is created, add `blueprint-module` to the `keywords` property in the generated `packaged.json` file. Now, save the application and publish it using `npm`.

You have now created your first Blueprint module.

## Loading Blueprint Modules

The Blueprint application automatically loads all Blueprint modules. It does so by using a postorder depth-first search of the dependencies defined in `package.json`, and loading all modules that have the keyword `blueprint-module`. This ensures that all dependencies are available to the parent module, or application, when it is loaded into memory.

{% hint style="info" %}
A Blueprint module can depend on other Blueprint modules.
{% endhint %}

When a Blueprint module is loaded into memory, the module is added to the Blueprint application and the entities in the Blueprint module are merged with the entities in the application. If an entity with the same type and name already appears in the application, it is overwritten. The overwritten entity, however, will still be accessible via the application. You just have to include the Blueprint module name when you are perform a [lookup operation](/developer-guide/application-resources/lookup-operation.md). For example

```javascript
blueprint.lookup ('module-a:model:message');    // using lookup() method
blueprint.model ('module-a:message');           // using model() method 
```

## Supported Entities

The following entities can be loaded from a Blueprint module into a Blueprint application:

* Controllers
* Listeners
* Models
* Policies
* Resources
* Routers
* Sanitizers
* Services
* Validators

{% hint style="info" %}
When a router is loaded from a Blueprint module, its routes *are not* automatically added to the Blueprint application. Instead, you must [mount a router](https://onehilltech.gitbook.io/blueprint/developer-guide/routers-and-controllers/routers#mounting-external-routers) for it to be useable from the Blueprint application.
{% endhint %}

## Module Directory

The following is a list of know Blueprint modules.

### Authentication

* [Gatekeeper](https://github.com/onehilltech/gatekeeper) - Token-based authentication

### Communication/Messaging

* [Greenlock](https://github.com/onehilltech/blueprint-greenlock) - Let's Encrypt support for free, automated SSLs
* [Firebase Messaging](https://github.com/onehilltech/blueprint-firebase-messaging) - Google Firebase Messaging support
* [Socket.IO](https://github.com/onehilltech/blueprint-socket.io) - Socket.IO support

### Data Models

* [MongoDB](https://github.com/onehilltech/blueprint-mongodb) - MongoDB support via Mongoose

### Documentation

* [Swagger UI](https://github.com/onehilltech/blueprint-swagger) - generate and view Swagger specification from application


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://blueprint.onehilltech.com/developer-guide/untitled-1.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
