Elyse Frontend Deployment Package
==================================

Version: 2026.03.22-1951
Build Date: 2026-03-22 19:51:43
Configuration: Production (Optimized)
Package Type: Static files (HTML, JavaScript, CSS)

TARGET ENVIRONMENT: Any web server (IIS, nginx, Apache, etc.)

This frontend package works with BOTH SERVER and WORKGROUP backend deployments.
Configure the backend URL in assets/config.json after deployment.

================================================================================
IMPORTANT: FRONTEND INSTALLATION FOR MULTIPLE USERS ON SAME MACHINE
================================================================================
PREREQUISITES CHECKLIST

[ ] IIS Installed (with Static Content & URL Rewrite)

[ ] ARR 3.0 Installed

[ ] Administrative Access to PowerShell

[ ] Backend URL / Port identified
================================================================================

SCENARIO A: Single Machine with Multiple User Accounts (WORKGROUP)
-------------------------------------------------------------------

When deploying to a single machine with multiple Windows user accounts:

FRONTEND: Install ONCE (Shared)
- The frontend is installed in a shared location (e.g., C:\inetpub\wwwroot\Elyse\frontend)
- All users access the SAME frontend files
- The frontend is just static HTML/CSS/JavaScript - no user-specific data
- Only one frontend installation is needed per machine

BACKEND: Install separately for each user (Isolated)
- Each user must have their own backend instance
- User Alice: C:\Users\Alice\AppData\Local\ElyseApp\Backend\
- User Bob: C:\Users\Bob\AppData\Local\ElyseApp\Backend\
- User Carol: C:\Users\Carol\AppData\Local\ElyseApp\Backend\
- Each backend runs as a Windows Service under that user's account
- Each backend connects to SQL Server with that user's Windows credentials

HOW IT WORKS:
1. All users share the same frontend (C:\inetpub\wwwroot\Elyse\frontend)
2. Frontend calls http://localhost:5000/api (configured in config.json)
3. When Alice logs in:
   - Alice's backend service starts (runs as COMPUTERNAME\Alice)
   - Frontend connects to Alice's backend on port 5000
   - Backend connects to SQL Server as COMPUTERNAME\Alice
   - SQL Server returns only Alice's data
4. When Bob logs in (Alice logs out):
   - Alice's backend service stops
   - Bob's backend service starts (runs as COMPUTERNAME\Bob)
   - Frontend connects to Bob's backend on port 5000
   - Backend connects to SQL Server as COMPUTERNAME\Bob
   - SQL Server returns only Bob's data

SECURITY:
- The frontend has no user-specific data - it's just a UI shell
- All security is enforced by the backend and SQL Server
- Each user's backend is isolated in their AppData folder
- SQL Server uses Windows Authentication to identify each user
- Database ACLs control what data each user can access

SUMMARY:
- Frontend: Install ONCE per machine (shared by all users)
- Backend: Install ONCE per user (isolated in each user's AppData)
- Each user gets their own data based on their Windows account

================================================================================

PACKAGE CONTENTS:
- index.html              (Main application entry point)
- assets/config.json      (Runtime configuration - EDIT THIS)
- assets/config.template.json (Configuration template)
- assets/*.csv            (Application configuration files)
- *.js, *.css             (Optimized application bundles)
- web.config              (IIS URL rewriting configuration)

================================================================================
DEPLOYMENT OVERVIEW
================================================================================

Choose ONE of two web server options:

OPTION A: IIS (Internet Information Services)
  - Recommended for production environments
  - Built into Windows Server and Windows 10/11 Pro
  - Runs as Windows Service (auto-starts on boot)
  - More robust and feature-rich

OPTION B: Node.js http-server
  - Simpler alternative if IIS not available
  - Requires Node.js installation
  - Can be configured as Windows Service (auto-starts on boot)
  - Suitable for workgroup deployments

================================================================================
OPTION A: DEPLOYMENT WITH IIS
================================================================================

STEP 1: INSTALL IIS
-------------------
IIS must be installed before deploying the frontend.

On Windows Server:
1. Open Server Manager
2. Click "Add roles and features"
3. Click "Next" until "Server Roles"
4. Check "Web Server (IIS)"
5. Click "Add Features" when prompted
6. Click "Next" until "Role Services"
7. Ensure these are checked:
   - Web Server > Common HTTP Features > Static Content
   - Web Server > Common HTTP Features > Default Document
   - Management Tools > IIS Management Console
8. Click "Next" then "Install"
9. Wait for installation to complete
10. Click "Close"

On Windows 10/11 Pro:
1. Open Control Panel
2. Click "Programs and Features"
3. Click "Turn Windows features on or off"
4. Check "Internet Information Services"
5. Expand "Internet Information Services"
6. Expand "World Wide Web Services"
7. Expand "Application Development Features"
8. Check "WebSocket Protocol" (optional but recommended)
9. Expand "Common HTTP Features"
10. Ensure these are checked:
    - Default Document
    - Static Content
11. Expand "Web Management Tools"
12. Check "IIS Management Console"
13. Click "OK"
14. Wait for installation to complete
15. Click "Close"

Verify IIS Installation:
1. Open web browser
2. Navigate to http://localhost
3. You should see the IIS default page

STEP 2: INSTALL URL REWRITE MODULE (REQUIRED FOR ANGULAR ROUTING)
------------------------------------------------------------------
The URL Rewrite module is required for Angular routing to work correctly.

1. Download URL Rewrite Module:
   https://www.iis.net/downloads/microsoft/url-rewrite

2. Run the installer (rewrite_amd64_en-US.msi)
3. Accept license agreement
4. Click "Install"
5. Wait for installation to complete
6. Click "Finish"

Note: If you skip this step, direct URL navigation in the application will fail.

STEP 3: COPY FILES TO WEB SERVER
Using Windows Explorer or Remote Desktop:

1. Create deployment directory:
   Recommended: C:\inetpub\wwwroot\Elyse\frontend

2. Extract the ZIP file

3. Copy ALL files from the extracted folder to C:\inetpub\wwwroot\Elyse\frontend\

Verify: Directory should contain index.html, assets folder, and various .js/.css files

STEP 4: CONFIGURE BACKEND API URL
----------------------------------
Using Notepad or any text editor:

1. Navigate to C:\inetpub\wwwroot\Elyse\frontend\assets\
2. Open config.json
3. Edit the apiUrl to point to your backend server:

   FOR SERVER DEPLOYMENT (backend on separate server):
   {
     "apiUrl": "http://SERVER-HOSTNAME:8080/api"
   }
   
   Replace SERVER-HOSTNAME with the actual server hostname or IP address.
   Port 8080 is the default for SERVER deployments (configured in backend .env file).
   
   Examples:
   - "apiUrl": "http://elyse-server:8080/api"
   - "apiUrl": "http://elyse-server.domain.com:8080/api"
   - "apiUrl": "http://192.168.1.50:8080/api"
   
   FOR WORKGROUP DEPLOYMENT (backend on same machine):
   {
     "apiUrl": "http://localhost:5000/api"
   }

4. Save the file

IMPORTANT: You can change this URL anytime without rebuilding the frontend.

STEP 5: CONFIGURE IIS
---------------------
Open IIS Manager:
1. Press Windows key
2. Type "IIS Manager"
3. Press Enter

Create a new website:
1. In IIS Manager, expand the server node in left panel
2. Right-click "Sites" -> "Add Website"
3. Enter the following:
   - Site name: Elyse
   - Application pool: DefaultAppPool
   - Physical path: C:\inetpub\wwwroot\Elyse\frontend
   - Binding Type: http
   - IP address: All Unassigned
   - Port: 8080
   - Host name: (leave blank)
4. Click OK
5. IIS must be able to load the .md help files:
   - Select the site.   
   - Double-click MIME Types.  
   - Click Add... in the right sidebar
   - Enter .md in the filename extension and enter text/markdown in the MIME type field. 
   - Click Apply. 
6. Install IIS Modules: URL Rewrite and ARR 3.0. if not already. 
7. Open PowerShell as Administrator and run the following script to enable ARR proxy mode
   Note that ARR must be installed and IIS Manager must be restarted before running the following.
	# 1. Ensure the WebAdministration module is loaded
	Import-Module WebAdministration
	# 2. Enable the Proxy setting in ARR (Crucial for the 'Rewrite' action to work)
	Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/proxy" -name "enabled" -value "True"
	# 3. Optional: Set a timeout if your database queries take longer than 30 seconds
	Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.webServer/proxy" -name "timeout" -value "00:02:00"
	Write-Host "IIS Proxy Mode has been enabled successfully." -ForegroundColor Green
8. In IIS click on the Server Note > Application Request Routing Cache > Server Proxy Settings > and check the box 
   "Enable proxy".  (Othewise a 502.3 Bad Gateway error will occur.)
9. The new site should start automatically
   If not, select "Elyse" site and click "Start" in the Actions panel
10. Verify web.config is present:
   - Navigate to C:\inetpub\wwwroot\Elyse\frontend\
   - Confirm web.config file exists
   - This file enables Angular routing

STEP 6: CONFIGURE WINDOWS FIREWALL (IF ACCESSING FROM OTHER MACHINES)
----------------------------------------------------------------------
If users will access the frontend from other computers:

1. Open Windows Defender Firewall with Advanced Security:
   - Press Windows key
   - Type "Windows Firewall with Advanced Security"
   - Press Enter

2. Click "Inbound Rules" in left panel

3. Click "New Rule" in right panel

4. Select "Port" and click "Next"

5. Select "TCP" and enter port number (e.g., 80 or 8080)

6. Click "Next"

7. Select "Allow the connection"

8. Click "Next"

9. Check all profiles (Domain, Private, Public)

10. Click "Next"

11. Name: "Elyse Frontend HTTP"

12. Click "Finish"

STEP 7: FOR DOMAIN DEPLOYMENT
Service Principal Names (SPNs) 
For KCD to work, a Domain Admin must run these commands:
1.	setspn -S HTTP/YourVMName YourServiceAccount
2.	setspn -S MSSQLSvc/YourSQLServerName:1433 YourServiceAccount
3.	In Active Directory, the VM's Service Account must be "Trusted for delegation to specified services only" (pointing to the SQL Server).


STEP 8: TEST DEPLOYMENT
-----------------------
1. Open a web browser

2. Navigate to: http://localhost:8080

3. The application should load and display the main interface

If you see errors, check:
- Backend is running (for WORKGROUP: check Windows Services for "ElyseBackend")
- Backend URL in assets/config.json is correct
- Test backend directly: http://localhost:5000/api/eula/read

STEP 9: CREATE DESKTOP SHORTCUT (OPTIONAL)
-------------------------------------------
To create a shortcut with custom icon for easy access:

METHOD 1 - Using Windows Shortcut Wizard:
1. Right-click on the Desktop
2. Select "New" -> "Shortcut"
3. Enter the location: http://localhost:8080
4. Click "Next"
5. Enter a name: Elyse Application
6. Click "Finish"
7. Right-click the new shortcut and select "Properties"
8. Click "Change Icon" button
9. Click "Browse" and navigate to: C:\inetpub\wwwroot\Elyse\frontend\elyse.ico
10. Click OK, then OK again

METHOD 2 - Create Internet Shortcut File with Icon:
1. Open Notepad
2. Type the following:
   [InternetShortcut]
   URL=http://localhost:8080
   IconFile=C:\inetpub\wwwroot\Elyse\frontend\elyse.ico
   IconIndex=0
3. Save as: Elyse.url (on Desktop or any location)
4. The shortcut will display with the Elyse icon
5. Double-click to open the application

Note: The elyse.ico file is included in the deployment package and will be
available at C:\inetpub\wwwroot\Elyse\frontend\elyse.ico after deployment.

STEP 10: CONFIGURE HTTPS (OPTIONAL BUT RECOMMENDED)
--------------------------------------------------
For production deployments, configure HTTPS:

In IIS Manager:
1. Obtain SSL certificate (from CA or self-signed for testing)
2. Right-click your site -> "Edit Bindings"
3. Click "Add"
4. Type: https, Port: 443
5. Select your SSL certificate
6. Click OK

Update config.json to use https:
{
  "apiUrl": "https://SERVER-HOSTNAME:8080/api"
}

================================================================================
OPTION B: DEPLOYMENT WITH NODE.JS HTTP-SERVER
================================================================================

This option is simpler than IIS but requires Node.js installation.
The http-server will be configured as a Windows Service to auto-start on boot.

STEP 1: INSTALL NODE.JS
-----------------------
Node.js must be installed to run http-server.

1. Download Node.js LTS (Long Term Support) version:
   https://nodejs.org/

2. Run the installer (node-vXX.XX.X-x64.msi)

3. Installation wizard:
   - Click "Next"
   - Accept license agreement
   - Click "Next"
   - Installation path: C:\Program Files\nodejs\ (default)
   - Click "Next"
   - Ensure "Add to PATH" is checked
   - Click "Next"
   - Click "Install"
   - Click "Finish"

4. Verify installation:
   - Open Command Prompt (cmd.exe)
   - Type: node --version
   - Should display version number (e.g., v20.11.0)
   - Type: npm --version
   - Should display version number (e.g., 10.2.4)

STEP 2: INSTALL HTTP-SERVER
----------------------------
1. Open Command Prompt as Administrator:
   - Press Windows key
   - Type "cmd"
   - Right-click "Command Prompt"
   - Select "Run as administrator"

2. Install http-server globally:
   npm install -g http-server

3. Wait for installation to complete

4. Verify installation:
   http-server --version

STEP 3: COPY FILES TO DEPLOYMENT DIRECTORY
-------------------------------------------
1. Create deployment directory:
   mkdir C:\Elyse\frontend

2. Extract the ZIP file

3. Copy ALL files from the extracted folder to C:\Elyse\frontend\

Verify: Directory should contain index.html, assets folder, and various .js/.css files

STEP 4: CONFIGURE BACKEND API URL
----------------------------------
Using Notepad:

1. Navigate to C:\Elyse\frontend\assets\
2. Open config.json
3. Edit the apiUrl:

   FOR WORKGROUP DEPLOYMENT (backend on same machine):
   {
     "apiUrl": "http://localhost:5000/api"
   }
   
   FOR SERVER DEPLOYMENT (backend on separate server):
   {
     "apiUrl": "http://SERVER-HOSTNAME:8080/api"
   }
   
   Replace SERVER-HOSTNAME with the actual server hostname or IP address.
   Port 8080 is the default for SERVER deployments.

4. Save the file

STEP 5: INSTALL NSSM (NON-SUCKING SERVICE MANAGER)
---------------------------------------------------
NSSM allows http-server to run as a Windows Service (auto-start on boot).

1. Download NSSM:
   https://nssm.cc/download

2. Extract the ZIP file (e.g., nssm-2.24.zip)

3. Copy the appropriate executable to a permanent location:
   - For 64-bit Windows: Copy nssm-2.24\win64\nssm.exe to C:\Windows\System32\
   - For 32-bit Windows: Copy nssm-2.24\win32\nssm.exe to C:\Windows\System32\

4. Verify installation:
   - Open Command Prompt
   - Type: nssm
   - Should display NSSM help text

STEP 6: CREATE WINDOWS SERVICE FOR HTTP-SERVER
-----------------------------------------------
1. Open Command Prompt as Administrator

2. Create the service:
   nssm install ElyseFrontend

3. NSSM Service Installer window will open:

   Application tab:
   - Path: C:\Program Files\nodejs\node.exe
   - Startup directory: C:\Elyse\frontend
   - Arguments: C:\Program Files\nodejs\node_modules\http-server\bin\http-server -p 8080 -c-1

   Details tab:
   - Display name: Elyse Frontend
   - Description: Elyse Frontend Web Server
   - Startup type: Automatic

   I/O tab:
   - Output (stdout): C:\Elyse\frontend\http-server.log
   - Error (stderr): C:\Elyse\frontend\http-server-error.log

4. Click "Install service"

5. Start the service:
   nssm start ElyseFrontend

6. Verify service is running:
   nssm status ElyseFrontend
   
   Should display: SERVICE_RUNNING

STEP 7: CONFIGURE WINDOWS FIREWALL
-----------------------------------
If users will access the frontend from other computers:

1. Open Windows Defender Firewall with Advanced Security

2. Click "Inbound Rules" -> "New Rule"

3. Select "Port" -> "Next"

4. Select "TCP" and enter port: 8080

5. Click "Next"

6. Select "Allow the connection" -> "Next"

7. Check all profiles -> "Next"

8. Name: "Elyse Frontend HTTP" -> "Finish"

STEP 8: TEST DEPLOYMENT
-----------------------
1. Open web browser

2. Navigate to:
   - Local: http://localhost:8080
   - Remote: http://your-server-name:8080 or http://your-server-ip:8080

3. Application should load and display the login page or main interface

4. Check logs if issues occur:
   - C:\Elyse\frontend\http-server.log
   - C:\Elyse\frontend\http-server-error.log

STEP 9: CREATE DESKTOP SHORTCUT (OPTIONAL)
-------------------------------------------
To create a shortcut with custom icon:

METHOD 1 - Using Windows Shortcut Wizard:
1. Right-click on the Desktop
2. Select "New" -> "Shortcut"
3. Enter the location: http://localhost:8080
4. Click "Next"
5. Enter a name: Elyse Application
6. Click "Finish"
7. Right-click the new shortcut and select "Properties"
8. Click "Change Icon" button
9. Click "Browse" and navigate to: C:\Elyse\frontend\elyse.ico
10. Click OK, then OK again

METHOD 2 - Create Internet Shortcut File with Icon:
1. Open Notepad
2. Type the following:
   [InternetShortcut]
   URL=http://localhost:8080
   IconFile=C:\Elyse\frontend\elyse.ico
   IconIndex=0
3. Save as: Elyse.url (on Desktop or any location)
4. Double-click to open the application

STEP 10: VERIFY AUTO-START ON BOOT
-----------------------------------
1. Restart the computer

2. After restart, open web browser

3. Navigate to http://localhost:8080

4. Application should load automatically (service started on boot)

MANAGING THE HTTP-SERVER SERVICE:
----------------------------------
Stop service:    nssm stop ElyseFrontend
Start service:   nssm start ElyseFrontend
Restart service: nssm restart ElyseFrontend
Remove service:  nssm remove ElyseFrontend confirm

View service status:
1. Press Windows key
2. Type "services.msc"
3. Press Enter
4. Find "Elyse Frontend" in the list
5. Status should show "Running"
6. Startup Type should show "Automatic"

================================================================================
COMMON TO BOTH OPTIONS: TROUBLESHOOTING
================================================================================

Application won't load:
- Verify all files were copied correctly
- Check IIS site/application is started
- Check Windows Event Viewer for IIS errors
- Verify physical path in IIS matches deployment directory

Blank page or "Cannot GET /" error:
- Verify index.html exists in deployment directory
- Check IIS has Static Content feature installed
- Verify web.config is present for URL rewriting

"Failed to load config.json":
- Verify assets/config.json exists
- Check file permissions (IIS user needs read access)
- Check browser console for exact error

Cannot connect to backend:
- Verify backend is running
- Test backend URL directly in browser
- Check apiUrl in config.json is correct
- Verify firewall allows connection to backend port
- Check CORS configuration on backend

================================================================================
RUNTIME CONFIGURATION
================================================================================

KEY FEATURE: The backend API URL is loaded from assets/config.json at runtime.

This means:
- You can change the backend URL without rebuilding the frontend
- Same frontend package works for development, testing, and production
- Just edit assets/config.json and refresh the browser

To change backend URL:
1. Edit C:\inetpub\wwwroot\Elyse\frontend\assets\config.json
2. Change "apiUrl" to new backend URL
3. Save file
4. Refresh browser (Ctrl+F5 to clear cache)

No IIS restart or application rebuild required.

================================================================================
UPDATING TO A NEW RELEASE
================================================================================

When a new version of the frontend is released, follow these steps to update:

OPTION A: UPDATING IIS DEPLOYMENT
----------------------------------

STEP 1: BACKUP CURRENT VERSION
-------------------------------
Open PowerShell as Administrator:

$FrontendPath = "C:\inetpub\wwwroot\Elyse\frontend"
$BackupPath = "C:\inetpub\wwwroot\Elyse\frontend_backup_$(Get-Date -Format 'yyyyMMdd_HHmmss')"

Write-Host "Creating backup..."
Copy-Item -Path "$FrontendPath" -Destination "$BackupPath" -Recurse -Force
Write-Host "Backup created at: $BackupPath"

STEP 2: EXTRACT NEW VERSION
----------------------------
Extract the new deployment package (Elyse-Frontend-Deploy-*.zip) to a temporary location

STEP 3: PRESERVE CONFIG.JSON
-----------------------------
Your current config.json contains your backend URL. Save it:

Copy-Item "$FrontendPath\assets\config.json" "$env:TEMP\config.json.backup"

STEP 4: DELETE OLD FILES
-------------------------
Remove old frontend files (but keep the directory):

Remove-Item "$FrontendPath\*" -Recurse -Force

STEP 5: COPY NEW FILES
-----------------------
Copy all files from the extracted package to the frontend directory:

Copy-Item -Path "C:\path\to\extracted\package\*" -Destination "$FrontendPath\" -Recurse -Force

Replace "C:\path\to\extracted\package" with the actual path where you extracted the ZIP.

STEP 6: RESTORE CONFIG.JSON
----------------------------
Restore your backend URL configuration:

Copy-Item "$env:TEMP\config.json.backup" "$FrontendPath\assets\config.json" -Force

STEP 7: VERIFY UPDATE
----------------------
1. Open web browser
2. Navigate to http://localhost:8080
3. Press Ctrl+Shift+R to hard refresh (clear cache)
4. Application should load with new version

No IIS restart required - changes take effect immediately.

STEP 8: TEST APPLICATION
-------------------------
Test key functionality to ensure everything works correctly.

ROLLBACK IF NEEDED
-------------------
If the new version has issues, rollback to the backup:

Remove-Item "$FrontendPath\*" -Recurse -Force
Copy-Item -Path "$BackupPath\*" -Destination "$FrontendPath\" -Recurse -Force

Then hard refresh your browser (Ctrl+Shift+R).

CLEANUP OLD BACKUPS
--------------------
After confirming the new version works:

Get-ChildItem "C:\inetpub\wwwroot\Elyse\frontend_backup_*" |
    Sort-Object LastWriteTime -Descending |
    Select-Object -Skip 2 |
    Remove-Item -Recurse -Force

This keeps the 2 most recent backups and deletes older ones.

OPTION B: UPDATING NODE.JS HTTP-SERVER DEPLOYMENT
--------------------------------------------------

STEP 1: BACKUP CURRENT VERSION
-------------------------------
Open PowerShell as Administrator:

$FrontendPath = "C:\Elyse\frontend"
$BackupPath = "C:\Elyse\frontend_backup_$(Get-Date -Format 'yyyyMMdd_HHmmss')"

Write-Host "Creating backup..."
Copy-Item -Path "$FrontendPath" -Destination "$BackupPath" -Recurse -Force
Write-Host "Backup created at: $BackupPath"

STEP 2: STOP THE SERVICE
-------------------------
nssm stop ElyseFrontend
Write-Host "Service stopped"

STEP 3: EXTRACT NEW VERSION
----------------------------
Extract the new deployment package (Elyse-Frontend-Deploy-*.zip) to a temporary location

STEP 4: PRESERVE CONFIG.JSON
-----------------------------
Copy-Item "$FrontendPath\assets\config.json" "$env:TEMP\config.json.backup"

STEP 5: DELETE OLD FILES
-------------------------
Remove-Item "$FrontendPath\*" -Recurse -Force

STEP 6: COPY NEW FILES
-----------------------
Copy-Item -Path "C:\path\to\extracted\package\*" -Destination "$FrontendPath\" -Recurse -Force

Replace "C:\path\to\extracted\package" with the actual path.

STEP 7: RESTORE CONFIG.JSON
----------------------------
Copy-Item "$env:TEMP\config.json.backup" "$FrontendPath\assets\config.json" -Force

STEP 8: START THE SERVICE
--------------------------
nssm start ElyseFrontend
Start-Sleep -Seconds 3
nssm status ElyseFrontend

Expected output: SERVICE_RUNNING

STEP 9: VERIFY UPDATE
----------------------
1. Open web browser
2. Navigate to http://localhost:8080
3. Press Ctrl+Shift+R to hard refresh
4. Application should load with new version

STEP 10: TEST APPLICATION
--------------------------
Test key functionality to ensure everything works.

ROLLBACK IF NEEDED
-------------------
If the new version has issues:

1. Stop service: nssm stop ElyseFrontend
2. Restore backup:
   Remove-Item "$FrontendPath\*" -Recurse -Force
   Copy-Item -Path "$BackupPath\*" -Destination "$FrontendPath\" -Recurse -Force
3. Start service: nssm start ElyseFrontend

CLEANUP OLD BACKUPS
--------------------
Get-ChildItem "C:\Elyse\frontend_backup_*" |
    Sort-Object LastWriteTime -Descending |
    Select-Object -Skip 2 |
    Remove-Item -Recurse -Force

IMPORTANT NOTES FOR UPDATES
----------------------------
- Always backup before updating
- Always preserve your config.json (contains backend URL)
- Hard refresh browser (Ctrl+Shift+R) after update to clear cache
- Test thoroughly before deleting backups
- Keep at least 2 recent backups for safety

================================================================================
DEPLOYMENT OPTIONS
================================================================================

This frontend can be deployed to:
- IIS (Windows Server) - Recommended for SERVER backend
- IIS Express (Development/Workstation) - For WORKGROUP backend
- nginx (Linux/Windows) - Configure similar to IIS
- Apache (Linux/Windows) - Configure similar to IIS
- Any static file web server
- CDN (for distributed deployments)

================================================================================
REQUIREMENTS
================================================================================

Server:
- Any web server capable of serving static files
- For IIS: Windows Server 2012+ or Windows 10/11
- For IIS: URL Rewrite module (for Angular routing)

Client Browser:
- Modern browser (Chrome, Firefox, Edge, Safari)
- JavaScript enabled
- Cookies enabled (for session management)

================================================================================
IMPORTANT NOTES
================================================================================

- This is a static file deployment (no server-side processing)
- All application logic runs in the browser
- Backend API URL is configurable at runtime via config.json
- No rebuild required to change backend URL
- Same package works for both SERVER and WORKGROUP deployments
- web.config enables Angular routing (URL rewriting)
- All files must be readable by IIS user (typically IIS_IUSRS)

================================================================================
VERIFYING USER AUTHENTICATION
================================================================================

Once the frontend is working, verify that the database is correctly resolving
the connected user:

1. Open the application in your web browser

2. Navigate to: Connected User -> Who is this?

3. Check the username displayed at the right-hand end of the message bar

4. Verify that the username matches the Windows login

This confirms that:
- Windows Authentication is working correctly
- The backend is properly impersonating the user (SERVER deployment)
- The database is correctly resolving the user's Windows identity
- User-level access control is functioning

If the username is incorrect or shows the service account instead of the
actual username, check:
- Backend .env configuration (USE_KCD setting)
- IIS Windows Authentication settings (SERVER deployment)
- SQL Server connection string (Windows Authentication enabled)
- Service account permissions (WORKGROUP deployment)

================================================================================

For complete deployment instructions see:
- DEPLOYMENT_GUIDE_SERVER.md (for SERVER deployments)
- DEPLOYMENT_GUIDE_WORKGROUP.md (for WORKGROUP deployments)

