Paste your unpaid invoices. Get the follow-up email already written, in the right tone for how late it is.
docstoc never emails your clients for you — it drafts follow-ups you copy into Gmail, Outlook, or Apple Mail. Tone escalates with days overdue (friendly → firm → direct).
Live URLs
AI invoice follow-up emails for freelancers. Draft-only, never sends for you.
Legacy chasa.io / api.chasa.io301 to docstoc (Pages _middleware.ts + worker redirect). See scripts/oauth-redirect-uris.md for provider console URIs.
Go-live checklist
Attach docstoc.io on Cloudflare Pages project chasa and wait for Active.
www.docstoc.io → apex: handled by apps/web/functions/_middleware.ts (redeploy web).
chasa.io / www.chasa.io → docstoc.io: same middleware.
api.chasa.io → api.docstoc.io: worker middleware in apps/worker/src/lib/legacyHostRedirect.ts.
Register OAuth redirect URIs on api.docstoc.io — see scripts/oauth-redirect-uris.md.
Optional DMARC: ./scripts/dmarc-remove-rua.sh (removes rua= from _dmarc.docstoc.io).
Run ./scripts/go-live-verify.sh.
The order does not matter: browser-facing links are built from the origin the request came in on (see “App origin resolution” below), so pages.dev and chasa.io both keep working whichever is deployed first.
App origin resolution
Magic links, post-login redirects, Stripe return URLs and team invites use the origin the user is actually on, not PUBLIC_APP_URL. The Pages /api proxy forwards it as X-Docstoc-App-Origin, and the worker honours it only if it matches lib/appUrl.ts's allowlist (PUBLIC_APP_URL, docstoc.io, www.docstoc.io, legacy chasa.io hosts, *.pages.dev project/preview hosts, localhost). This keeps preview deploys self-contained and makes the domain cutover zero-downtime.
Requests that arrive without a trusted origin — provider OAuth callbacks hitting api.docstoc.io directly, and the digest cron — still fall back to PUBLIC_APP_URL.
Stripe price IDs live in apps/worker/wrangler.toml as STRIPE_PRICE_SOLO (maps to Pro), STRIPE_PRICE_PRO / STRIPE_PRICE_ENTERPRISE (map to Business; non-secret). Billing portal and webhooks update accounts.plan and is_paid.
Workspace roles: owner is always admin. Invited members can use Pro+ features; admin-only actions: branding, webhooks, connector OAuth connect/import, API key CRUD, team invites.
App routes (/app/*)
Route
Purpose
/
Tool — invoice list, AI drafts, CSV/PDF import, multi-select batch
/login
Magic-link login + Cloudflare Turnstile
/account
Plan, billing portal, payment link
/team
Invite members, roles (Pro+)
/clients
Client CRM (Pro+)
/branding
Logo + late-fee hint (workspace admin)
/webhooks
Outbound webhook URLs (workspace admin)
/connector
Cloud storage + QBO/Xero OAuth + API keys
/admin
Internal admin dashboard (separate cookie)
All app routes except /login and /admin require a session. Unauthenticated users redirect to /login. SPA analytics require cookie consent (GDPR).
i18n (EN + ES)
Same path as Docracy: lightweight catalogs in apps/web/app/src/lib/i18n/ (no i18next). LocaleProvider + EN|ES switcher on login, sidebar, and More sheet. P1 covers login / shell / welcome; expand catalogs for the rest of the app next. Preference stored as chasa_locale. Marketing HTML stays English until a later pass.
Marketing & SEO (static HTML in apps/web/public/)
Homepage with pricing, FAQ JSON-LD, competitor comparison
SEO landing pages: /invoice-follow-up, /payment-reminder, /overdue-invoice, /chase-invoices, /freelancer-invoice-follow-up
/features/ (index, AI tone, templates), /docs/, /ai, /about
/blog/ (3 articles + dynamic post.html)
/free-templates/ — 15 generated template pages + index
Click tracking: redirects only to URLs stored when the tracked email was created
Webhook URLs: SSRF checks (no localhost / private IPs)
OAuth state: timing-safe HMAC compare
CSP: enforcing policy on Pages; report-uri → /api/csp-report
GDPR: cookie consent gates SPA analytics; no visitor IDs on page views (aggregate only)
Secrets: never committed — wrangler secret put …
Local development
npm install
npm run dev:worker # wrangler dev --local, http://127.0.0.1:8787
npm run dev:web # vite, http://localhost:5173 (proxies /api to worker)
Without RESEND_API_KEY, magic links log to the worker console — copy the URL into your browser.
Quality checks
npm run lint # ESLint (web app + worker)
npm run test # Vitest (schemas, crypto, dates)
npm run typecheck # tsc worker + vite build web
CI (.github/workflows/ci.yml) runs lint → test → static HTML validation → typecheck on every PR; auto-deploys worker + web on push to main when CLOUDFLARE_API_TOKEN is set.
Deploy manually
npm run deploy:worker
npm run deploy:web # builds (copies fonts) then pages deploy
After schema changes:
cd apps/worker
wrangler d1 migrations apply chasa-db --local # dev
wrangler d1 migrations apply chasa-db --remote # production
Migrations 0001–0011 include plans, admin/analytics, branding, webhooks, API keys, cloud connectors, clients/aging, parity features, and security hardening (rate limits, AI usage, Stripe idempotency, tracking link allowlist).
wrangler secret put RESEND_API_KEY — verify sending domain in Resend
Turnstile — see above
wrangler secret put ADMIN_PASSWORD — for /app/admin
9a. AI Document Generator (optional, public marketing tool):Google AI Studio → create a free API key → wrangler secret put GEMINI_API_KEY. Free tier is rate-limited; the worker also enforces its own per-IP limit + Turnstile. See apps/worker/src/lib/geminiDocGen.ts.
wrangler secret put DROPBOX_CLIENT_ID
wrangler secret put DROPBOX_CLIENT_SECRET
wrangler secret put ONEDRIVE_CLIENT_ID
wrangler secret put ONEDRIVE_CLIENT_SECRET
wrangler secret put BOX_CLIENT_ID
wrangler secret put BOX_CLIENT_SECRET
wrangler secret put GOOGLE_LOGIN_CLIENT_SECRET
wrangler secret put GOOGLE_INTEGRATIONS_CLIENT_SECRET