# Deployment

## Deployment

This guide outlines the step-by-step process to deploy the On-Demand architecture, including configuring the API dashboard, setting up the Client-Gateway, and integrating the Data Layer.

***

### Step-by-Step Guide

#### 1. Configure On-Demand in the API Dashboard

1. **Log In:**
   * Access the [API Dashboard](https://dashboard.example.com) and log in with your account.
2. **Enable On-Demand Mode:**
   * Navigate to the **On-Demand Settings** section.
   * Enable the On-Demand mode for your account.
3. **Choose the Integration Option:**
   * **Webhooks:**
     * Enter the URLs for each operation (`/create`, `/import`, `/revoke`, `/verify`).
   * **Client-Gateway:**
     * Select the Gateway option to use our pre-configured solution.
4. **Generate Security Keys:**
   * Click **Generate Keys** to create:
     * `API_KEY`: Used by the SDK Client and Gateway for authentication.
     * `CLIENT_SECRET`: Used for internal communication within the On-Demand system.
5. **Save Configuration:**
   * Save the On-Demand settings to activate the mode.

***

#### 2. Deploy the Client-Gateway

The Client-Gateway is a pre-built service that simplifies the management of credential operations. You can deploy it using a pre-built Docker image or by building it locally.

**Option 1: Use the Pre-built Docker Image**

1. **Pull the Docker Image:**

   ```bash
   docker run -d -p 8080:8080 \
     -e API_BASE_URL=https://api.example.com \
     -e API_KEY=your-api-key \
     -e CLIENT_SECRET=your-client-secret \
     your-registry/client-gateway:latest

   ```
2. **Run the Gateway:** Use the following command to start the Gateway:

   `docker run -d -p 8080:8080`\
   `-e API_BASE_URL=https://api.example.com`\
   `-e API_KEY=your-api-key`\
   `-e CLIENT_SECRET=your-client-secret`\
   `your-registry/client-gateway:latest`

**Option 2: Build the Gateway Locally**

1. **Clone the Repository:**

   ```
   git clone https://github.com/your-repo/client-gateway.git
   cd client-gateway

   ```
2. Built docker image

`git clone https://github.com/your-repo/client-gateway.git cd client-`git clone <https://github.com/your-repo/client-gateway.git> cd client-gateway

3. Run Gateway

docker run -d -p 8080:8080\
-e API\_BASE\_URL=<https://api.example.com\\>
-e API\_KEY=your-api-key\
-e CLIENT\_SECRET=your-client-secret\
client-gateway

#### 3. Set Up the Data Layer

The Data Layer stores and manages sensitive data. You need to implement this layer based on your infrastructure.

1. **Choose a Database Technology:**
   * Supported options include MongoDB, PostgreSQL, MySQL, or others.
2. **Implement the Required Endpoints:**
   * Create endpoints for operations such as `/create`, `/import`, `/revoke`, and `/verify`.
   * Refer to the Data Layer section for example implementations.
3. **Configure the Gateway:**
   * Update the Gateway configuration to point to your Data Layer endpoints

`const DATA_LAYER_URL = 'http://your-database-service';`

#### 4. Test the Deployment

1. **Test SDK Integration:**
   * Use the SDK Client to make test requests for each operation (`create`, `import`, `revoke`, `verify`).
   * Ensure the requests are routed to the Gateway or Webhooks based on your configuration.
2. **Verify API Logs:**
   * Log in to the API Dashboard and check the logs to confirm that operations are being recorded.
3. **Check the Data Layer:**
   * Verify that data is being stored and managed correctly in your database.


---

# 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://docs.wallid.io/certishop-on-prem/deployment.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.
