> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Building & deploying Atoti Market Risk

> Guide to building and deploying Atoti Market Risk, covering Artifactory access configuration and build steps.

## Building the Project

### Set up Artifactory access

You can download all Maven dependencies from Artifactory by setting up your Maven settings file:

```xml theme={"languages":{"custom":["/engine/python-sdk/6.2/languages/pycon.tmLanguage.json"]}}
<settings>
    <profiles>
        <profile>
            <id>default</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>

            <repositories>
                <repository>
                    <id>ActiveViamMvn</id>
                    <name>ActiveViam Maven Repository</name>
                    <url>https://activeviam.jfrog.io/artifactory/mvn/</url>
                </repository>
                <repository>
                    <id>ActiveViamGeneric</id>
                    <name>ActiveViam Generic Repository</name>
                    <url>https://activeviam.jfrog.io/artifactory/generic/</url>
                </repository>
            </repositories>
        </profile>
    </profiles>

    <servers>
        <server>
            <id>ActiveViamMvn</id>
            <username>username</username>
            <password>password</password>
        </server>
        <server>
            <id>ActiveViamGeneric</id>
            <username>username</username>
            <password>password</password>
        </server>
    </servers>
</settings>
```

To download the dependencies for the UI, you need to set up access to Artifactory via npm:

`npm login --scope @activeviam --registry https://activeviam.jfrog.io/artifactory/npm/`

The result is the following message:
`Logged in as username to scope @activeviam on https://activeviam.jfrog.io/artifactory/npm/.`

If the scope isn't mentioned in the message, change the command to the following:
`npm login --scope=@activeviam --registry=https://activeviam.jfrog.io/artifactory/npm/`

### Source

From the distribution folder of the version to build, linked at the top of each release in the [Release notes](https://docs.activeviam.com/solutions/market-risk/6.0/dev/dev-release/release-notes.md), download and unzip the source files. The zipped file
is called *atoti-market-risk-**\<version number>**.zip*.

### Build

1. To compile the source code using Maven, you must set your `MAVEN_OPTS` environment variable, to pass Java options, like so: `MAVEN_OPTS="-Xss8m"`.

> [!TIP]
>
> You may need to change the stack size with this option. Here are some useful parameters:
>
> ```
> -Xms<size>        set initial Java heap size
> -Xmx<size>        set maximum Java heap size
> -Xss<size>        set java thread stack size
> ```

2. Once you have added all the Maven repositories and extracted the
   source code, run `mvn install` on the parent pom file to build the
   entire project.

   This will build the Atoti Server executable JAR file
   (mr-application/target/mr-application-exec.jar)

3. When the build is complete, you must deploy it. See
   [Deployment](#deployment)

4. Build the standalone UI application using npm or yarn, or download the prebuilt application from the distribution folder.

5. Deploy the UI application.

## Configuration

See [Project configuration](https://docs.activeviam.com/solutions/market-risk/6.0/dev/dev-getting-started/dev-configure-acc/configuration-project.md).

## Deployment

### Atoti Server

The mr-application is a Spring Boot application that builds an executable JAR. To deploy the
executable JAR files, use the following command:

```
java -jar mr-application-exec.jar
```

To configure the port and context path of the application, two properties
are used: `server.port` and `server.servlet.context-path`. The default
values are in `resources/application.yaml`, the standard configuration
file for Spring Boot applications.

For example:

```
java -jar mr-application-exec.jar --server.port=<port>
```

This can also be changed by externalizing the properties files (see
[Externalising Properties Files](#externalizing-properties-files)).

Atoti Server will be available at: http\://\<your hostname>:10010/mr-application/

### Atoti UI

Atoti UI is a static website that can be deployed in any way you see
fit. All the necessary files are to be found in the */build* folder
after the project has been built.

The UI should be built using Yarn or NPM. If customizations are not required, a prebuilt UI is available in the distribution folder.

### Externalizing Properties Files

In the default implementation, all the necessary properties are within
the project. A number of properties files have been externalized and can
be overridden with an external file using JVM variables. You may wish to
use this functionality if you are running the project in different
environments. Below is a list of the files together with their
respective variable names:

There are two options to override default properties:

* OPTION 1: Command line arguments, for example:
  "mr.data-load.csv.dataset=/path/to/folder .

> [!NOTE]
>
> We are using "`--`" when providing the option after calling the jar. If the option was called first then "`-D`" is used.

* OPTION 2: Create a properties file, for example:
  application.properties and add your
  property overrides. Then pass it to the main using the command line
  argument:
  "spring.config.additional-location=/\<path>/application.properties

  For more details, see the [Spring Boot documentation](https://docs.spring.io/spring-boot/docs/2.1.9.RELEASE/reference/html/boot-features-external-config.html#boot-features-external-config-application-property-files).
