LiveSchool — Cloud / self-host INSTALL GUIDE
============================================
Read this file completely before deploying.
Online copy: https://www.school-automation.com/modules/install#self-host
Full handbook: https://www.school-automation.com/guide

WHAT YOU NEED
-------------
1) license.json from https://www.school-automation.com/modules/purchases
   (same order id + email you used at Stripe checkout)
2) This zip (api/ + web/)
3) A SQL Server database YOU control (Express, Standard, or Azure SQL)
4) Two HTTPS hostnames (recommended):
   - API example:  https://api.yourschool.edu
   - Web example:  https://sis.yourschool.edu

school-automation.com does NOT create cloud hosting for you.
liveschools365.com is the full hosted SIS product (separate).

ZIP CONTENTS
------------
  README.txt           Short overview
  INSTALL-GUIDE.txt    This file
  api/                 LiveSchool API (Simple mode: auth + notification workers inside API)
  web/                 Blazor Web UI

STEP 1 — UNZIP
--------------
Extract to a working folder, e.g. C:\LiveSchool-Deploy\ or ~/liveschool-deploy/

STEP 2 — PREPARE SQL
--------------------
1. Create an empty database (example name: LiveSchool).
2. Apply the product schema / go-live SQL scripts for a new installation
   (ask Trend Developers for the current script set if you do not have them).
3. Save a working connection string. Example (SQL auth):

   Server=YOUR_SERVER;Database=LiveSchool;User Id=liveschool;Password=***;TrustServerCertificate=True;Encrypt=True

STEP 3 — DEPLOY THE API (folder "api")
--------------------------------------
Option A — IIS (Windows Server)
  1. Install the ASP.NET Core 9 Hosting Bundle.
  2. Create an Application Pool: .NET CLR version = "No Managed Code".
  3. Create a Site pointing at the "api" folder.
  4. Bind HTTPS to your API hostname.
  5. Set environment variables (or appsettings.Production.json):
       ConnectionStrings__LiveSchoolDatabase = <your SQL connection string>
       ASPNETCORE_ENVIRONMENT = Production
       Cors__AllowedOrigins__0 = https://sis.yourschool.edu
  6. Start the site. Test: open https://api.yourschool.edu/health
     (or the health path your build exposes). The process must start without SQL errors.

Option B — Azure App Service (YOUR subscription)
  1. Create a Windows App Service, runtime .NET 9.
  2. Deploy ALL files inside "api" (Zip Deploy / FTPS).
  3. Configuration > Application settings:
       ConnectionStrings__LiveSchoolDatabase = <your SQL>
       Cors__AllowedOrigins__0 = https://sis.yourschool.edu
  4. Restart and confirm the app starts.

You do NOT need Stripe keys on the customer API. Billing stays on school-automation.com.

STEP 4 — DEPLOY THE WEB (folder "web")
--------------------------------------
  1. Create a second IIS site or App Service.
  2. Deploy ALL files inside "web".
  3. Set:
       ApiBaseUrl = https://api.yourschool.edu/
     (include the trailing slash)
  4. Bind HTTPS to your Web hostname.
  5. Browse https://sis.yourschool.edu — you should see the login page.

STEP 5 — ACTIVATE YOUR LICENSE
------------------------------
  1. Sign in as the installation administrator
     (created by Setup/seed scripts — create SuperAdmin if your DB was empty).
  2. Go to Settings > Package / Component Activation (or Component Activation).
  3. Open license.json. For each component key, activate with an Installation ID
     (example: SCHOOL-CLOUD-01).
  4. Turn Licensing enforcement = On.
  5. Open Settings > Available modules:
       - Paid modules = Active
       - Others = Locked (you can subscribe later without redeploying)

STEP 6 — GO-LIVE CHECKLIST
--------------------------
  [ ] API starts and can reach SQL
  [ ] Web login works against YOUR API (not school-automation.com)
  [ ] ApiBaseUrl is correct
  [ ] CORS allows your Web origin
  [ ] HTTPS certificates valid
  [ ] SQL backups scheduled
  [ ] License activated + enforcement On
  [ ] Stripe subscription still Active on school-automation.com

ADDING MODULES LATER
--------------------
1. Buy more modules on https://www.school-automation.com/modules
2. Download the new license.json
3. Activate only the new keys — no need to redeploy api/ or web/

TROUBLESHOOTING
---------------
Web shows API / CORS errors
  -> Add Web URL to API Cors__AllowedOrigins__0 (and __1, __2 if needed), restart API.

All modules locked
  -> Activate keys from license.json, then enable enforcement.

Purchases said "webhook pending"
  -> Payment may still be completing. Wait and Look up again, or contact support
     with your order id for fulfillment repair.

Cannot download cloud zip
  -> Contact support; platform ops must publish LiveSchool-CloudDeploy-*.zip
     to the API App_Data/marketplace-cloud-pack folder.

SUPPORT
-------
Contact Trend Developers via https://www.school-automation.com/contact-us
Product handbook: https://www.school-automation.com/guide
