This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun devOpen http://localhost:3000 with your browser to see the result.
The Docker development stack runs Next.js against an isolated MongoDB database
named waysorted_local. Production notification producers are disabled by the
Compose configuration.
-
Create the ignored local environment file:
cp .env.docker.example .env.docker.local
-
Add localhost Google OAuth credentials and Razorpay test-mode credentials only when those flows are being tested. The Google callback URL is:
http://localhost:3000/api/auth/callbackDEV_PRICING_COUNTRYis the explicit local regional-pricing override. In production, it is ignored and pricing trusts only Vercel'sx-vercel-ip-countryheader. -
Start the application and database:
docker compose up -d --build web
The development container uses Turbopack and mounts the source tree at runtime. It does not copy the large
publicdirectory into the development image. -
Open http://localhost:3000.
Useful commands:
docker compose logs -f web
docker compose restart web
docker compose downdocker compose down preserves the local MongoDB volume. Running
docker compose down -v permanently deletes the local database copy.
The optional Figma MCP service is started separately:
docker compose --profile figma up -d figma-mcpDo not put production database, Razorpay, email, or notification credentials in
.env.docker.local. Refreshing the local database from production must be a
controlled owner operation, and the resulting local copy must be treated as
sensitive data.
After deploying the user-scoped usage-reservation idempotency change, run this once against the intended database before enabling traffic:
npm run migrate:usage-reservation-indexYou can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.
File Importer → Canva reaches the existing Python capture backend only through
the authenticated /api/figma/canva/* gateway.
CANVA_IMPORTER_BACKEND_URLis the Python service base URL. Production accepts HTTPS only; local development may usehttp://localhostorhttp://127.0.0.1.CANVA_IMPORTER_SERVICE_TOKENis optional. When present, Waysorted forwards it to the Python service asX-Waysorted-Service-Token.
The gateway accepts a valid Waysorted cookie or plugin bearer token and only forwards the capture-job, capture-metadata, cancellation, and page-image routes used by the plugin.
Account activation, preference, feedback, billing, credit, and tool-usage events are emitted to the newsletter v2 notification ingest service when these server-side environment variables are configured:
NOTIFICATION_INGEST_URL: Full/api/v2/notifications/eventsingest URL.NOTIFICATION_INGEST_TOKEN: Shared ingest token configured on the newsletter service.NOTIFICATION_EVENT_SOURCE: Event source name allowed by the newsletter service.NOTIFICATION_INGEST_TIMEOUT_MS: Optional request timeout override.NOTIFICATION_HEAVY_USAGE_CREDIT_THRESHOLD: Optional credit threshold fortool_usage_heavyevents. Defaults to100.NOTIFICATION_LOW_CREDIT_THRESHOLD: Optional post-reservation balance threshold for proactivecredits_lowevents. Defaults to20.NOTIFICATION_PRODUCER_ENABLED=false: Optional local kill switch.
Purchase-completion delivery is retried through Razorpay when a configured Newsletter service is temporarily unreachable or rejects the event. If the producer is explicitly disabled or has no configuration, payment processing finishes and records a warning because webhook retries cannot repair missing deployment configuration.
Razorpay webhook processing uses a two-minute ownership lease. A concurrent delivery receives a retryable response instead of being acknowledged as a duplicate, and an expired lease can be claimed safely by a later retry. The daily maintenance run marks abandoned leases as failed and reconciles captured one-time purchases whose original webhook or browser callback did not finish.
After deploying the billing schema hardening, run these one-time migrations against the target database before enabling payment traffic:
npm run migrate:billing-idempotency-indexes
npm run migrate:redact-razorpay-event-logsThe first aligns purchase/refund uniqueness with application idempotency. The second removes signatures and payer details from historical webhook logs; new logs are already stored in redacted form and expire after 180 days.
The billing notification producer emits subscription_checkout_started when a
subscription checkout is created and the deterministic
subscription_purchase_completed event when Razorpay confirms the matching
purchase or subscription. The newsletter service uses these events to schedule
and safely cancel the N3 purchase-retention reminder.
The daily /api/cron/n4-product-recall route identifies previously active
users as they cross seven days without a successful login or committed credited
tool job. It emits deterministic product_inactive_7d events. Successful
logins emit product_activity_resumed; existing tool_usage_completed events
also cancel pending recall work.
Required rollout configuration:
CRON_SECRET: Protects the Vercel Cron route.NOTIFICATION_N4_PRODUCER_ENABLED=false: Independent producer kill switch.NOTIFICATION_N4_PRODUCER_STARTED_AT: Required ISO timestamp that prevents historical dormant-user backfill.NOTIFICATION_N4_INACTIVITY_DAYS: Defaults to7.NOTIFICATION_N4_SCAN_LOOKBACK_HOURS: Defaults to50for one missed-run recovery; deterministic IDs make overlap safe.NOTIFICATION_N4_SCAN_LIMIT: Defaults to100and is capped at500.NOTIFICATION_N4_CANARY_TEST_ENABLED=false: Enables the protected, canary-only simulated scan. Keep disabled outside a short test window.NOTIFICATION_N4_PRODUCER_CANARY_EMAILS: Comma-separated emails permitted as simulated scan targets.
To prove the production scanner path without changing activity timestamps or
waiting seven days, temporarily enable the canary test flag and send an
authenticated POST /api/cron/n4-product-recall request with
{"email":"owner@example.com"}. The endpoint loads that allowlisted user's
real latest successful activity, evaluates the normal scanner just beyond the
configured inactivity threshold, and emits a clearly marked test event. It
never scans another user. Disable the test flag immediately after validation.
This activity definition has partial coverage: it intentionally excludes non-credit plugin interactions until their telemetry is reliable.