# Integration Main Module

## &#x20;Directory Structure

```
sample-integration/
└── integration.js
```

## Summary

The `integration.js` file is the entry point into your integration on the server.  The file runs on the server and is responsible for taking entities from the Polarity client, enriching or transforming them, and returning results back to the Polarity client.

{% hint style="info" %}
The `integration.js` file runs in its own process on the Polarity Server so if your integration crashes it will not also crash the server.
{% endhint %}

At a minimum your main module must export a `doLookup` method but it can also provide a `startup`, `validateOptions`, `onDetails`, and `onMessage` method. Each of these methods must be exported from your main module so that they are accessible to the Polarity Server's integration loader.

The minimum `integration.js` file which will properly load is as follows:

{% code title="integration.js" %}

```
function doLookup(entities, options, cb){
    cb(null, []);
}

module.exports = {
    doLookup: doLookup
}
```

{% endcode %}

## Method Hooks

The following table provides a summary of the special methods that can be implemented and exported from the `integration.js` file.

| Method                                                                                             | Required     | Description                                                                                                                                   |
| -------------------------------------------------------------------------------------------------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| [startup](https://docs.polarity.io/integrations/build-an-integration/main/startup)                 | optional     | Executed once when your  integration is started or restarted                                                                                  |
| [doLookup](https://docs.polarity.io/integrations/build-an-integration/main/dolookup)               | **required** | Enriches or transforms entities passed from the client and returns the enriched data.                                                         |
| [validateOptions](https://docs.polarity.io/integrations/build-an-integration/main/validateoptions) | optional     | Called anytime a user saves changes to their integration options                                                                              |
| [onDetails](https://docs.polarity.io/integrations/build-an-integration/main/ondetails)             | optional     | Executed when a user opens the details panel for your integration in the Overlay Window                                                       |
| [onMessage](https://docs.polarity.io/integrations/build-an-integration/main/onmessage)             | optional     | Used to send messages from your integration's front end code (component and template) to your integration's server side code (integration.js) |
