# SURVAM v1.0 — Deployment Guide **Relevant Reflex Consulting · survam.relevantreflex.shop** --- ## Overview SURVAM is a full-stack survey programming tool built in PHP + MySQL for Hostinger shared hosting. | Layer | Technology | |---|---| | Backend | PHP 8.0+ | | Database | MySQL 5.7+ / MariaDB 10.3+ | | Frontend | Vanilla JS + Chart.js (CDN) | | Payments | Razorpay (INR wallet model) | | Hosting | Hostinger shared hosting | --- ## File Structure ``` survam/ ├── .htaccess # URL routing, security headers ├── index.php # Public landing page ├── dashboard.php # Client portal home ├── account/ │ ├── billing.php # Wallet & top-up │ ├── profile.php # User settings │ └── upgrade.php # Plan selection ├── admin/ │ ├── index.php # Platform dashboard │ ├── users.php # User management (super_admin) │ ├── surveys.php # All surveys view │ ├── transactions.php # Payment log │ ├── plans.php # Plan CRUD (super_admin) │ ├── reports.php # Analytics & charts │ └── settings.php # App config (super_admin) ├── api/ │ ├── surveys.php # Builder AJAX API │ └── billing.php # Razorpay orders & webhooks ├── assets/ │ ├── css/style.css # Portal + survey styles │ ├── css/admin.css # Admin panel styles │ ├── js/app.js # Core JS (nav, modals, survey renderer) │ ├── js/builder.js # Drag-drop survey builder │ └── js/admin.js # Admin panel JS ├── auth/ │ ├── login.php / register.php / logout.php │ ├── forgot.php / reset.php ├── includes/ │ ├── config.php # DB credentials & constants ← EDIT THIS │ ├── db.php # PDO singleton │ ├── auth.php # Session, CSRF, plan limits │ ├── functions.php # Helpers, badges, formatters │ ├── header.php / footer.php │ └── admin_header.php / admin_footer.php ├── install/ │ ├── schema.sql # Full DB schema + seed data │ └── install.php # Web-based installer ├── s/ │ └── index.php # Public survey renderer └── surveys/ ├── create.php / builder.php / index.php ├── results.php / export.php / delete.php ``` --- ## Hostinger Deployment Steps ### 1 — Upload files Upload the entire `survam/` folder contents to: ``` public_html/ (if running at root) OR public_html/survam/ (if running in subdirectory) ``` For `survam.relevantreflex.shop` subdomain, upload to the subdomain's root folder. ### 2 — Create MySQL database In Hostinger hPanel → Databases → MySQL Databases: - Create database: `survam_db` - Create user: `survam_user` with a strong password - Grant user ALL PRIVILEGES on `survam_db` ### 3 — Run the installer Visit: `https://survam.relevantreflex.shop/install/install.php` Fill in: - DB Host: `localhost` - DB Name: `survam_db` - DB User: `survam_user` - DB Password: (the password you set) - App URL: `https://survam.relevantreflex.shop` - Admin email & password The installer will: - Write `includes/config.php` with your settings - Run `install/schema.sql` to create all tables - Seed the 4 pricing plans - Create your admin account **⚠ Delete `/install/install.php` immediately after installation.** ### 4 — Manual config (if not using installer) Edit `includes/config.php`: ```php define('DB_HOST', 'localhost'); define('DB_NAME', 'survam_db'); define('DB_USER', 'survam_user'); define('DB_PASS', 'YOUR_PASSWORD'); define('APP_URL', 'https://survam.relevantreflex.shop'); define('CSRF_SECRET', 'GENERATE_32_RANDOM_CHARS_HERE'); define('RAZORPAY_KEY_ID', 'rzp_live_...'); define('RAZORPAY_KEY_SECRET', '...'); define('RAZORPAY_WEBHOOK_SECRET','...'); ``` Then import `install/schema.sql` via phpMyAdmin. ### 5 — Razorpay setup 1. Log in to [dashboard.razorpay.com](https://dashboard.razorpay.com) 2. Settings → API Keys → Generate Live Key 3. Add Key ID and Key Secret to Admin → Settings (or config.php) 4. Settings → Webhooks → Add webhook URL: `https://survam.relevantreflex.shop/api/billing.php?webhook=1` 5. Select event: `payment.captured` 6. Copy webhook secret to Admin → Settings ### 6 — Post-install checklist - [ ] Delete `/install/install.php` - [ ] Change default admin password (admin@relevantreflex.com / Admin@2024) - [ ] Set Razorpay keys in Admin → Settings - [ ] Set SMTP credentials for password reset emails - [ ] Test a survey end-to-end - [ ] Test a payment (₹1 test transaction) - [ ] Verify `.htaccess` is working (short survey URLs `/s/{token}`) --- ## Default Accounts | Email | Password | Role | |---|---|---| | admin@relevantreflex.com | Admin@2024 | super_admin | | manager@relevantreflex.com | Admin@2024 | manager | **Change these immediately after first login.** --- ## Pricing Plans (pre-seeded) | Plan | Price | Surveys | Responses/mo | |---|---|---|---| | Free | ₹0 | 3 | 100 | | Starter | ₹999 | 10 | 1,000 | | Growth | ₹2,999 | 50 | 10,000 | | Scale | ₹7,999 | Unlimited | 100,000 | Plans are editable via Admin → Plans. --- ## Key URLs | Path | Purpose | |---|---| | `/` | Public landing page | | `/auth/login.php` | Sign in | | `/auth/register.php` | New account | | `/dashboard.php` | Client home | | `/surveys/create.php` | New survey | | `/s/{token}` | Public survey URL | | `/admin/index.php` | Admin dashboard | | `/api/surveys.php` | Builder API (POST) | | `/api/billing.php` | Payments API (POST) | | `/api/billing.php?webhook=1` | Razorpay webhook (POST) | --- ## Roles & Permissions | Feature | client | manager | super_admin | |---|---|---|---| | Create surveys | ✓ (plan limit) | ✓ | ✓ | | View all surveys | own only | all | all | | Admin dashboard | ✗ | ✓ | ✓ | | Users page | ✗ | ✗ | ✓ | | Plans & Settings | ✗ | ✗ | ✓ | --- ## Troubleshooting **Short URLs not working (`/s/{token}` → 404)** → Check `.htaccess` is uploaded and `mod_rewrite` is enabled (Hostinger supports this). **"Database connection failed"** → Verify DB credentials in `includes/config.php`. Check DB user has correct privileges. **Razorpay payment not crediting wallet** → Ensure webhook URL is set and webhook secret matches `RAZORPAY_WEBHOOK_SECRET`. → Check PHP `error_log` for verification failures. **Emails not sending** → Set SMTP credentials in Admin → Settings. On shared hosting `mail()` may be blocked. **SPSS export not working** → SPSS export generates a `.sps` syntax file (not `.sav`). Open in SPSS and run to import data. → For true `.sav` files, install `composer require phpoffice/phpspreadsheet`. --- ## Tech Notes - Session name: `survam_sess` - CSRF token: per-session, validated on all POST forms - Passwords: bcrypt cost 12 - Survey tokens: 64-char hex (32 random bytes) - All user input is sanitized via `htmlspecialchars()` before output - SQL uses PDO prepared statements throughout - Response monthly counter resets on the 1st of each month (via `responses_reset_date`) --- © 2024 Relevant Reflex Consulting Pvt. Ltd. · SURVAM v1.0