# Introduction 
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project. 

# Getting Started
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
1.	Installation process
2.	Software dependencies
3.	Latest releases
4.	API references

# Build and Test
TODO: Describe and show how to build your code and run the tests. 

# Contribute
TODO: Explain how other users and developers can contribute to make your code better. 

If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
- [ASP.NET Core](https://github.com/aspnet/Home)
- [Visual Studio Code](https://github.com/Microsoft/vscode)
- [Chakra Core](https://github.com/Microsoft/ChakraCore)

# Prerequisites

Before setting up the project, ensure the following are installed:

- PHP 8.x or above
- Composer
- Web Server (Apache/Nginx)
---

# Project Setup

## 1. Clone the Repository

```bash
git clone <repository-url>
cd <project-folder>
```

---

## 2. Install Frontend Dependencies

From the project root directory, run:

```bash
composer install
```

---

## 3. Install Backend Dependencies

Navigate to the `api` directory and install backend dependencies:

```bash
cd api

composer install
```

---

## 4. Configure Environment Variables

Navigate to the `env` folder.

Locate the `.env` file and update the required configuration values according to your environment.

Typical values include:

- BASE_URL
- API_BASE_URL
- PORTAL_API_BASE_URL
- ROOT_DIR
- PORTAL_CODE
- DOMAIN
- PORTAL_API_DOMAIN
- ROOT_DIR

Example:

```env
PHALCON="5.9.0"
VERSION="1.0.0"
APP_ENV=""
PORTAL_CODE="spendedge"
CORE_DOMAIN = ""
DOMAIN=""
BASE_URL=""
API_BASE_URL="/api/data-insights/services"
PORTAL_API_BASE_URL="/api/portal-insights/services"
PORTAL_API_DOMAIN="/api/portal-insights/services"
ROOT_DIR="/var/www/html//"
STREAMING_API_URL=""

# Piwik Pro
IS_PIWIK_ENABLED="FALSE"
PIWIK_ENABLED=1
PIWIK_URL=""
PIWIK_ID=""

#PIWIK SETTINGS
ADDPIWIK = "FALSE"
PIWIK_ENABLED=1

#HUBSPOT SETTINGS
HUBSPOT_EMBED = "FALSE"
HUBSPOT_CODE = ""

```

> **Note:** Ensure all mandatory values are configured before running the application.

---
## 5. Update Database configurations
Open the following configuration file: 

```
api/_configs/db.config.php
```
copy the db.config.php from old folder to new folder

Example:

```php
<?php
/**
* PostgreSQL Database Config
* @var host (string)
* @var username (string)
* @var password (string)
* @var dbname (string); Database Name
*/
$DBCONFIG = array(
	'host'        => '',
    'username'    => '',
    'password'    => '',
    'dbname'      => '',
    'schema'      => ''
);

```

## 6. Update External API's 

Open the following configuration file: 

```
api/_configs/1.0/data.api.config.php
```

copy the data.api.config.php from old folder to new folder

Example:

```php
<?php

/** *************************************************************************
* External Data API (External Lambda API)*
** **************************************************************************/

/**
* Data APIs (External Lambda API) Information
* @author System Generated
*
* @var apiEndpoint (string) - API Endpopint
* @var authHeader (string)
* @var authKey (string)*
*
*/
return array (
    'apiList' => array (
        'aioverview' => array (
            'api' => '/aioverview',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'smartSearch' => array (
            'api' => '/smartSearch',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'getpdffullreportbypage' => array (
            'api' => '/getReportByPage',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'getReportBasicDetails' => array (
            'api' => '/getReportBasicDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'commoditieslist' => array (
            'api' => '/getCommoditiesDropdownList',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'commoditiesprices' => array (
            'api' => '/getCommodityPriceDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'currencieslist' => array (
            'api' => '/getCurrencyDropdownList',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'currenciesprices' => array (
            'api' => '/getCurrencyExchangeDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'indicatorslist' => array (
            'api' => '/getIndicatorsCountriesDropdown',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'indicatorsdata' => array (
            'api' => '/getMEIndicatorDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'ratecardlist' => array (
            'api' => '/getRatecardFilterDropdownDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'ratecarddata' => array (
            'api' => '/getRatecardBenchmarkDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'fetchmegatrendslist' => array (
            'api' => '/fetchReportsBasedOnModule',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'categoryreportslist' => array (
            'api' => '/categoryreportslist',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'moduleregiondropdownlist' => array(
            'api' => '/getModuleRegionDropdown_v2',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'fetchtrenddetails' => array (
            'api' => '/getMegatrendDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'costmodeldetails' => array (
            'api' => '/getCostModelDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'costmodeldropdownlist' => array (
            'api' => '/getCostModelDropdown',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'supplierslist' => array (
            'api' => '/getSuppliersList',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'supplierdetail' => array (
            'api' => '/getSupplierDetail',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'freightratedropdownlist' =>  array (
            'api' => '/freightratedropdownlist',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'freightratedata' =>  array (
            'api' => '/freightratedata',
            'method' => 'POST',
            'environment' => 'PRELIVE',
        ),
        'categoryinteligencedropdownlist' => array(
                'api' => '/categoryinteligencedropdownlist',
                'method' => 'POST',
                'environment' => 'PRELIVE'
            ),
        'categoryinteligencedata' => array(
            'api' => '/categoryinteligencedata',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'supplierDiscovery' => array(
                'api' => '/supplierDiscovery',
                'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'supplierDiscoveryHistory' => array(
            'api' => '/supplierDiscoveryHistory',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'supplierDiscoverySession' => array(
            'api' => '/supplierDiscoverySession',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'supplierDiscoverySimilar' => array(
            'api' => '/supplierDiscoverySimilar',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'streemingaichatbot' => array(
            'api' => '/mockaichat',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'whitepapers' => array(
            'api' => '/whitepapers',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'whitepapervideo' => array(
            'api' => '/getWhitepaperVideoUrl',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'commodityOutlook' => array(
            'api' => '/commodityOutlook',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'commodityDetails' => array(
            'api' => '/commodityDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'myBriefs' => array(
            'api' => '/myBriefs',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'pastBriefs' => array(
            'api' => '/pastBriefs',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'saveBriefs' => array(
            'api' => '/saveBriefs',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'getPdfMetainfo' => array(
            'api' => '/getPdfMetainfo',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'microIndicators' => array (
            'api' => '/microindicators',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'publicPagePublish' => array (
            'api' => '/publicPagePublish',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'tntitleform' => array (
            'api' => '/tntitleform',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'incentive-compensation' => array (
            'api' => '/incentive-compensation',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'se-commodity-console' => array (
            'api' => '/se-commodity-console',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'se-freight-rate-console' => array (
            'api' => '/se-freight-rate-console',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'rep-performance' => array (
            'api' => '/rep-performance',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'progress-monitoring' => array (
            'api' => '/progress-monitoring',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'currency-exchange-console' => array (
            'api' => '/currency-exchange-console',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'internalDataSearch' => array(
            'api' => '/internalDataSearch',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'costIntelligenceExamples' => array (
            'api' => '/costIntelligenceExamples',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'costIntelligence' => array (
            'api' => '',
            'method' => 'POST',
            'environment' => 'PRELIVE_V2'
        ),
        'costIntelligenceSearch' => array (
            'api' => '/costIntelligenceSearch',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'cmiFetchById' => array (
            'api' => '/cmiFetchById',
            'method' => 'POST',
            'environment' => 'MOCK'
        ),
        'searchBycmi' => array (
            'api' => '/searchBycmi',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'getCiByItemId' => array (
            'api' => '/getCiByItemId',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'cmiOverview' => array (
            'api' => '',
            'method' => 'POST',
            'environment' => 'PRELIVE_V2'
        ),
        'cmiMarketInsights' => array (
            'api' => '',
            'method' => 'POST',
            'environment' => 'PRELIVE_V2'
        ),
        'cmiPricingAndSuppliers' => array (
            'api' => '',
            'method' => 'POST',
            'environment' => 'PRELIVE_V2'
        ),
        'cmiStrategy' => array (
            'api' => '',
            'method' => 'POST',
            'environment' => 'PRELIVE_V2'
        ),
        'cmiRegionalInsights' => array (
            'api' => '',
            'method' => 'POST',
            'environment' => 'PRELIVE_V2'
        ),
        'getCmiCategoryName' => array (
            'api' => '',
            'method' => 'POST',
            'environment' => 'PRELIVE_V2'
        ),
        'fetchSowHistory' => array (
            'api' => '/fetchSowHistory',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'analyseSow' => array (
            'api' => '',
            'method' => 'POST',
            'environment' => 'PRELIVE_V2'
        ),
        'fetchSowAnalysisDetails' => array (
            'api' => '/fetchSowAnalysisDetails',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'fetchSowReport' => array (
            'api' => '/fetchSowReport',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'sowbenchmarks3fileupload' => array(
            'api'         => '',
            'method'      => 'PUT',
            'environment' => 'S3UPLOAD',
        ),
        'sowbenchmarks3fileupload' => array(
            'api'         => '',
            'method'      => 'PUT',
            'environment' => 'S3UPLOAD',
        ),
        'prismconfigjsonuploads3' => array(
            'api'         => '',
            'method'      => 'PUT',
            'environment' => 'S3PRISMUPLOAD',
        ),
        'weeklyprismconfigjsonuploads3' => array(
            'api'         => '',
            'method'      => 'PUT',
            'environment' => 'S3WEEKLYPRISMUPLOAD',
        ),
        'montlyprismconfigjsonuploads3' => array(
            'api'         => '',
            'method'      => 'PUT',
            'environment' => 'S3MONTHLYPRISMUPLOAD',
        ),
        'cmisearchhistory' => array(
            'api' => '/cmiSearchHistory',
            'method' => 'POST',
            'environment' => 'PRELIVE'
        ),
        'whitepaperpdffullreport' => array(
            'api' => '/getWhitepaperPdfFullReport',
            'method' => 'POST',
            'environment' => 'WHITEPAPER_PDF'
        )
    ),
    'environments' => array (
        'MOCK' => array (
            'apiEndPoint' => '',
            'apiPath' => '',
            'apiSecurityOn' => false,
            'apiAuthHeader' => '',
            'apiAuthType' => '',
            'apiAuthToken' => ''
        ),
        'PRELIVE' => array (
            'apiEndPoint' => '',
            'apiPath' => '',
            'apiSecurityOn' => false,
            'apiAuthHeader' => '',
            'apiAuthType' => '',
            'apiAuthToken' => ''
	),
	'PRELIVE_V2' => array (
           'apiEndPoint' => '',
           'apiPath' => '',
           'apiSecurityOn' => false,
           'apiAuthHeader' => '',
           'apiAuthType' => '',
           'apiAuthToken' => ''
	),
	'S3UPLOAD' => array(
            'apiEndPoint'   => '',
            'apiPath'       => '',
            'apiSecurityOn' => true,
            'apiAuthHeader' => 'x-api-key',
            'apiAuthType'   => '',
            'apiAuthToken'  => '',
	),
	'S3PRISMUPLOAD' => array(
            'apiEndPoint'   => '',
            'apiPath'       => '',
            'apiSecurityOn' => true,
            'apiAuthHeader' => 'x-api-key',
            'apiAuthType'   => '',
            'apiAuthToken'  => 'e',
        ),
        'DEMO' => array(
            'apiEndPoint' => '',
            'apiPath' => '',
            'apiSecurityOn' => true,
            'apiAuthHeader' => 'X-Authorization',
            'apiAuthType' => 'Bearer',
            'apiAuthToken' => ''
        ),
        'LIVE' => array (
            'apiEndPoint' => '',
            'apiPath' => '/prod',
            'apiSecurityOn' => true,
            'apiAuthHeader' => 'Authorization',
            'apiAuthType' => 'Bearer',
            'apiAuthToken' => ''
        ),
        'S3WEEKLYPRISMUPLOAD' => array(
            'apiEndPoint'   => '',
            'apiPath'       => '',
            'apiSecurityOn' => true,
            'apiAuthHeader' => 'x-api-key',
            'apiAuthType'   => '',
            'apiAuthToken'  => '',
        ),
        'S3MONTHLYPRISMUPLOAD' => array(
            'apiEndPoint'   => '',
            'apiPath'       => '',
            'apiSecurityOn' => true,
            'apiAuthHeader' => 'x-api-key',
            'apiAuthType'   => '',
            'apiAuthToken'  => '',
        ),
        'WHITEPAPER_PDF' => array(
            'apiEndPoint'   => '',
            'apiPath'       => '',
            'apiSecurityOn' => false,
            'apiAuthHeader' => '',
            'apiAuthType'   => '',
            'apiAuthToken'  => '',
        )
    )
);


```
Replace the URL with the appropriate endpoint for your environment.

copy the 
```
api/_configs/1.0/plans.config.json
```

If not created please copy from the pages/plans.config.json
```json
{
  "spendedge": {
    "portal_name": "spendedge",
    "plans": [
      {
        "plan_name": "PRO",
        "plan_code": "PRO",
        "reports_count": 2,
        "reports_period": "Month",
        "dashboard_count": 2,
        "dashboard_period": "Month",
        "dashboard_label": "1 dashboard/month",
        "status": "A"
      },
      {
        "plan_name": "PROMAX",
        "plan_code": "PROMAX",
        "reports_count": 12,
        "reports_period": "Year",
        "dashboard_count": 5,
        "dashboard_period": "Month",
        "dashboard_label": "5 dashboards/month",
        "status": "A"
      },
      {
        "plan_name": "BUSINESS",
        "plan_code": "BUSINESS",
        "reports_count": 60,
        "reports_period": "Year",
        "dashboard_count": 10,
        "dashboard_period": "Month",
        "dashboard_label": "10 dashboards/month",
        "status": "A"
      },
      {
        "plan_name": "ENTERPRISE",
        "plan_code": "ENTERPRISE",
        "reports_count": -1,
        "reports_period": "Year",
        "dashboard_count": -1,
        "dashboard_period": "Month",
        "dashboard_label": "Unlimited dashboards",
        "status": "A"
      }
    ]
  }
}

```

> **Note:** Ensure all mandatory values are configured before running the application.

## 7. Update or add .htaccess files

```
RewriteEngine On

RewriteCond %{THE_REQUEST} \s/+(.+?)\.php[\s?] [NC]
RewriteRule ^integration_callback.php$ integration_callback.php [L,NC]
RewriteRule ^samltesting/public/ - [L] 
RewriteRule ^samltesting/(.*)$ /samltesting/public/$1 [L]
RewriteRule ^samltesting.php$ samltesting.php [L,NC]
RewriteCond %1 !^(index|callback|404|401|access-denied)$ [NC]
RewriteCond %1 !^[A-Za-z]: [NC]
RewriteRule ^ %1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

RewriteRule (^|/)\. - [F]
RewriteRule ^\.env - [F]
RewriteRule ^app/ - [F]

RewriteRule ^callback(?:\.php)?$ callback.php [L,NC]
RewriteRule ^ index.php [L]

```

# Running the Application

Configure your web server to point to the project root.

Once configured:

- Access the frontend using your configured domain or localhost URL.
- Ensure the backend API is accessible.
- Confirm Stripe configuration is correct before testing subscription payments.

---

# Support

For any setup issues or configuration assistance, contact the project development team.