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

# On Power Platform

Once you have tested your custom application locally, you can deploy it to the Power Platform controller. The application should be
placed in the `/opt/plcnext/appshome/data` folder on the controller. There are two ways to get the `dep-ppl-app` repository
with the application onto the controller.

## Transfer the Application

<Tabs>
  <Tab title="Option 1: Git Clone (Recommended)">
    Clone the repository directly on the controller using Git. The benefit of this approach is that any changes you make
    to the repository can be pulled directly onto the controller using `git pull`.

    <Note>
      The controller needs access to the internet for this option.
    </Note>

    <Steps>
      <Step title="SSH into the Controller">
        Open a terminal and connect to the controller via SSH:

        ```bash theme={null}
        ssh admin@<controller-ip-address>
        ```
      </Step>

      <Step title="Navigate to the Target Folder">
        Navigate to the application data folder:

        ```bash theme={null}
        cd /opt/plcnext/appshome/data
        ```
      </Step>

      <Step title="Clone the Repository">
        Clone your forked `dep-ppl-app` repository:

        ```bash theme={null}
        git clone https://github.com/<your-username>/dep-ppl-app.git
        ```
      </Step>

      <Step title="Pull Updates (When Needed)">
        Whenever you push changes to your repository, you can pull them onto the controller:

        ```bash theme={null}
        cd /opt/plcnext/appshome/data/dep-ppl-app
        git pull
        ```
      </Step>
    </Steps>
  </Tab>

  <Tab title="Option 2: Copy using FileZilla">
    Use **FileZilla** to copy the entire `dep-ppl-app` repository folder to the controller.

    <Steps>
      <Step title="Open FileZilla">
        Open FileZilla (or another SFTP client) on your local machine.
      </Step>

      <Step title="Connect to Controller">
        Connect to the controller using:

        <ul>
          <li>Host: `controller_ip`</li>
          <li>Username: `admin`</li>
          <li>Password: `admin password`</li>
          <li>Port: `22`</li>
        </ul>
      </Step>

      <Step title="Navigate to Folders">
        <ul>
          <li>Navigate on the controller side to: `/opt/plcnext/appshome/data`</li>
          <li>Navigate on your local machine side to the folder containing the `dep-ppl-app` repository.</li>
        </ul>
      </Step>

      <Step title="Drag and Drop Repository">
        Drag and drop the `dep-ppl-app` folder from your local machine to the controller folder.
      </Step>

      <Step title="Verify File Transfer">
        Verify the file transfer was successful.
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Install and Run the Application

Once the repository is on the controller, follow these steps to install and run the application.

<Steps>
  <Step title="Navigate to the Repository">
    SSH into the controller and navigate to the repository folder:

    ```bash theme={null}
    cd /opt/plcnext/appshome/data/dep-ppl-app
    ```
  </Step>

  <Step title="Run the Install Script">
    Run the installation script. This will create a Python virtual environment, install all dependencies from
    `requirements.txt`, and set up a cronjob that automatically starts the application when the controller reboots.

    ```bash theme={null}
    bash install.sh
    ```
  </Step>

  <Step title="Start the Application">
    Manually start the application by running:

    ```bash theme={null}
    bash start.sh
    ```
  </Step>

  <Step title="Stop the Application">
    To stop the application at any time, run:

    ```bash theme={null}
    bash stop.sh
    ```
  </Step>
</Steps>

<Note>
  After running `bash install.sh`, the application will automatically start on every reboot of the controller thanks to
  the cronjob. You can always manually start or stop the application using `bash start.sh` and `bash stop.sh`.
</Note>
