# Ghaymah CLI Integration & Environment Strategy

This document outlines the deployment environment strategy and provides comprehensive documentation for installing, configuring, and authenticating with the **Ghaymah Command Line Interface (CLI)**.

---

# Table of Contents

- [Environment Strategy](#environment-strategy)
  - [Staging Environment](#staging-environment)
  - [Production Environment](#production-environment)
- [Ghaymah CLI](#ghaymah-cli)
  - [Prerequisites](#prerequisites)
  - [Installation](#installation)
  - [Authentication](#authentication)
  - [Core Commands](#core-commands)

---

# Environment Strategy

To ensure reliable deployments and stable software releases, Ghaymah uses separate environments for testing and production workloads.

| Feature | Staging | Production |
|----------|----------|------------|
| **Purpose** | Final testing, QA, and integration validation. Mirrors production configuration as closely as possible. | Live customer-facing environment with maximum stability and availability. |
| **Users** | Developers, QA engineers, and internal stakeholders. | End users and customers. |
| **Data** | Mock, seeded, or anonymized datasets. | Real production data. |
| **Deployment** | Automatic deployment after merging into the staging branch (Continuous Deployment). | Manual approval with version tracking (release tags or commit SHA). |
| **Resources** | Lower CPU and memory allocation to reduce infrastructure costs. | High availability, load balancing, monitoring, and autoscaling. |

---

# Ghaymah CLI

The **Ghaymah CLI** allows developers and CI/CD pipelines to interact with the platform directly from the terminal.

It can be used to:

- Authenticate with the platform
- Manage applications
- Deploy services
- View running applications
- Integrate deployments into CI/CD workflows

---

## Prerequisites

Before using the CLI, you must generate a **Personal Access Token**.

1. Log in to the **Ghaymah Web Console**.
2. Navigate to:

```
Account Settings
    └── Developer Settings
```

3. Generate a new **Personal Access Token**.
4. Copy the token immediately.

> **Note**
>
> The token is displayed only once. Store it securely.

---

## Installation

### Linux (Debian/Ubuntu/Linux Mint)

Install the CLI using:

```bash
curl -sL https://cli.ghaymah.systems/install.sh | sudo bash
```

Verify the installation:

```bash
ghaymah --version
```

---

## Authentication

For local development or automated CI/CD pipelines, authenticate using your Personal Access Token.

### Step 1 — Export the Token

```bash
export GHAYMAH_TOKEN="your_personal_access_token_here"
```

### Step 2 — Login

```bash
ghaymah login --token "$GHAYMAH_TOKEN"
```

If authentication succeeds, the CLI is ready to use.

---

# Core Commands

## List Applications

Display all deployed applications and their current health status.

```bash
ghaymah apps list
```

Example output:

```text
NAME           STATUS      REGION
frontend       Running     eu-central
backend        Running     eu-central
database       Running     eu-central
```

---

## Check CLI Version

```bash
ghaymah --version
```

---

## Display Help

```bash
ghaymah --help
```

---

# Environment Summary

| Environment | Deployment | Data | Approval |
|-------------|------------|------|----------|
| **Staging** | Automatic | Test/Mock | Not Required |
| **Production** | Manual | Live | Required |