# 🚀 Trust Tax Advisor - cPanel Installation Guide (NON-DEVELOPERS)

**This guide is for beginners with NO coding experience**

---

## ✅ PART 1: PREPARE YOUR FILES (On Your Computer)

### What You Need:
1. Project folder: `Trust Tax Advisor` (all files)
2. cPanel hosting credentials
3. FTP software: **FileZilla** (free, download from [filezilla-project.org](https://filezilla-project.org))

### Step 1.1: Download FileZilla
- Go to: https://filezilla-project.org
- Click **Download**
- Confirm you get the **Client** version (NOT Server)
- Install it on your computer

---

## ✅ PART 2: GET YOUR cPanel CREDENTIALS

### Step 2.1: Access Your cPanel
1. Go to: `https://yourdomain.com:2083` or `https://yourdomain.com/cpanel`
2. Login with your **cPanel username** and **cPanel password**
3. You'll see the cPanel dashboard

### Step 2.2: Find Your FTP Credentials
1. In cPanel, click **FTP Accounts** (or **FTP Connections**)
2. You'll see:
   - **FTP Hostname**: `yourdomain.com`
   - **FTP Username**: `username@yourdomain.com` (or similar)
   - **FTP Password**: (your FTP password)
   - **FTP Port**: `21`

**Note:** Save these credentials somewhere safe!

---

## ✅ PART 3: UPLOAD FILES VIA FileZilla

### Step 3.1: Open FileZilla
1. Launch FileZilla
2. Go to **File → Site Manager**

### Step 3.2: Create New Connection
1. Click **New Site**
2. Fill in:
   - **Protocol**: FTP
   - **Host**: `yourdomain.com`
   - **Port**: `21`
   - **User**: `username@yourdomain.com`
   - **Password**: (your FTP password)
3. Click **Connect**

### Step 3.3: Upload Project Files
1. **Left side** = Your computer folders
2. **Right side** = Server folders
3. Navigate to `public_html` folder on right side
4. Drag & drop entire `Trust Tax Advisor` project folder
5. **Wait for upload to complete** (may take 5-10 minutes)

**Check:** All files uploaded successfully ✅

---

## ✅ PART 4: CREATE DATABASE IN cPanel

### Step 4.1: Create New Database
1. In cPanel, click **MySQL® Databases**
2. Under **Create New Database**:
   - **Database Name**: `fmpdcrei_tta1`
   - Click **Create Database**
3. You'll see: `Database created successfully!`

### Step 4.2: Create Database User
1. Scroll down to **MySQL Users**
2. Click **Create New User**:
   - **Username**: `fmpdcrei_tta1`
   - **Password**: `Chintan@1993`
   - **Confirm Password**: `Chintan@1993`
3. Click **Create User**
4. You'll see: `User created successfully!`

### Step 4.3: Assign User to Database
1. Scroll down to **Add User to Database**
2. Select:
   - **User**: `fmpdcrei_tta1`
   - **Database**: `fmpdcrei_tta1`
3. Click **Add**
4. Check ALL boxes for permissions
5. Click **Make Changes**

---

## ✅ PART 5: IMPORT DATABASE SCHEMA

### Step 5.1: Open phpMyAdmin
1. In cPanel, click **phpMyAdmin**
2. On left side, click your database: `fmpdcrei_tta1`
3. You'll see an empty database

### Step 5.2: Import Schema File
1. Click **Import** tab (at top)
2. Click **Choose File**
3. Navigate to: `Trust Tax Advisor → database → schema.sql`
4. Select it and click **Open**
5. Click **Import** button
6. **Wait for completion** (may take 1-2 minutes)
7. You'll see: `Import has been successfully finished`

### Step 5.3: Verify Tables Created
1. Click **Structure** tab
2. You should see 12 tables:
   - ✅ users
   - ✅ connectors
   - ✅ clients
   - ✅ orders
   - ✅ services
   - ✅ leads
   - ✅ commissions
   - ✅ documents
   - ✅ form_templates
   - ✅ form_responses
   - ✅ otp_logs
   - ✅ audit_logs

---

## ✅ PART 6: CONFIGURE BACKEND SETTINGS

### Step 6.1: Access File Manager
1. In cPanel, click **File Manager**
2. Navigate to: `public_html → Trust Tax Advisor → backend`

### Step 6.2: Copy .env.example to .env
1. Find file: `.env.example`
2. Right-click on it
3. Click **Copy**
4. Right-click in same folder
5. Click **Paste**
6. Rename to: `.env` (remove .example)

### Step 6.3: Edit .env File
1. Right-click on `.env`
2. Click **Edit**
3. Find these lines and update:

**DATABASE SECTION:**
```
DB_HOST=localhost
DB_USER=fmpdcrei_tta1
DB_PASSWORD=Chintan@1993
DB_NAME=fmpdcrei_tta1
DB_PORT=3306
```

**JWT SECTION:**
```
JWT_SECRET=your_super_secret_jwt_key_change_this_in_production
```

**EMAIL SECTION:**
```
SMTP_USER=noreply@trusttaxadvisor.com
SMTP_PASSWORD=Chintan@1993
SMTP_HOST=mail.trusttaxadvisor.com
SMTP_PORT=465
SMTP_SECURE=true
SMTP_FROM=Trust Tax Advisor <noreply@trusttaxadvisor.com>
```

**WHATSAPP SECTION:**
```
WHATSAPP_API_URL=https://whatsapp.thechintanpatel.co.in/api/create-message
WHATSAPP_APP_KEY=1a68fcd1-3746-4be7-9cc0-334423e4e1d5
WHATSAPP_AUTH_KEY=yoQ5tAx2MjtnOM2JCu8HU5IuL14DDkKesmGnCVOLRzuyVbu1qv
```

**SERVER SECTION:**
```
PORT=3000
NODE_ENV=production
CORS_ORIGIN=https://yourdomain.com
```

4. Click **Save** button
5. Close editor

---

## ✅ PART 7: SETUP NODE.JS APP

### Step 7.1: Go to Setup Node.js App
1. In cPanel, search for: **Setup Node.js App**
2. Click on it
3. Click **Create Node.js App**

### Step 7.2: Configure App Settings
1. **Node.js version**: Select latest (18.0+)
2. **Application root**: `/home/username/public_html/Trust Tax Advisor` 
   - (Replace 'username' with your cPanel username)
3. **Application startup file**: `backend/server.js`
4. **Application URL**: Leave as default
5. Click **Create**

**You'll see:** `Node.js application successfully created!`

### Step 7.3: Install Dependencies
1. Click on your created app
2. Click **NPM Install**
3. **Wait for completion** (5-10 minutes)
4. You'll see: `npm install completed successfully!`

---

## ✅ PART 8: ENABLE HTTPS (SSL)

### Step 8.1: Enable AutoSSL
1. In cPanel, click **AutoSSL**
2. You'll see your domain
3. Click **Check & Install**
4. **Wait for completion**
5. You'll see: `Certificate installed successfully!`

**Note:** This is FREE with cPanel

### Step 8.2: Update Configuration
1. Go back to File Manager
2. Open `.env` file again
3. Change this line:
```
CORS_ORIGIN=https://yourdomain.com
```

4. Save file

---

## ✅ PART 9: START YOUR APPLICATION

### Step 9.1: Restart Node.js App
1. Go to **Setup Node.js App**
2. Find your app
3. Click **Restart**
4. **Wait for restart** (1-2 minutes)
5. You'll see: `Node.js app restarted successfully!`

---

## ✅ PART 10: TEST YOUR WEBSITE

### Step 10.1: Check If Working
Open your browser and go to:
```
http://thechintanpatel.co.in
```

**You should see:**
- ✅ Login page loads
- ✅ No errors

### Step 10.2: Test API Connection
Open your browser and go to:
```
http://thechintanpatel.co.in/api/health
```

**Expected response:**
```json
{
  "status": "ok",
  "timestamp": "2026-03-18T..."
}
```

If you see this JSON, your backend is working! ✅

---

## ✅ PART 11: FIRST LOGIN

### Step 11.1: Login Credentials
- **Mobile**: `918733870977`
- **Email**: `admin@trusttaxadvisor.com`

### Step 11.2: How to Login
1. Go to: `https://yourdomain.com`
2. Click **Login with Mobile**
3. Enter: `918733870977`
4. Click **Send OTP**
5. Check **WhatsApp** for 6-digit code
6. Enter OTP code
7. Click **Verify**
8. **You're logged in!** ✅

---

## ✅ PART 12: TROUBLESHOOTING

### Issue: Files not uploading via FTP
**Solution:**
1. Check internet connection
2. Restart FileZilla
3. Try again with smaller chunks

### Issue: Database import failed
**Solution:**
1. Delete all tables in database
2. Try importing schema.sql again
3. Make sure file is not corrupted

### Issue: Node.js app won't start
**Solution:**
1. Check `.env` file has all required fields
2. Check database user permissions are correct
3. Click **Restart** in Setup Node.js App again

### Issue: Login page won't load
**Solution:**
1. Wait 5 minutes for SSL certificate to activate
2. Clear browser cache (Ctrl+Shift+Delete)
3. Try in Incognito/Private window
4. Check if `/api/health` works

### Issue: OTP not received on WhatsApp
**Solution:**
1. Check mobile number is correct: `918733870977`
2. WhatsApp API might be down - try email login
3. Check WhatsApp business account is active

---

## ✅ CHECKLIST: INSTALLATION COMPLETE?

- ✅ Files uploaded to public_html
- ✅ Database created: `fmpdcrei_tta1`
- ✅ Database user created: `fmpdcrei_tta1`
- ✅ schema.sql imported (12 tables created)
- ✅ `.env` file created and configured
- ✅ Node.js app created
- ✅ npm install completed
- ✅ SSL enabled (HTTPS)
- ✅ Node.js app restarted
- ✅ Login page loads at `https://yourdomain.com`
- ✅ `/api/health` returns JSON response

---

## 📞 SUPPORT

### Common Things to Check:
1. **Database connection error?**
   - Go to cPanel → MySQL Databases
   - Verify user `fmpdcrei_tta1` has ALL permissions to database `fmpdcrei_tta1`

2. **Node.js app won't start?**
   - Check cPanel error logs: **Error Log** in File Manager
   - Look for red error messages

3. **SSL certificate not working?**
   - Wait 24 hours for propagation
   - Or manually add SSL from cPanel

4. **WhatsApp OTP not working?**
   - Check `WHATSAPP_APP_KEY` and `WHATSAPP_AUTH_KEY` in `.env`
   - Verify WhatsApp Business account is active

---

## 🎉 CONGRATULATIONS!

Your Trust Tax Advisor website is now LIVE on the internet!

**What Can You Do Now:**
- ✅ Users can login with mobile OTP
- ✅ Admin can manage orders
- ✅ Track commissions automatically
- ✅ Send email notifications
- ✅ WhatsApp OTP delivery
- ✅ Full dashboard with reports

---

## 📝 REMEMBER THESE CREDENTIALS

Save in a safe place:

**cPanel Login:**
- URL: https://yourdomain.com:2083
- Username: [your cPanel username]
- Password: [your cPanel password]

**Database:**
- Username: `fmpdcrei_tta1`
- Password: `Chintan@1993`
- Database: `fmpdcrei_tta1`

**Admin Login:**
- Mobile: `918733870977`
- Email: `admin@trusttaxadvisor.com`

**Email Credentials:**
- Email: `noreply@trusttaxadvisor.com`
- Password: `Chintan@1993`

---

**Version:** 1.0.0  
**Last Updated:** March 18, 2026  
**Support:** Contact your hosting provider for cPanel issues
