July 3rd - Update landing page

This commit is contained in:
2026-07-03 15:38:31 -04:00
parent 4c275fc0e5
commit 4b6401be43
12 changed files with 414 additions and 19 deletions
+13 -9
View File
@@ -52,7 +52,8 @@
- **Mobile API** — JWT-authenticated REST layer for the iPad native app
- **iPad native app** — SwiftUI + SwiftData offline-first inspection tool (Phase A + B + C complete)
- **Billing** — Stripe-backed subscription system with plan picker, Checkout, Customer Portal, dunning emails (HTML + plain text), invoice history, and trial-period enforcement
- **Self-service signup** — public `/signup` page provisions a new tenant immediately with a 14-day trial (no Stripe required at signup)
- **Public landing page** — `jqc.app` apex serves a marketing/landing page (`landing.index`, canonical path `/welcome`) introducing the product and plans, funneling to signup
- **Self-service signup** — public `/signup` page provisions a new tenant immediately: Free plan = free-forever (`active`), paid plans = 14-day trial (no Stripe required at signup)
The application is actively deployed in production and maintained by a single developer/administrator.
@@ -488,7 +489,8 @@ The `DeviceRegistration` model and the duplicate `api_devices` blueprint were **
| `api_discovery` | `/api/v1` | `GET /discover?subdomain=` or `?email=`, `GET /tenant` — MT-9 server side (public, no auth, exempt from tenant middleware) |
| `tenant_settings` | `/settings` | MT-7: `GET/POST /branding`, `GET /plan`, `GET /domains`, `POST /domains/request`, `POST /domains/<id>/delete` |
| `billing` | `/billing` | `GET /subscribe`, `POST /subscribe`, `GET /portal`, `POST /webhook`, `GET /suspended` |
| `signup` | `/signup` | `GET /`, `POST /` — public self-service signup (exempt from tenant middleware) |
| `signup` | `/signup` | `GET /`, `POST /` — public self-service signup (exempt from tenant middleware). Free plan → provisioned `active` (free forever); paid plans → 14-day trial |
| `landing` | `/` (apex only) | `GET /welcome` — public marketing/landing page (tenant-exempt). In MT mode the middleware serves this for the apex host's `/` and funnels to `/signup` |
---
@@ -1235,6 +1237,8 @@ set -a; . /etc/jqc/control.env; set +a
| 75 | **`delete_tenant()` + `_add_domains()` are retry-safe** | `_add_domains` uses `_upsert_domain()` (delete-then-insert) to handle orphan rows from failed partial runs. `delete_tenant()` also purges by derived domain string, not only by `tenant_id`, catching orphans whose parent tenant row was rolled back. |
| 76 | **`register-tenant-zero` never bootstraps and never drops the DB** | `register_tenant_zero()` only reads the existing head, inserts control rows, and maps domains. `delete_tenant()` on tenant-zero must never use `--drop-db` — the guard checks `db_name == db_name_for(slug)` and refuses non-provisioner-named DBs (LT's DB name is `jqc_lt`, not `jqc_lts`). |
| 84 | **Device registration is consolidated on `DeviceToken` / `api_device_tokens` — one handler only** | RESOLVED. There is exactly one `POST /api/v1/devices/register`, in `app/api/auth.py` (blueprint `api_auth`); it upserts `DeviceToken` (device_id, device_name, app_version, ios_version, apns_token, last_seen_at) which the admin Devices page reads. The former duplicate `api_devices` blueprint (`app/api/devices.py`) and the orphaned `DeviceRegistration` model / `device_registrations` table were **deleted** — that path wrote to a table phase31/32 drop. Do not reintroduce a second `/devices/register` route or a `device_registrations`-backed model. |
| 85 | **Apex host serves the public landing page; the landing route lives at `/welcome`, NOT `/`** | The dashboard owns `/` (login-gated) on tenant hosts, so the landing page cannot register a second `/` route (same collision class as rule 84). Instead the tenant middleware detects the apex host (`TENANT_BASE_DOMAIN` + `www.`) and calls `landing.index` directly for `/`, redirecting other non-exempt apex paths to `/`. `/welcome`, `/signup`, `/static/` are tenant-exempt. The apex handling is inert when `MULTI_TENANT_ENABLED=false`, so `/welcome` is the always-reachable preview URL. Requires the Nginx apex block to **proxy** (not 301-redirect) to port 8000 with `Host` passed through. |
| 86 | **Free plan is free-forever, not a trial** | `signup.index()` passes `trial_days=0` for `plan_code == 'free'`; `create_tenant()` then sets `subscription_status='active'` (no `trial_ends_at`) so `_billing_gate()` never blocks it. Paid plans keep the 14-day trial (`trial_days=14`). The welcome email adapts via `trial_note` and hides the trial row when `trial_ends_at` is blank. Do not reintroduce a hardcoded `trial_days=14` in the signup path. |
---
@@ -1400,7 +1404,7 @@ curl -sI -H "Host: ztest.jqc.app" http://127.0.0.1:8000/ | head -2
| 76 | `register-tenant-zero` never bootstraps and never drops the DB |
| 77 | `CONTROL_DATABASE_URL` not in interactive shell — always `set -a; . /etc/jqc/control.env; set +a` before CLI |
| 78 | Nginx `admin.jqc.app` must be a separate `server {}` block before `*.jqc.app` — exact name wins only in its own block |
| 79 | `jqc.app` apex has no registered tenant — Nginx redirects to `lts.jqc.app` at the server level |
| 79 | `jqc.app` apex has no registered tenant — Nginx **proxies** it to the app (port 8000) and the tenant middleware serves the public landing page (`landing.index`) for `/`. (Was a server-level 301 to `lts.jqc.app`; changed when the marketing landing page was added — see rule 85 + §10 of MULTI_TENANT_PLAN.md.) |
| 80 | `@feature_required` before `@quota_soft_check` in decorator stack — no point counting if feature is blocked |
| 81 | `TenantSettings.get_or_default()` returns a transient (non-persisted) default instance — `db.session.add(row)` required before first save |
| 82 | `inject_tenant_branding()` context processor wraps the DB call in try/except — branding failure must never break page rendering |
@@ -1437,9 +1441,9 @@ Stripe-backed subscription billing. Controlled by `BILLING_ENABLED` env var (def
### Trial period
- New tenants provisioned via `create_tenant()` get `subscription_status='trial'`, `trial_ends_at = now + 14 days` by default.
- Self-service signup (`/signup`) provisions a tenant immediately with a 14-day trial and sends a `welcome` email.
- Trial enforcement is in `_billing_gate()` — no Stripe required until they subscribe.
- New tenants provisioned via `create_tenant()` with `trial_days > 0` get `subscription_status='trial'`, `trial_ends_at = now + N days`. With `trial_days=0` they are provisioned `subscription_status='active'` (no trial) — used by the Free plan (rule 86).
- Self-service signup (`/signup`) provisions paid plans with a 14-day trial and the **Free plan as active/free-forever**, then sends a `welcome` email (wording adapts per plan).
- Trial enforcement is in `_billing_gate()` — no Stripe required until they subscribe; `active` and `None` pass through indefinitely.
### Billing emails (`app/billing/emails.py`)
@@ -1497,13 +1501,13 @@ All three actions write a `TenantAudit` row.
### Self-service signup (`/signup`)
Public route, exempt from tenant middleware. `SignupForm` validates:
Public route, exempt from tenant middleware. Reached from the public landing page (`landing.index`) CTA buttons. `SignupForm` validates:
- Company name, full name, email
- Subdomain: DNS label regex + uniqueness check against control DB
- Plan picker (Starter / Pro / Enterprise)
- Plan picker (Free / Starter / Pro / Enterprise — choices loaded from the control DB, cheapest-first so **Free is the default**)
- Password + confirm
On submit calls `create_tenant(admin_password=pw, trial_days=14)`. Shows `signup/success.html` with workspace URL and trial end date.
On submit calls `create_tenant(admin_password=pw, trial_days=0 if free else 14)` (rule 86). Shows `signup/success.html` with workspace URL and (for paid plans) trial end date.
---
+17 -3
View File
@@ -260,11 +260,19 @@ server {
location / { proxy_pass http://127.0.0.1:8001; ... }
}
# 2. APEX redirect — jqc.app has no registered tenant
# 2. APEX — jqc.app serves the public marketing/landing page
# (was a 301 redirect to lts.jqc.app; now proxied to the app, which the
# tenant middleware serves the landing page for — see app/routes/landing.py)
server {
listen 80;
server_name jqc.app;
return 301 http://lts.jqc.app$request_uri;
server_name jqc.app www.jqc.app;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host; # resolver reads this
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
# 3. WILDCARD — all tenant subdomains
@@ -275,6 +283,12 @@ server {
}
```
The apex block must pass `Host` through unchanged: the app's tenant middleware
compares `request.host` to `TENANT_BASE_DOMAIN` (and its `www.` variant) and
serves the landing page (`landing.index`) for `/`, bouncing any other apex path
back to `/`. `/signup`, `/welcome`, and `/static/` are tenant-exempt and served
directly. Tenant subdomains and `admin.jqc.app` are unaffected.
If `admin.jqc.app` is in the same block as `*.jqc.app`, Nginx routes it to port 8000 (main app), which returns "Workspace not found" because `admin.jqc.app` is not a registered tenant domain.
---
+2
View File
@@ -206,6 +206,7 @@ def create_app(config_name='default'):
from app.routes import devices # Admin device management
from app.routes import tenant_settings # MT-7 — tenant self-service
from app.routes import signup # MT-8+ — public self-service signup
from app.routes import landing # Public apex marketing/landing page
from app.billing import bp as billing_bp # MT-8 — Stripe billing
app.register_blueprint(auth.bp)
@@ -225,6 +226,7 @@ def create_app(config_name='default'):
app.register_blueprint(devices.bp)
app.register_blueprint(tenant_settings.bp)
app.register_blueprint(signup.bp)
app.register_blueprint(landing.bp)
# Billing blueprint is CSRF-exempt: /billing/webhook receives raw POST from
# Stripe and cannot carry a CSRF token. Subscribe/portal are GET redirects
# which Flask-WTF does not protect anyway (CSRF only applies to unsafe methods).
+1 -1
View File
@@ -36,7 +36,7 @@ _PLAIN_BODIES = {
'welcome': (
"Welcome to Janitorial QC!\n\n"
"Your workspace is ready at:\n {login_url}\n\n"
"Trial: {trial_days} days (expires {trial_ends_at})\n\n— The JQC Team"
"{trial_note}\n\nPlan: {plan_name}\n\n— The JQC Team"
),
'payment_failed': (
"We were unable to process your most recent payment for your JQC subscription.\n\n"
+92
View File
@@ -0,0 +1,92 @@
"""
app/routes/landing.py
----------------------
Public marketing / landing page served at the apex domain (e.g. jqc.app).
Canonical path is GET /welcome (always reachable, tenant-exempt) so the page
can be previewed directly in any environment. In multi-tenant production the
tenant middleware delegates the apex host's `/` to this view (see
app/tenancy/middleware.py) the apex is NOT a tenant, so `/` cannot be owned
by the login-gated dashboard route.
The page introduces the product, lists plans (read live from the control DB
when available, with a static fallback), and funnels visitors to the existing
public self-service signup at /signup (plan picker, Free selectable/default).
"""
import logging
from flask import Blueprint, render_template, current_app, url_for
bp = Blueprint('landing', __name__)
logger = logging.getLogger(__name__)
# Static fallback mirrors control/seed.py PLAN_DEFS so the page still renders if
# the control DB is unreachable or multi-tenancy is disabled (dev preview).
_FALLBACK_PLANS = [
dict(code='free', name='Free', price_label='$0',
max_users=3, max_facilities=2, max_inspections_month=50, max_issues_month=50,
allow_mobile_api=False, allow_scheduled_reports=False,
allow_branding=False, allow_custom_domain=False),
dict(code='starter', name='Starter', price_label='Contact us',
max_users=15, max_facilities=10, max_inspections_month=500, max_issues_month=500,
allow_mobile_api=True, allow_scheduled_reports=False,
allow_branding=False, allow_custom_domain=False),
dict(code='pro', name='Pro', price_label='Contact us',
max_users=50, max_facilities=50, max_inspections_month=5000, max_issues_month=5000,
allow_mobile_api=True, allow_scheduled_reports=True,
allow_branding=True, allow_custom_domain=True),
dict(code='enterprise', name='Enterprise', price_label='Contact us',
max_users=None, max_facilities=None, max_inspections_month=None, max_issues_month=None,
allow_mobile_api=True, allow_scheduled_reports=True,
allow_branding=True, allow_custom_domain=True),
]
def _plan_dict(p):
"""Flatten a control Plan ORM row into a template-safe dict (read inside the
open session so no lazy attribute access happens after it closes)."""
if p.price_cents == 0:
price_label = '$0'
elif p.price_cents:
price_label = f'${p.price_cents // 100}/mo'
else:
price_label = 'Contact us'
return dict(
code=p.code, name=p.name, price_label=price_label,
max_users=p.max_users, max_facilities=p.max_facilities,
max_inspections_month=p.max_inspections_month,
max_issues_month=p.max_issues_month,
allow_mobile_api=p.allow_mobile_api,
allow_scheduled_reports=p.allow_scheduled_reports,
allow_branding=p.allow_branding,
allow_custom_domain=p.allow_custom_domain,
)
def _load_plans():
"""Return plan dicts from the control DB, ordered cheapest-first, with a
static fallback so the landing page never fails to render."""
try:
from control.base import control_session
from control.models import Plan
with control_session() as s:
plans = (s.query(Plan)
.order_by(Plan.price_cents.nullslast(), Plan.id)
.all())
if plans:
return [_plan_dict(p) for p in plans]
except Exception as exc:
logger.debug('LANDING | plan_load_failed | err=%s', exc)
return _FALLBACK_PLANS
@bp.route('/welcome')
def index():
return render_template(
'landing/index.html',
plans=_load_plans(),
signup_url=url_for('signup.index'),
base_domain=current_app.config.get('TENANT_BASE_DOMAIN', 'jqc.app'),
)
+20 -3
View File
@@ -27,16 +27,28 @@ logger = logging.getLogger(__name__)
def _send_welcome_email(to_email, login_url, tenant_name, plan_code, trial_ends_at):
"""Fire a welcome email in a background thread — never blocks the request."""
"""Fire a welcome email in a background thread — never blocks the request.
The wording adapts to the plan: the Free plan has no trial/expiry, paid
plans start a 14-day trial. `trial_note` carries the plan-appropriate line
and `trial_ends_at` is blank for Free so the template hides the trial row.
"""
try:
from app.billing.emails import send_billing_email
is_free = (plan_code == 'free')
ends_str = (trial_ends_at.strftime('%B %d, %Y')
if hasattr(trial_ends_at, 'strftime') else str(trial_ends_at or ''))
if is_free:
trial_note = "You're on the Free plan — no credit card, no expiry."
ends_str = ''
else:
trial_note = f'Your 14-day free trial runs through {ends_str}.'
send_billing_email(to_email, 'welcome', {
'tenant_name': tenant_name,
'login_url': login_url,
'trial_days': 14,
'trial_days': 0 if is_free else 14,
'trial_ends_at': ends_str,
'trial_note': trial_note,
'plan_name': plan_code.title(),
})
except Exception as exc:
@@ -115,6 +127,11 @@ def index():
plan_code = form.plan.data
password = form.password.data
# Free plan is free forever — no trial, no expiry. Paid plans start a
# 14-day trial. trial_days=0 makes create_tenant provision the tenant as
# 'active' (see control/provision.py) so the billing gate never blocks it.
trial_days = 0 if plan_code == 'free' else 14
try:
from control.provision import create_tenant
info = create_tenant(
@@ -124,7 +141,7 @@ def index():
admin_email=email,
admin_full_name=full_name,
admin_password=password,
trial_days=14,
trial_days=trial_days,
)
except ValueError as exc:
flash(str(exc), 'danger')
+2 -2
View File
@@ -2,14 +2,14 @@
{% set subject = "Welcome to JQC — your workspace is ready" %}
{% block body %}
<h2 style="margin:0 0 8px;font-size:1.2rem;color:#111827;">Welcome to Janitorial QC!</h2>
<p style="margin:0 0 20px;color:#6b7280;font-size:.9rem;">Your workspace <strong>{{ tenant_name }}</strong> is ready. You're on a free trial — no credit card needed until {{ trial_ends_at }}.</p>
<p style="margin:0 0 20px;color:#6b7280;font-size:.9rem;">Your workspace <strong>{{ tenant_name }}</strong> is ready. {{ trial_note }}</p>
<table width="100%" cellpadding="12" cellspacing="0" style="background:#f0fdf4;border-radius:6px;margin-bottom:24px;">
<tr>
<td>
<p style="margin:0;font-size:.9rem;color:#15803d;line-height:1.6;">
<strong>&#10003; Workspace:</strong> <a href="{{ login_url }}" style="color:#15803d;">{{ login_url }}</a><br>
<strong>&#10003; Free trial:</strong> {{ trial_days }} days (expires {{ trial_ends_at }})<br>
{% if trial_ends_at %}<strong>&#10003; Free trial:</strong> {{ trial_days }} days (expires {{ trial_ends_at }})<br>{% endif %}
<strong>&#10003; Plan:</strong> {{ plan_name }}
</p>
</td>
+175
View File
@@ -0,0 +1,175 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Janitorial QC — Quality control for janitorial contracts</title>
<meta name="description" content="Run inspections, track issues with SLA enforcement, and share live reports with your customers. Start free.">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
:root { --jqc-primary:#1a56db; --jqc-accent:#16a34a; }
body { font-family:-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif; color:#1f2937; }
.navbar-brand { font-weight:700; letter-spacing:-.02em; }
.hero { background:linear-gradient(160deg,#eff4ff 0%,#f8fafc 60%,#f0fdf4 100%); padding:5rem 0 4.5rem; }
.hero h1 { font-size:2.6rem; font-weight:800; letter-spacing:-.03em; line-height:1.1; }
.hero .lead { color:#4b5563; font-size:1.15rem; max-width:34rem; }
.btn-jqc { background:var(--jqc-primary); border-color:var(--jqc-primary); color:#fff; }
.btn-jqc:hover { background:#1544b0; border-color:#1544b0; color:#fff; }
.feature-icon { width:44px;height:44px;border-radius:10px;display:flex;align-items:center;justify-content:center;
background:#eff4ff;color:var(--jqc-primary);font-size:1.35rem;font-weight:700; }
.section { padding:4.5rem 0; }
.price-card { border:1px solid #e5e7eb;border-radius:14px;height:100%; transition:box-shadow .15s,transform .15s; }
.price-card:hover { box-shadow:0 10px 30px rgba(0,0,0,.07); transform:translateY(-2px); }
.price-card.popular { border-color:var(--jqc-primary); box-shadow:0 10px 30px rgba(26,86,219,.12); }
.price-amt { font-size:2rem;font-weight:800;letter-spacing:-.02em; }
.plan-feat { font-size:.9rem;color:#374151; }
.plan-feat .yes { color:var(--jqc-accent);font-weight:700; }
.plan-feat .no { color:#cbd5e1; }
footer { background:#0f172a;color:#94a3b8;padding:2.5rem 0; }
footer a { color:#cbd5e1;text-decoration:none; }
</style>
</head>
<body>
<!-- Nav -->
<nav class="navbar navbar-expand-md navbar-light bg-white border-bottom sticky-top">
<div class="container">
<a class="navbar-brand text-primary" href="#top">Janitorial<span style="color:var(--jqc-accent)">QC</span></a>
<div class="ms-auto d-flex align-items-center gap-2">
<a class="nav-link d-none d-sm-inline text-secondary" href="#features">Features</a>
<a class="nav-link d-none d-sm-inline text-secondary" href="#pricing">Pricing</a>
<a class="btn btn-jqc btn-sm px-3" href="{{ signup_url }}">Start free</a>
</div>
</div>
</nav>
<!-- Hero -->
<header class="hero" id="top">
<div class="container">
<div class="row align-items-center g-5">
<div class="col-lg-7">
<span class="badge rounded-pill text-bg-success-subtle text-success mb-3">No credit card required</span>
<h1 class="mb-3">Quality control for janitorial contracts.</h1>
<p class="lead mb-4">
Run structured inspections, track issues with automatic SLA enforcement,
and give your customers a live window into every facility — all in one place.
</p>
<div class="d-flex flex-wrap gap-2">
<a class="btn btn-jqc btn-lg px-4" href="{{ signup_url }}">Register free</a>
<a class="btn btn-outline-secondary btn-lg px-4" href="#pricing">See plans</a>
</div>
</div>
<div class="col-lg-5">
<div class="bg-white rounded-4 shadow-sm p-4 border">
<div class="d-flex justify-content-between align-items-center mb-3">
<strong>Facility scorecard</strong>
<span class="badge text-bg-success">96%</span>
</div>
<div class="progress mb-2" role="progressbar" aria-label="score"><div class="progress-bar bg-success" style="width:96%"></div></div>
<small class="text-muted">Restrooms</small>
<div class="progress mb-2 mt-1"><div class="progress-bar bg-success" style="width:92%"></div></div>
<small class="text-muted">Lobby &amp; entrances</small>
<div class="progress mb-2 mt-1"><div class="progress-bar" style="width:78%;background:#f59e0b"></div></div>
<small class="text-muted">Open issues</small>
<div class="d-flex gap-2 mt-2">
<span class="badge text-bg-danger">1 critical</span>
<span class="badge text-bg-warning">2 high</span>
<span class="badge text-bg-secondary">3 open</span>
</div>
</div>
</div>
</div>
</div>
</header>
<!-- Features -->
<section class="section" id="features">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold">Everything you need to prove clean.</h2>
<p class="text-muted">From the inspector's tablet to the customer's inbox.</p>
</div>
<div class="row g-4">
<div class="col-md-6 col-lg-3">
<div class="feature-icon mb-3">&#10003;</div>
<h5 class="fw-semibold">Custom inspections</h5>
<p class="text-muted small mb-0">Build templates with a drag-and-drop form editor. Score areas, attach photos, and capture GPS at submit time.</p>
</div>
<div class="col-md-6 col-lg-3">
<div class="feature-icon mb-3">&#9200;</div>
<h5 class="fw-semibold">Issues with SLA</h5>
<p class="text-muted small mb-0">Flag problems by severity. The SLA engine escalates automatically and alerts the right people before deadlines slip.</p>
</div>
<div class="col-md-6 col-lg-3">
<div class="feature-icon mb-3">&#128202;</div>
<h5 class="fw-semibold">Live reports</h5>
<p class="text-muted small mb-0">Score trends, aging, SLA compliance, and per-facility PDF summaries — on demand or on a schedule.</p>
</div>
<div class="col-md-6 col-lg-3">
<div class="feature-icon mb-3">&#128241;</div>
<h5 class="fw-semibold">Offline iPad app</h5>
<p class="text-muted small mb-0">Inspectors work anywhere. Records sync automatically when a connection returns — no lost data in the field.</p>
</div>
</div>
</div>
</section>
<!-- Pricing -->
<section class="section bg-light" id="pricing">
<div class="container">
<div class="text-center mb-5">
<h2 class="fw-bold">Simple plans that grow with you.</h2>
<p class="text-muted">Start on the Free plan — upgrade any time.</p>
</div>
<div class="row g-4 align-items-stretch">
{% for p in plans %}
<div class="col-md-6 col-lg-3">
<div class="price-card p-4 {% if p.code == 'pro' %}popular{% endif %}">
{% if p.code == 'pro' %}<span class="badge text-bg-primary mb-2">Most popular</span>{% endif %}
<h5 class="fw-bold mb-1">{{ p.name }}</h5>
<div class="price-amt mb-3">{{ p.price_label }}</div>
<ul class="list-unstyled plan-feat mb-4">
<li class="mb-2"><span class="yes">&#10003;</span> {{ p.max_users or 'Unlimited' }} users</li>
<li class="mb-2"><span class="yes">&#10003;</span> {{ p.max_facilities or 'Unlimited' }} facilities</li>
<li class="mb-2"><span class="yes">&#10003;</span> {{ p.max_inspections_month or 'Unlimited' }} inspections/mo</li>
<li class="mb-2">{% if p.allow_mobile_api %}<span class="yes">&#10003;</span>{% else %}<span class="no">&#10007;</span>{% endif %} Mobile iPad app</li>
<li class="mb-2">{% if p.allow_scheduled_reports %}<span class="yes">&#10003;</span>{% else %}<span class="no">&#10007;</span>{% endif %} Scheduled reports</li>
<li class="mb-2">{% if p.allow_branding %}<span class="yes">&#10003;</span>{% else %}<span class="no">&#10007;</span>{% endif %} Custom branding</li>
<li class="mb-2">{% if p.allow_custom_domain %}<span class="yes">&#10003;</span>{% else %}<span class="no">&#10007;</span>{% endif %} Custom domain</li>
</ul>
<a href="{{ signup_url }}" class="btn w-100 {% if p.code == 'pro' %}btn-jqc{% else %}btn-outline-secondary{% endif %}">
{% if p.code == 'free' %}Get started{% else %}Choose {{ p.name }}{% endif %}
</a>
</div>
</div>
{% endfor %}
</div>
<p class="text-center text-muted small mt-4 mb-0">
Every workspace gets its own secure database and a <strong>your-name.{{ base_domain }}</strong> address.
</p>
</div>
</section>
<!-- CTA -->
<section class="section text-center">
<div class="container">
<h2 class="fw-bold mb-3">Ready to see cleaner results?</h2>
<p class="text-muted mb-4">Set up your workspace in under two minutes.</p>
<a class="btn btn-jqc btn-lg px-5" href="{{ signup_url }}">Register for free</a>
</div>
</section>
<footer>
<div class="container d-flex flex-column flex-md-row justify-content-between align-items-center gap-2">
<span>&copy; Janitorial QC</span>
<span class="d-flex gap-3">
<a href="#features">Features</a>
<a href="#pricing">Pricing</a>
<a href="{{ signup_url }}">Register</a>
</span>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
+17 -1
View File
@@ -57,6 +57,8 @@ def _is_exempt(path):
return True
if path.startswith('/signup'):
return True # public self-service signup has no tenant context
if path.startswith('/welcome'):
return True # public marketing/landing page has no tenant context
if path.startswith('/notifications/trial-reminders'):
return True # cross-tenant cron — iterates all tenants from control DB
if path.startswith('/notifications/dunning-reminders'):
@@ -74,6 +76,7 @@ def init_tenancy(app):
g.tenant = None
g.tenant_engine = None
g.billing_warning = None # MT-8: set to 'past_due' by _billing_gate when needed
g.is_apex = False # True when serving the public apex/landing host
if not current_app.config.get('MULTI_TENANT_ENABLED', False):
return # inert: default database serves everything (single-tenant)
@@ -124,8 +127,21 @@ def init_tenancy(app):
session.pop('impersonating_tenant_id', None)
session.pop('impersonating_superadmin_id', None)
# ── Normal Host → tenant resolution ──────────────────────────────
# ── Apex (marketing) host → public landing page ──────────────────
# The apex domain (jqc.app) and its www. variant are NOT tenants. Serve
# the public landing page for '/' and send any other non-exempt apex
# path back to it. /signup, /static, /welcome are already exempt above.
host = (request.host or '').split(':')[0].strip().lower()
base = (current_app.config.get('TENANT_BASE_DOMAIN') or '').strip().lower()
if base and host in (base, f'www.{base}'):
g.is_apex = True
if request.path == '/':
# Serve the landing view without a redirect (dashboard owns '/'
# on tenant hosts, so we can't register a second '/' route).
return current_app.view_functions['landing.index']()
return redirect('/')
# ── Normal Host → tenant resolution ──────────────────────────────
tenant = resolve_tenant(host)
if tenant is None:
return Response(_UNKNOWN_TENANT_PAGE, status=404, mimetype='text/html')
+5
View File
@@ -47,6 +47,11 @@ class Config:
p.strip() for p in os.environ.get('MULTI_TENANT_EXEMPT_PATHS', '').split(',')
if p.strip()
]
# Apex domain for the public marketing/landing page. When MULTI_TENANT_ENABLED
# is True, requests to this host (and its www. variant) are served the landing
# page instead of being resolved to a tenant. Mirrors TENANT_BASE_DOMAIN used
# by the provisioner to build <slug>.<base> subdomains.
TENANT_BASE_DOMAIN = os.environ.get('TENANT_BASE_DOMAIN', 'jqc.app')
# Per-tenant SQLAlchemy engine pool tuning (see MULTI_TENANT_PLAN.md §4).
TENANT_ENGINE_POOL_SIZE = int(os.environ.get('TENANT_ENGINE_POOL_SIZE', 5))
TENANT_ENGINE_MAX_OVERFLOW = int(os.environ.get('TENANT_ENGINE_MAX_OVERFLOW', 5))
+4
View File
@@ -269,6 +269,10 @@ def create_tenant(slug, name, plan_code, admin_email, admin_username=None,
if trial_days:
t.subscription_status = 'trial'
t.trial_ends_at = now_eastern() + timedelta(days=trial_days)
else:
# No trial (e.g. Free plan) — provision as active so the billing
# gate treats it as a live, non-expiring subscription.
t.subscription_status = 'active'
t.set_db_password(password)
s.add(t); s.flush()
tenant_id = t.id
+66
View File
@@ -0,0 +1,66 @@
"""
Tests for the public apex landing page (app/routes/landing.py) and the
apex-host routing in the tenant middleware (app/tenancy/middleware.py).
Two invariants:
1. GET /welcome always renders the landing page (tenant-exempt, any host).
2. When multi-tenancy is on, the apex host (TENANT_BASE_DOMAIN + www.) serves
the landing page at '/' and bounces any other non-exempt path back to '/',
while /signup stays reachable. Tenant subdomains are unaffected (still 404
for unknown hosts, dashboard still owns '/').
"""
import pytest
def test_welcome_renders_landing(app):
"""/welcome is public and renders the marketing page (MT inert here)."""
client = app.test_client()
r = client.get('/welcome')
assert r.status_code == 200
assert b'Quality control for janitorial contracts' in r.data
assert b'/signup' in r.data # funnels to existing signup
assert b'Simple plans that grow with you' in r.data # pricing section
@pytest.fixture
def mt_app(app):
"""The shared app with multi-tenancy temporarily enabled (apex = jqc.app).
Reuses the single app instance create_app cannot be called twice in one
process because the /api/v1 parent blueprint is a module-level singleton.
The middleware reads current_app.config per request, so toggling config here
is sufficient. Config is restored afterwards so other tests are unaffected.
"""
prev_mt = app.config.get('MULTI_TENANT_ENABLED')
prev_base = app.config.get('TENANT_BASE_DOMAIN')
app.config.update(MULTI_TENANT_ENABLED=True, TENANT_BASE_DOMAIN='jqc.app')
yield app
app.config.update(MULTI_TENANT_ENABLED=prev_mt, TENANT_BASE_DOMAIN=prev_base)
def test_apex_root_serves_landing(mt_app):
client = mt_app.test_client()
r = client.get('/', headers={'Host': 'jqc.app'})
assert r.status_code == 200
assert b'Quality control for janitorial contracts' in r.data
def test_www_apex_serves_landing(mt_app):
client = mt_app.test_client()
r = client.get('/', headers={'Host': 'www.jqc.app'})
assert r.status_code == 200
assert b'Quality control for janitorial contracts' in r.data
def test_apex_other_path_redirects_to_root(mt_app):
client = mt_app.test_client()
r = client.get('/issues', headers={'Host': 'jqc.app'})
assert r.status_code == 302
assert r.headers['Location'] == '/'
def test_apex_signup_is_reachable(mt_app):
client = mt_app.test_client()
r = client.get('/signup', headers={'Host': 'jqc.app'})
assert r.status_code == 200