RepMojoMulti-tenant Namecheap Installation Guide · R2

RepMojo Multi-tenant R2 — Fresh Namecheap Installation

Read first: This release is a functional staging foundation and new public website, NOT a complete paid production ERP. It implements the correct physical multi-tenant architecture, with one independent folder and database per wholesale company. The website, Office, Sales Rep and Master interfaces are included, but real GoCardless checkout/reconciliation, end-to-end accounting/purchasing, and hands-off paid tenant deployment are not complete. Do not take subscription payments yet.

Final architecture

/home/YOUR_CPANEL_USER/
├── public_html/                     ← main repmojo.com website
│   ├── index.html                   ← redesigned marketing site
│   ├── assets/
│   ├── api/lead.php                 ← public enquiry endpoint, no payments
│   ├── control/                     ← CENTRAL MASTER CONTROL, installed once
│   │   ├── index.html
│   │   ├── setup.php                ← delete after first master setup
│   │   ├── install-company.php      ← staging-only, Master-authenticated
│   │   ├── api/index.php
│   │   └── webhook.php              ← event inbox only
│   ├── abc/                         ← COMPANY ABC: created by staging installer
│   │   ├── office/index.html        ← ABC Office Admin
│   │   ├── rep/index.html           ← ABC Sales Rep iPad app
│   │   ├── api/index.php            ← ABC tenant-locked API
│   │   └── assets/ ...
│   └── 2nd-company/              ← SECOND independent wholesaler
│       ├── office/  ├── rep/  ├── api/  └── assets/
└── repm-private/                    ← MUST be outside public_html
    ├── config.php                   ← Master database credentials
    ├── master-encryption.key         ← created during setup
    ├── tenants/abc.json             ← private ABC database credentials
    ├── tenants/2nd-company.json  ← separate database credentials
    ├── tenant-template/             ← approved reusable company release
    └── backend/                    ← shared PHP source and business services

Important: each company has its own physically installed release files in /slug/ (office, rep, API, assets). The source engine is currently shared, but company database access is isolated and its entry points are forced to that company. Tenant API paths and sessions are restricted to their own company URL. Future per-company backend version pinning will require copying/versioning the backend engine per release; it is NOT implemented yet. Do not claim company releases can be updated independently in the current backend.

Step 0 — What you need

Step 1 — Create the main Master Control database

  1. Open Namecheap → Hosting List → Go to cPanel → Database Wizard.
  2. Create database e.g. rm_master (cPanel will show something like cpusername_rm_master).
  3. Create its own MySQL user and strong password. Give that user privileges only on that database.
  4. Open phpMyAdmin; select the Master database only. Import these files from 04-Databases.zip in exactly this order:
    1. database/01_master_control.sql
    2. database/05_unified_security.sql
  5. Confirm you see master_users, master_user_totp, tenants, plans, subscription_contracts, and master_audit_logs.

Step 2 — Upload the website to the EMPTY public_html

  1. Go to cPanel → File Manager → public_html.
  2. Upload 01-Public-Website.zip, then Extract it there. The ZIP contains website files directly (index.html, assets/, api/), so extraction inside public_html places them correctly. If cPanel creates a wrapper folder, move its contents into actual public_html.
  3. The actual docroot should show index.html, assets/, api/, and .htaccess immediately inside public_html.
  4. Open https://repmojo.com/ to view the redesigned sales website. The subscription form remains enquiry only, with no payment.

Step 3 — Upload the PRIVATE backend (outside public_html)

  1. In File Manager, navigate to /home/YOUR_CPANEL_USER/ (the parent of public_html).
  2. Create folder repm-private directly in your home directory. Open that new folder and upload/extract 04-Private-PHP-Engine.zip INSIDE it. The ZIP contains backend/, tenant-template/, config.example.php, etc. Make sure the final path is exactly /home/YOUR_CPANEL_USER/repm-private/ and NOT public_html/repm-private/.
  3. Copy repm-private/config.example.php to repm-private/config.php.
  4. Open config.php and enter your real Master DB host/name/user/password. Use 'environment'=>'staging' initially.
  5. Keep the file private. Permissions 600 for credentials where supported (you can set permissions using cPanel File Manager).

Step 4 — Upload and set up Master Control

  1. In public_html, create the control folder, then OPEN control. Upload and extract 02-Master-Control.zip INSIDE public_html/control/. This ZIP contains index.html, api/, setup.php, etc. DO NOT extract it directly in public_html or it would overwrite the public website.
  2. Verify public_html/control/index.html and public_html/control/setup.php exist.
  3. Visit https://repmojo.com/control/setup.php over HTTPS. The setup script creates a random private key on first use.
  4. In cPanel File Manager read the random setup key at repm-private/install-secrets/setup.key. Keep it private.
  5. In your browser setup page enter your own Master email and a unique 14+ character password.
  6. Setup generates a 2FA authenticator secret shown once. Enter it in an authenticator app (e.g. Google Authenticator or Microsoft Authenticator) and keep a secure backup.
  7. DELETE public_html/control/setup.php immediately after successful setup.
  8. Open https://repmojo.com/control/ and sign in with your Master email, password and six-digit authenticator code.
  9. Master Control should show Companies and other existing modules using the integrated PHP API. If it shows empty tables, that is normal until you create tenants.

Step 5 — Create a SEPARATE ABC wholesale-company database

  1. In cPanel → Database Wizard, create a second database e.g. rm_abc and a new different MySQL user.
  2. Grant this user privileges only over the ABC database; do not grant access to the Master DB.
  3. In phpMyAdmin, select ABC's database, import database/02_tenant_company.sql from 04-Databases.zip.
  4. For a harmless test only, you may subsequently import database/03_staging_seed_EXAMPLE_ONLY.sql (it contains fictional data; never import into a real tenant database).
  5. Check that the ABC database has users, roles, user_roles, customers, products, orders, and order_items.

Step 6 — Create ABC's OWN /abc/ folder using Master Control

  1. Remain signed in at https://repmojo.com/control/ with Master administrator access.
  2. Expand Install a staging wholesale company at the bottom of the Master workspace.
  3. Fill in:
    • Company folder: abc (this becomes https://repmojo.com/abc/).
    • Company name and ABC company administrator's email and strong password.
    • The full ABC database host/name/username/password from Step 5, NOT the Master credentials.
  4. Click Prepare company folder & administrator. The wizard checks the database tables, creates a company_admin login, copies the complete company-template files to public_html/abc/ (including a company landing page at /abc/), and writes repm-private/tenants/abc.json securely.
  5. Verify the new URLs:
    • https://repmojo.com/abc/office/ — ABC Office Admin
    • https://repmojo.com/abc/rep/ — ABC iPad ordering
    • https://repmojo.com/abc/api/index.php?route=/v1/health — ABC API
  6. Sign in to ABC Office with the ABC administrator email/password. Your Master login will not sign in to ABC's Office.
  7. The company is marked internal staging only. A successful staging sign-in is NOT evidence of a paid subscription.

Note: cPanel may restrict file permissions or disk operations. If the provisioning step fails, read the cPanel PHP Error Log, check directory permissions and whether a partial abc/ folder or abc.json was created. Do not delete a partially created database or blindly retry if duplicate records exist. Run a fresh test with a separate slug if needed. Automated restoration/rollback on a partial multi-database failure is not yet complete.

Step 7 — Create the second company's INDEPENDENT installation

Repeat Steps 5 and 6, but create its own new MySQL DB/user (e.g. cpusername_rm_second) and enter the slug 2nd-company. The wizard creates:

Never point multiple company folders at the same tenant DB. Each company must have unique DB credentials, separate users and separate customer/product/order data.

Step 8 — Isolation and functionality checks

  1. ABC Office must display only ABC database records. A second company's Office must display only second company's records.
  2. Sign in to ABC, then try the 2nd-company API from the ABC page. The browser has different session cookie paths, and server route bindings must reject cross-tenant access.
  3. On /abc/office/, test searching Orders/Customers/Products, adding a customer and making a simple order. The backend recalculates prices and VAT.
  4. Test the row popups, columns, CSV export, audited stock adjustments and document preview-only actions.
  5. On /abc/rep/, sign in online, select customer and take a simple test order. Check that Office receives it. Offline orders are queued and submitted only after server acceptance.
  6. Check https://repmojo.com/abc/api/index.php?route=/v1/office/data/customers without an authenticated ABC session — it should give 401.
  7. Verify every account/password is different for Master and companies. Never send credentials in a support screenshot.

Step 9 — GoCardless status: IMPORTANT

No customer should be charged or activated yet. Main website packages are enquiry-only; there is no working GoCardless checkout/subscription creation or fully verified payment reconciliation. The central endpoint /control/webhook.php?route=/v1/webhooks/gocardless only validates event signatures and stores events in Master DB. After provider sandbox testing, paid onboarding needs a billing worker that verifies payment status server-to-server, then authorises a non-demo company provisioning job. Webhook received ≠ successful payment. Never mark a new tenant active solely from a browser form or GoCardless mandate authorisation.

Step 10 — Development sources (Node.js, Next.js, React/Vite)

06-Developer-Source.zip includes Next.js marketing source, React/Vite Office and Master starter projects, and the approved Prototype 23 design reference. The uploaded, ready-to-run frontend in R2 is built static HTML/CSS/JavaScript backed by PHP/MySQL. It is not yet a compiled Next.js/React replacement with full Prototype 23 parity. The Node source is for the future compiled release, not to be uploaded over these interfaces without testing.

Step 11 — Security and maintenance

Troubleshooting (without sharing secrets)

Symptom Check
setup.php says extension missing Enable pdo_mysql and sodium in cPanel PHP Selector
503 Database Full cPanel DB prefixes, hostname and privileges, SQL import order
Master login requests MFA Authenticator secret from first setup
Tenant installer rejects slug Lowercase letters, numbers or hyphens, 3–39 chars, unique slug, not reserved
Company exists but shows no records Company DB is empty or optional sample seed wasn't imported
Installer 403 You must be signed into Master Control with valid session/CSRF, and environment must be staging
Directory not found Check actual ZIP extract location and avoid nested public_html
GoCardless not collecting This release does not include a live GoCardless checkout; do NOT enable real subscriptions

Acceptance criteria to move out of staging: real MySQL CRUD and isolation tests on two companies, payment sandbox reconciliation tests, security audit, double-entry accounting and inventory integration, offline queue security, backup restore, independent release pinning and automatic provisioning with safe rollback.