# Build and Run Instructions

This guide explains how to build and run the Benefits Provider App UI.

## Running Locally

1. **Clone the Repository**

   ```bash
   git clone https://github.com/PSMRI/ubi-provider-ui.git
   cd ubi-provider-ui
   ```
2. **Install Dependencies**

   ```bash
   yarn install
   ```
3. **Set Up Environment**
   * Configure environment variables as specified in Environment Variables
4. **Start Development Server**

   ```bash
   yarn dev
   ```

   The application will be available at `http://localhost:5173`
5. **Build for Production**

   ```bash
   yarn build
   ```

   The build output will be in the `dist/` directory
6. **Preview Production Build**

   ```bash
   yarn preview
   ```

## Build Output Structure

The production build (`dist/` directory) contains:

* `index.html` - Entry point
* `assets/` - Optimized JavaScript, CSS, and other assets
* Static files (images, fonts, etc.)

## Common Issues and Solutions

1. **Port Already in Use**

   ```bash
   # Change port for development server
   VITE_PORT=3000 yarn dev
   ```
2. **Node Version Mismatch**

   ```bash
   # Use nvm to switch Node version
   nvm use 20
   ```
3. **Build Errors**
   * Clear node\_modules: `rm -rf node_modules`
   * Clear yarn cache: `yarn cache clean`
   * Reinstall dependencies: `yarn install`

## Deployment Options

You can host the UI on any hosting provider you prefer, such as **S3** and **CloudFront**.

Here is an example pipeline showing deployment to **S3** & **CloudFront Invalidation** using a CI/CD tool such as GitHub Actions.

* We are currently deploying the frontend on **S3 (not using Docker)**.\
  For detailed instructions, refer to the [**Frontend Deployment Documentation**](https://github.com/%3Cyour-repo%3E/%3Cpath-to-frontend-doc%3E).<br>


---

# 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://piramal-swasthya.gitbook.io/uba/toasters/provider-toaster/developer-guide/frontend-guide/benefits-provider-app-ui/build-and-run-instructions.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.
