# Coding Metrics Setup

Here’s a structured Hivel On-Prem Deployment Guide tailored for Coding Metrics Integration, including system requirements, architecture, data flow, and step-by-step deployment instructions.

***

### 🖥️ **System Requirements**

#### VM Specifications

| Resource         | Requirement      |
| ---------------- | ---------------- |
| **RAM**          | 8 GB             |
| **Storage**      | 50 GB minimum    |
| **CPUs**         | 2                |
| **Architecture** | AMD64 compatible |

***

### 🌐 **Technical Prerequisites**

#### Outbound Connectivity

Your environment must allow outbound connections to:

* Push logs to Hivel (for support and troubleshooting)
* Access Hivel APIs for:
  * Git repository analysis
  * Submitting coding metrics

#### Required API Endpoints

Ensure these URLs are accessible from your VM:

* `https://app.hivel.ai/hivelapi/gitutil/*`
* `https://app.hivel.ai/insightlyapi/webhook/*`

***

### 🧭 **System Architecture & Data Flow**

#### 🔧 System Components

| Component                    | Function                                                       |
| ---------------------------- | -------------------------------------------------------------- |
| **Customer VM**              | Hosts the Code Checkout and Metric Calculation process locally |
| **Hivel API Gateway**        | Authenticates requests using Customer ID and Secret            |
| **Hivel Processing Service** | Handles request processing and metadata storage                |
| **Hivel Database**           | Stores only metadata (Rework, New Work, Maintenance)           |

***

#### 🔄 Data Flow Overview

**✅ Phase 1: Data Retrieval**

1. The Customer VM sends a **GET request** (authenticated) to Hivel to check for unprocessed commits.
2. The request passes through:
   * **API Gateway** → **Processing Service** → **Database**
3. Metadata about pending commits is returned to the VM.

**🧠 Phase 2: Internal Processing (Local VM)**

1. **Repository Checkout**:

   The system securely clones each repository using authenticated Git operations. For each pending repository, the VM creates a temporary local directory and clones the remote repository using the provided credentials (username and personal access token). The checkout process is handled for invalid paths, authentication failures, and network issues. If repository cloning fails, the process logs the error and skips to the next repository. Upon successful cloning, the system processes the repository data and ensures proper cleanup by automatically closing and deleting the temporary repository files after processing is complete.
2. **Metric Calculation**: Once the repository is successfully cloned locally, the system performs three types of coding metric calculations:
   * **Rework**
   * **New Work**
   * **Maintenance**
   * *All processing occurs locally on the Customer VM with no source code transmitted externally.*

**📤 Phase 3: Results Submission**

1. Customer VM sends processed commit metadata (containing only Rework, New work, and Maintenance numbers) via POST request to an endpoint with authentication.
2. API Gateway validates → forwards to Hivel Service → saves in Hivel Database.

***

### 🚀 **Pre-Deployment Requirements**

Ensure the following are installed on your VM:

* ✅ **Docker**
* ✅ **AWS CLI**

***

### 📦 **Deployment Steps**

#### 1. **Obtain the Deployment Script**

* You’ll receive a `run.sh` file via email from Hivel.
* Save the file to your server.

#### 2. **Make the Script Executable**

```bash
chmod +x run.sh
```

#### 3. **Run the Script**

```bash
./run.sh
```

#### 4. **Enter Required Parameters** (prompted during script run):

All these will be provided via email

* `Customer ID`&#x20;
* `Customer Secret`
* `ECR Image Version`
* `Hivel AWS Access Key ID`
* `Hivel AWS Secret Access Key`
* `Hivel AWS Region`

#### 5. **Verify Installation**

* Check Docker container logs and status:

```bash
docker ps
docker logs <container-id>
```

***

### 🔐 **Security & Data Privacy Notes**

* No source code ever leaves your environment.
* Only commit metadata (Rework, New Work, Maintenance) is transmitted.
* All communication is secured via credential-based authentication.
* All temporary Git clones are auto-deleted post-analysis.

***

### 📩 Need Help?

If you experience issues during deployment or have questions, reach out to our support team at [**support@hivel.ai**](mailto:support@hivel.ai).


---

# 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.hivel.ai/integrations/on-prem-setup/coding-metrics-setup.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.
