Overview
System overview
High-level architecture for the YourNextSaaS monorepo: deployable apps, shared packages, auth, admin, and cross-cutting features.
Monorepo layout
- pnpm workspace:
apps/web(TanStack Start, product),apps/docs(developer documentation site),apps/marketing(public site). - Shared code:
packages/core(config, origins),packages/server(DB, auth, billing, webhooks),packages/shared(UI, hooks, features).
Production hosts
- Marketing apex — landing, pricing, legal, SEO, sitemap.
app.*— authenticated product (dashboard shell, settings, APIs).docs.*— this documentation site.
Better Auth
BETTER_AUTH_URLmust be the product origin (where/api/authis served).BETTER_AUTH_TRUSTED_ORIGINSmust list every browser origin in use (marketing + app in production).- Optional
BETTER_AUTH_COOKIE_DOMAIN(e.g..yournextsaas.xyz) for shared cookies across subdomains.
Details: Auth & sessions.
Operator console
/admin/*on the product app (same shell as the dashboard).- Dashboard
/includes usage analytics via server functions scoped to the user’s orgs. - Platform admins also load aggregate KPIs and catalog-based estimates where implemented.
Settings and workspace
- Settings layout wraps
/settings/*. - Workspace actions:
packages/server/src/org/workspace-actions.ts(profile name, create org, list members). - Onboarding checklist:
/onboarding.
Audit log
- Org-scoped
audit_log_entries(actor, action, resource, metadata, IP). - Settings UI:
/settings/audit-log. - Server:
packages/server/src/audit/*. - Typical writes: workspace create, API key create/revoke, Stripe checkout/portal, invitation create/revoke/accept.
Invitations
- Table
organization_invitationswith token hash. - Create/list/revoke on Team settings; accept at
/invite/$token. - Sign-in/up support
?redirect=for returning to the invite link.
Webhooks (outbound)
- Tables
webhook_endpointsandwebhook_deliveries. - Settings:
/settings/webhooks. - Server:
packages/server/src/webhooks/*. - Signed POSTs:
X-YNS-Signature,X-YNS-Event,X-YNS-Delivery. - Dispatched on workspace/invite lifecycle and manual
webhook.pingtests.
SEO and marketing
- Public routes use SEO helpers,
VITE_SITE_URL, dynamicsitemap.xml, andpublic/robots.txton the marketing app.
i18n and RTL
- Root route context exposes
locale(en|ar) from cookieyns_localeandAccept-Language. AppI18nProvider+ messages under shared i18n paths; RTL viadir="rtl"on<html>for Arabic.
See i18n & RTL.