FUTURE INTELLIGENTS – AMC SUBDOMAIN / CPANEL DEPLOYMENT PACK
Target: amc.futureintelligents.com
Architecture: same Laravel installation, same MySQL database, same users and authentication.

IMPORTANT SCOPE
This pack configures a subdomain entry point and restricts dynamic web routes on that
host to authentication pages and the existing AMC web routes. It does not implement
new AMC workflow tables, visit scheduling, complaint/SLA logic, Tally integration, or
an independent AMC visual layout. The current AMC views still use the CRM layout unless
the developer separately converts those views to an AMC-specific layout.

BEFORE YOU START
1. Confirm the exact cPanel account and current CRM document root.
2. Make a full cPanel backup of the Laravel application files and MySQL database.
3. Download a copy of the current .env securely. Never include it in this ZIP or Git.
4. Perform this first on a staging copy if your hosting plan supports it.
5. Confirm PHP version/extensions and Laravel 8 application compatibility with hosting.
6. Confirm the CRM is already served from the Laravel public directory, not the project root.

PART A – CREATE THE SUBDOMAIN IN CPANEL
1. Sign in to cPanel.
2. Open Domains (or Subdomains on older cPanel versions).
3. Create: amc.futureintelligents.com
4. Set its document root to EXACTLY the same public directory used by the existing CRM.
   Example only: /home/CPANELUSER/public_html/crm/public
   Use the real path shown by your hosting account. Do not copy this example blindly.
5. Do not point the subdomain to the Laravel project root. The project root contains
   sensitive files such as .env, composer files and application source.
6. Do not create a second Laravel installation or a second database.

If cPanel refuses a document root already used by the CRM, stop and ask the hosting
provider to map the subdomain to the same Laravel public directory using an Apache
VirtualHost/Alias configuration. Do not solve this by copying the whole app.

PART B – DNS AND SSL
1. In cPanel Zone Editor, check whether an A record for 'amc' exists.
2. If DNS is managed elsewhere, create an A record:
      Host: amc
      Value: same server IP as the CRM
   Or use a CNAME to the CRM host only if your DNS/hosting provider recommends it.
3. Wait for DNS propagation.
4. In cPanel SSL/TLS Status, run AutoSSL (or install the valid certificate supplied by
   your host) and confirm the certificate covers amc.futureintelligents.com.
5. Test https://amc.futureintelligents.com before enabling the shared secure cookie.

PART C – INSTALL THE LARAVEL FILES
1. Upload app/Http/Middleware/AmcSubdomainOnly.php to:
      <Laravel project root>/app/Http/Middleware/AmcSubdomainOnly.php
2. Upload config/amc.php to:
      <Laravel project root>/config/amc.php
3. Edit the EXISTING app/Http/Kernel.php. Add:
      \App\Http\Middleware\AmcSubdomainOnly::class,
   at the end of the existing 'web' middleware group, after SubstituteBindings.
   Use patches/Kernel-web-group.patch.txt as a guide. Do not replace Kernel.php.
4. Merge ENV-AMC-snippet.txt into the existing .env. Do not overwrite the .env file.
5. Keep APP_URL set to the main CRM URL, for example:
      APP_URL=https://crm.futureintelligents.com
6. Keep the existing DB_* values, APP_KEY, SESSION_DRIVER and other settings unchanged.
7. Both CRM and AMC must use HTTPS before SESSION_SECURE_COOKIE=true is enabled.
8. Do not change APP_KEY. Both subdomains must use the same application and key.

PART D – CLEAR LARAVEL CACHES
From cPanel Terminal/SSH, run from the Laravel project root:
      php artisan config:clear
      php artisan route:clear
      php artisan view:clear
      php artisan cache:clear
      php artisan config:cache
If cPanel has no Terminal/SSH, ask the hosting provider/developer to run these commands.
Do not run composer update on production as part of this deployment.

PART E – TEST IN THIS ORDER
1. Open https://crm.futureintelligents.com and confirm existing login and key CRM pages work.
2. Open https://amc.futureintelligents.com while logged out. It should show the existing
   login page (or redirect to it).
3. Log in at CRM, then open AMC in another tab. It should not ask for another login.
4. Log out and confirm both hosts require login again.
5. Log in and open https://amc.futureintelligents.com/amc.
6. Confirm AMC list, create, view, edit and print routes work.
7. Try a non-AMC CRM URL on the AMC host, for example /customer. It must return 404.
8. Confirm the same /customer URL still works on the main CRM host for authorised users.
9. Test in a private/incognito window and on a second browser/device.
10. Inspect browser developer tools for mixed-content, cookie, CSRF or redirect errors.

IMPORTANT IMPLEMENTATION NOTES
- The middleware blocks non-AMC dynamic routes on the AMC host; static files under the
  shared public directory remain accessible as normal. Do not store private documents
  or backups in public folders.
- Existing AMC controller permission checks remain in force. Assign the relevant Spatie
  permissions to AMC employees. The middleware is host routing isolation, not a substitute
  for role/permission authorisation.
- The current source has a separate AMC API route group. This pack does NOT expose those
  API routes on the AMC host. Review and secure API endpoints separately before using them.
- Current AMC create/edit/show views may include the shared CRM header/sidebar because
  they extend layouts.layout. A dedicated AMC shell requires a separate UI implementation.
- The existing root login route and Laravel Auth routes are shared. Do not create a second
  login controller or user table.
- If your CRM uses a custom login URL, MFA, CAPTCHA, SSO or additional auth routes, update
  the middleware allow-list after inspecting those exact routes.

ROLLBACK
1. Restore the backed-up app/Http/Kernel.php and .env.
2. Remove app/Http/Middleware/AmcSubdomainOnly.php and config/amc.php if no longer used.
3. Clear config/route/view caches.
4. Remove the AMC subdomain DNS/cPanel mapping only if you want to take the portal offline.
5. Confirm the main CRM works after rollback.

GO-LIVE GATE
Do not point the production subdomain to this app until the developer has tested the above
on staging, reviewed authentication and API security, and verified all existing CRM routes.
