|
| 1 | +# Local Debugging Setup |
| 2 | + |
| 3 | +Follow the steps below to set up and run the **Document-Generation-Solution-Accelerator** locally. |
| 4 | + |
| 5 | + |
| 6 | + |
| 7 | +## Prerequisites |
| 8 | + |
| 9 | +Install these tools before you start: |
| 10 | +- [Visual Studio Code](https://code.visualstudio.com/) with the following extensions: |
| 11 | + - [Azure Tools](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-node-azure-pack) |
| 12 | + - [Bicep](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep) |
| 13 | + - [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python) |
| 14 | +- [Python 3.11](https://www.python.org/downloads/). **Important:** Check "Add Python to PATH" during installation. |
| 15 | +- [PowerShell 7.0+](https://github.com/PowerShell/PowerShell#get-powershell). |
| 16 | +- [Node.js (LTS)](https://nodejs.org/en). |
| 17 | +- [Git](https://git-scm.com/downloads). |
| 18 | +- [Azure Developer CLI (azd) v1.18.0+](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd). |
| 19 | +- [Microsoft ODBC Driver 17](https://learn.microsoft.com/en-us/sql/connect/odbc/download-odbc-driver-for-sql-server?view=sql-server-ver16) for SQL Server. |
| 20 | + |
| 21 | + |
| 22 | +## Setup Steps |
| 23 | + |
| 24 | +### Clone the Repository |
| 25 | + |
| 26 | +Choose a location on your local machine where you want to store the project files. We recommend creating a dedicated folder for your development projects. |
| 27 | + |
| 28 | +#### Using Command Line/Terminal |
| 29 | + |
| 30 | +1. **Open your terminal or command prompt. Navigate to your desired directory and Clone the repository:** |
| 31 | + ```bash |
| 32 | + git clone https://github.com/microsoft/document-generation-solution-accelerator.git |
| 33 | + ``` |
| 34 | + |
| 35 | +2. **Navigate to the project directory:** |
| 36 | + ```bash |
| 37 | + cd document-generation-solution-accelerator |
| 38 | + ``` |
| 39 | + |
| 40 | +3. **Open the project in Visual Studio Code:** |
| 41 | + ```bash |
| 42 | + code . |
| 43 | + ``` |
| 44 | + |
| 45 | +## Local Setup/Debugging |
| 46 | + |
| 47 | +Follow these steps to set up and run the application locally: |
| 48 | + |
| 49 | +### 1. Open the App Folder |
| 50 | +Navigate to the `src` directory of the repository using Visual Studio Code. |
| 51 | + |
| 52 | +### 2. Configure Environment Variables |
| 53 | +- Copy the `.env.sample` file to a new file named `.env`. |
| 54 | +- Update the `.env` file with the required values from your Azure resource group in Azure Portal App Service environment variables. |
| 55 | +- You can get all env value in your deployed resource group under App Service: |
| 56 | + |
| 57 | +- Alternatively, if resources were |
| 58 | +provisioned using `azd provision` or `azd up`, a `.env` file is automatically generated in the `.azure/<env-name>/.env` |
| 59 | +file. To get your `<env-name>` run `azd env list` to see which env is default. |
| 60 | + |
| 61 | +### 3. Start the Application |
| 62 | +- Run `start.cmd` (Windows) or `start.sh` (Linux/Mac) to: |
| 63 | + - Install backend dependencies. |
| 64 | + - Install frontend dependencies. |
| 65 | + - Build the frontend. |
| 66 | + - Start the backend server. |
| 67 | +- Alternatively, you can run the backend in debug mode using the VS Code debug configuration defined in `.vscode/launch.json`. |
| 68 | + |
| 69 | +## Running with Automated Script |
| 70 | + |
| 71 | +For convenience, you can use the provided startup scripts that handle environment setup and start both services: |
| 72 | + |
| 73 | +**Windows:** |
| 74 | +```cmd |
| 75 | +cd src |
| 76 | +.\start.cmd |
| 77 | +``` |
| 78 | + |
| 79 | +**macOS/Linux:** |
| 80 | +```bash |
| 81 | +cd src |
| 82 | +chmod +x start.sh |
| 83 | +./start.sh |
| 84 | +``` |
| 85 | + |
| 86 | +## Running Backend and Frontend Separately |
| 87 | + |
| 88 | +#### Step 1: Create Virtual Environment (Recommended) |
| 89 | + |
| 90 | +Open your terminal and navigate to the root folder of the project, then create the virtual environment: |
| 91 | + |
| 92 | +```bash |
| 93 | +# Navigate to the project root folder |
| 94 | +cd document-generation-solution-accelerator |
| 95 | + |
| 96 | +# Create virtual environment in the root folder |
| 97 | +python -m venv .venv |
| 98 | + |
| 99 | +# Activate virtual environment (Windows) |
| 100 | +.venv/Scripts/activate |
| 101 | + |
| 102 | +# Activate virtual environment (macOS/Linux) |
| 103 | +source .venv/bin/activate |
| 104 | +``` |
| 105 | + |
| 106 | +> **Note**: After activation, you should see `(.venv)` in your terminal prompt indicating the virtual environment is active. |
| 107 | +
|
| 108 | +#### Step 2: Install Dependencies and Run |
| 109 | + |
| 110 | +To develop and run the backend API locally: |
| 111 | + |
| 112 | +```bash |
| 113 | +# Navigate to the API folder (while virtual environment is activated) |
| 114 | +cd src/ |
| 115 | + |
| 116 | +# Upgrade pip |
| 117 | +python -m pip install --upgrade pip |
| 118 | + |
| 119 | +# Install Python dependencies |
| 120 | +pip install -r requirements.txt |
| 121 | + |
| 122 | +# Install Fronend Packages |
| 123 | +cd src/frontend |
| 124 | +npm install |
| 125 | +npm run build |
| 126 | + |
| 127 | +# Run the backend API |
| 128 | +cd src/ |
| 129 | + |
| 130 | +start http://127.0.0.1:50505 |
| 131 | +call python -m uvicorn app:app --port 50505 --reload |
| 132 | +``` |
| 133 | + |
| 134 | +> **Note**: Make sure your virtual environment is activated before running these commands. You should see `(.venv)` in your terminal prompt when the virtual environment is active. |
| 135 | +
|
| 136 | +The App will run on `http://127.0.0.1:50505/#/` by default. |
0 commit comments