WOOSTACK

Overview

Understand the recommended architecture for TypeScript web applications and when to add mobile or desktop apps.

This stack is a starting point for a TypeScript product with a public website, a signed-in web application, and an API. It favors static public content and a client-rendered app, released together on Cloudflare Workers. Mobile and desktop apps are optional additions.

These are recommendations, not requirements for using Woostack. Existing repositories keep their selected technologies and conventions. This documentation site itself uses Next.js and Fumadocs; its implementation and deployment are described in the docs app README.

For deployment steps, see Deploy a full-stack Cloudflare Worker. For the engineering principles behind application boundaries, see Repository structure and rules.

Stack

The core web stack separates public content, interactive application screens, and server-side work. Optional tools address specific needs rather than becoming dependencies of every project. Package versions belong in the consuming project's manifests and lockfile; this list is not a certified compatibility matrix.

ResponsibilityRecommendationRole
Language and toolingTypeScript, ES modules, Node.jsNode runs local tooling and Node deployments; Workers has its own runtime.
Workspacepnpm workspacesKeeps app dependencies separate. Turborepo is optional when cross-app task orchestration and caching help.
Public siteAstroPrerenders marketing pages, blog posts, and other public content.
Web applicationReact, Vite, standalone TanStack RouterProvides client-rendered screens, typed navigation, and URL state. TanStack Start is not part of this recommendation.
Remote dataTanStack Query, oRPCQuery manages remote-data caching; oRPC supplies typed API calls.
APIHono, oRPC, ZodHandles HTTP requests, procedures, and runtime input validation.
DatabaseNeon PostgreSQL, Drizzle ORM, Drizzle Kit, pgStores application data; Drizzle Kit owns migrations. Hyperdrive pools Workers connections.
AuthenticationManaged Neon AuthProvides managed authentication; the API still verifies sessions and enforces authorization.
Web UITailwind CSS, shadcn/ui with Base UI primitivesSupplies styles and reusable web controls.
DocumentationFumadocs with AstroAdds documentation layouts, MDX content, and static search to the public site.
DeploymentCloudflare Workers, Wrangler, GitHub ActionsReleases public assets, app assets, and the API as one unit per environment.

Supporting tools depend on what the product needs:

NeedRecommendation
Native mobileReact Native, Expo, Expo Router; DOM components for selected web screens
Desktop appsTauri with React/Vite
Component catalogStorybook with React/Vite
UI utilitiesRecharts, date-fns, Embla Carousel, or React Day Picker where needed
Translated application UIi18next and react-i18next
AI featuresTanStack AI with direct provider adapters
Transactional emailResend
Web payments and subscriptionsStripe
Product analyticsPostHog
Revenue, costs, and profitOpenProfit
App and component testsVitest, React Testing Library with a DOM environment
Critical browser journeysPlaywright
Standalone Node script testsNative Node.js test runner and tsx, without duplicating Vitest suites
Linting and formattingOxlint, @shadcn/lint, Oxfmt
Local infrastructureDocker Compose, PostgreSQL, a local HTTPS Better Auth fixture, Wrangler

A local auth fixture supports development without proving managed-auth integration. Trusted preview checks cover the production provider, callbacks, and cookie behavior.

Application boundaries and rendering

The public site and signed-in app have different readers and rendering needs. Separate workspace apps let each use an appropriate renderer while sharing UI or contracts where there is real reuse.

Astro owns public routes such as /, /pricing/, /blog/, and /docs/. Static generation produces their HTML at build time. Readers and crawlers receive the main content without waiting for client JavaScript. React islands add interactive sections, such as a pricing calculator, without making every page a single-page application (SPA).

The React/Vite app uses standalone TanStack Router for navigation. After loading the app shell, the browser renders screens and requests data from the API. This suits signed-in workflows that do not need search indexing. TanStack Query caches server data in the client; it does not replace server-side authorization or database consistency.

Request-time server-side rendering (SSR) is a separate choice for public pages whose initial HTML needs fresh or request-specific data. It adds an adapter and server-handler integration. A different client router alone does not supply SSR, and static public content does not need SSR on every request.

Blogs and documentation

Git-backed Markdown in Astro Content Collections is the blog default. Posts live with the public site and produce complete article HTML under /blog/. MDX is useful when a post needs embedded components; plain Markdown keeps ordinary writing independent of component imports.

A small content schema can require title, description, and pubDate, default draft to false, and leave update dates, tags, and cover images optional. Shared layouts own article styling and metadata. Filename-derived content IDs can supply URLs, but a renamed published URL needs a redirect.

Publication filters matter at every output boundary. A draft excluded only from the index can still have a published page. Routes, indexes, RSS, sitemaps, and search must agree on which posts are public. Future-dated posts need the same treatment when scheduling is supported. Static output changes only after a build and deployment; a publication date alone cannot trigger a release.

Fumadocs with Astro brings documentation UI and MDX components into the same public-site build under /docs/. Prerendered articles and a static search index avoid a separate documentation server. The search index belongs on the public host, outside the app-only /api namespace.

A CMS helps authors who need browser editing, media management, or editorial releases independent of repository changes. It changes the authoring workflow without necessarily changing static rendering.

Runtime architecture

The proposed deployment uses one Cloudflare Worker per environment with two Custom Domains:

HostResponsibility
example.comAstro public site, including blog and documentation
app.example.comReact app at / and Hono API at /api and /api/*

Two hostnames, one Worker

Follow the arrows. On narrow screens, scroll horizontally to see the full diagram.

Two hostnames, one WorkerThe browser visits example.com for the public site or app.example.com for the SaaS application. Both Custom Domains enter the same Cloudflare Worker, which dispatches by hostname before looking up assets. The root host serves Astro HTML and files from the internal /site/ asset directory. The app host serves React and TanStack Router from the internal /app/ directory, with a shell fallback only for HTML navigation. Its /api endpoints reach Hono, oRPC, and Zod before asset lookup. The API uses Drizzle and pg through Hyperdrive to reach external Neon PostgreSQL. The app browser uses managed Neon Auth for sign-in and sessions.One Worker + its static assetssign-inCustom Domainsroot hostapp pagesapp /api/*SQLpooled SQLBrowserVisitors and SaaS usersManaged Neon AuthExternal authenticationexample.comLanding pages + blogapp.example.comSaaS screens + API callsHostname dispatcherWorker-first routingAstro public siteStatic HTML + filesASSETS: /site/*React SPAVite + TanStack RouterASSETS: /app/*Hono APIoRPC + ZodDrizzle ORM + pgHyperdriveConnection poolingNeon PostgreSQLExternal database
Solid arrows show request and data flow; the dashed arrow shows sign-in. Asset prefixes are internal, not public URLs. Missing public pages, API routes, and static files return 404. The API verifies sessions and authorization; the browser never connects directly to the database.
Read text description

The browser visits example.com for the public site or app.example.com for the SaaS application. Both Custom Domains enter the same Cloudflare Worker, which dispatches by hostname before looking up assets. The root host serves Astro HTML and files from the internal /site/ asset directory. The app host serves React and TanStack Router from the internal /app/ directory, with a shell fallback only for HTML navigation. Its /api endpoints reach Hono, oRPC, and Zod before asset lookup. The API uses Drizzle and pg through Hyperdrive to reach external Neon PostgreSQL. The app browser uses managed Neon Auth for sign-in and sessions.

A visitor opens a public page on the root host, then follows a link to the app subdomain. The app loads its shell and calls /api/* on its own origin. Hono verifies the session and authorization before accessing protected data. Database credentials stay on the server.

Sharing a Worker does not make the hostnames the same browser origin. Public-site browser calls to the app API require an explicit CORS policy. Host-scoped application cookies avoid sharing sessions with every subdomain; authentication callbacks must match the intended app origin.

The ASSETS binding matches pathnames, not hostnames. The Worker therefore selects the host before looking up a file in the internal /site/ or /app/ asset namespace. Only app-host HTML navigation can fall back to the SPA shell. Missing public pages, API routes, and static files remain 404 responses.

Worker-first dispatch also invokes code for asset requests. A single release unit means both apps share deployment timing and Worker configuration. Cloudflare does not require this topology.

Source apps and releases

The diagram uses example paths for a downstream application, not this repository's layout.

Source apps to one release

Follow the arrows. On narrow screens, scroll horizontally to see the full diagram.

Source apps to one releaseThree separate pnpm workspace apps feed one GitHub Actions pipeline: apps/site contains Astro pages and blog content; apps/app contains React, Vite, TanStack Router, Query, and the oRPC client; apps/api contains hostname dispatch, Hono, and Wrangler configuration. GitHub Actions checks, builds, assembles, and verifies one release containing dist/assets/site/, dist/assets/app/, and the Worker bundle with deployment configuration and bindings. Wrangler deploys that verified output together to one Cloudflare Worker serving example.com and app.example.com. Both frontends are built for their hostname's root path.pnpm workspace sourcesRelease artifactapps/siteAstro public siteapps/appReact + TanStack Routerapps/apiHono + dispatch + configGitHub ActionsCheck · build · assemble · verifySite assetsdist/assets/site/App assetsdist/assets/app/Worker bundleConfiguration + bindingsWranglerDeploy verified output togetherOne Cloudflare Workerexample.com + app.example.com
GitHub Actions releases and rolls back the site, app, and API as one unit. Shared UI packages are optional. Preview environments use their own hostname pair, bindings, and data. Drizzle Kit migrations are a separate release step.
Read text description

Three separate pnpm workspace apps feed one GitHub Actions pipeline: apps/site contains Astro pages and blog content; apps/app contains React, Vite, TanStack Router, Query, and the oRPC client; apps/api contains hostname dispatch, Hono, and Wrangler configuration. GitHub Actions checks, builds, assembles, and verifies one release containing dist/assets/site/, dist/assets/app/, and the Worker bundle with deployment configuration and bindings. Wrangler deploys that verified output together to one Cloudflare Worker serving example.com and app.example.com. Both frontends are built for their hostname's root path.

GitHub Actions builds the separate sources, assembles both asset namespaces, and verifies the Worker before release. The Worker and both frontends deploy together. Database migrations remain an explicit release step with their own compatibility and recovery requirements. A Worker rollback does not undo a database migration.

Mobile apps

A React/Vite web app, with PWA capabilities where needed, is the starting point. App-store distribution and native interaction can justify a separate React Native app with Expo. When React Native is the long-term target, using Capacitor as an intermediate platform adds another migration.

Expo Router owns native stacks, tabs, and modals. TanStack Router stays in the browser app. Expo DOM components can reuse selected web screens inside the native shell while high-value workflows move to native controls.

BoundaryWhat can be reusedWhat remains separate
Shared sourceBusiness logic, types, validation, API contracts, translation catalogsPlatform initialization and device integrations
DOM componentBrowser UI, CSS, and shadcn/ui controls, marked with 'use dom'Runs in a WebView, not as native controls; native views cannot nest inside it
Native-to-DOM connectionSerializable props and asynchronous native actionsReact context, global state, and query caches are not automatically shared across runtimes

Expo CLI and Metro bundle reused source; an unchanged Vite build is not the input. DOM components make incremental replacement possible, but do not themselves improve native performance. Frequent workflows, keyboard-heavy forms, lists, and gestures are stronger candidates for native UI than infrequently used content screens.

Mobile calls the existing backend through an absolute HTTPS URL rather than same-origin /api. Authentication, redirects, and session persistence need platform-specific integration. Login, session restoration, authenticated requests, and logout on a real target device are the early feasibility checks before a broad screen migration.

Native binaries have a separate release lifecycle. EAS Build and EAS Submit are the preferred build and upload tools; web and API releases remain on Cloudflare. Apple's minimum-functionality guideline still applies. A native navigation bar around a website does not guarantee store approval.

Desktop apps

Tauri is the recommendation for installable macOS, Windows, and Linux applications. Reuse the React/Vite frontend, including web controls, styles, and shared TypeScript logic. Tauri renders that UI in the operating system's WebView, with a Rust core for desktop integrations.

Bundle the client-built frontend assets with the app and keep the hosted Hono API and server secrets on Cloudflare. Tauri expects a static frontend; server-side rendering needs a separate server. Use an absolute HTTPS API URL and verify desktop authentication callbacks, session restoration, and logout rather than assuming the browser app's same-origin setup carries over.

Add Tauri plugins or focused Rust commands for operating-system features. Scope plugin permissions to the windows and resources that need them through capabilities.

Desktop binaries have their own release lifecycle. Follow Tauri's distribution guidance for installers and platform signing, and verify the packaged app on each supported operating system. Web and API releases stay on Cloudflare.

Internationalization

For multilingual React web and native UI, i18next with react-i18next allows translation catalogs, supported locales, and fallback rules to be shared. Initialization, language detection, and persistence stay in each app. Private app routes do not need locale prefixes simply to translate interface text. Bundled startup translations keep mobile UI available offline; a hosted translation service is optional.

Public content has a different concern: stable localized URLs. Astro's i18n routing owns those paths, while translated articles and documentation belong in the content layer. i18next core can supply interface strings through an explicit page locale. Changing a shared global language during rendering risks mixing concurrent pages' locales.

AI provider library

TanStack AI is the recommended TypeScript library for streaming and typed tool calling through direct provider adapters, such as @tanstack/ai-openai and @tanstack/ai-anthropic. No AI gateway is required for this design.

Clients call an authenticated Hono endpoint, which invokes the selected adapter. Provider code and API keys stay on the backend in Worker secrets, never in VITE_* or EXPO_PUBLIC_* variables. React clients use @tanstack/ai-react; the React Native guide covers an absolute backend URL and XHR streaming transport.

Provider and model capabilities vary. Adoption depends on verifying the chosen adapter in Wrangler and the mobile transport on target devices, not just on the library exposing a common API.

Product services

Transactional email

Resend is the transactional email recommendation for invitations, notifications, and other application messages. Send from the Hono backend with the API key in Worker secrets. Verify a sending domain before production; a dedicated subdomain keeps application mail separate from marketing mail.

Web payments and subscriptions

Use hosted Stripe Checkout for one-time web payments and subscriptions, with the customer portal for billing details, payment methods, invoices, and subscription management. These managed interfaces reduce custom billing UI.

Create Checkout and portal sessions on the backend and keep Stripe secret keys in Worker secrets. Update local billing state through verified webhooks: check signatures against the raw request body, make handlers idempotent, and handle out-of-order events. Grant paid access from verified billing state.

Product analytics

PostHog is the product analytics recommendation for events, funnels, and retention. Start with events tied to product questions, such as onboarding completion or a successful purchase. Add feature flags, experiments, and session replay as needed. Choose capture rules before sending production events, and configure replay privacy controls to mask sensitive content, including text outside form inputs.

Product profitability

OpenProfit tracks revenue, costs, and profit by product. Connect Stripe and supported AI and infrastructure providers through its connectors. It complements PostHog by showing which products earn enough to cover their costs. Some provider costs are calculated from usage and published rates; add unsupported bills manually and reconcile estimates with actual invoices.

SEO

Public content benefits from meaningful HTML before JavaScript runs. Prerendering or server rendering also serves crawlers that do not execute JavaScript. Static Astro output meets that need without request-time SSR. Private application screens have no equivalent search requirement.

ConcernPublic-site expectation
Page identityDescriptive title, meta description, canonical production URL, semantic headings, and crawlable links
Link previewsOpen Graph metadata in the page HTML
Structured dataRelevant types, such as Article, matching visible content; rich results are not guaranteed
DiscoverySitemap entries for indexable public pages only, using the root domain without internal asset prefixes
URL changes and missesHTTP redirects for moved pages; HTTP 404 for missing pages rather than a successful app shell

Each hostname has its own robots.txt; the root domain's file does not control the app subdomain. The app shell and previews are non-indexable by default, using noindex in initial HTML or an X-Robots-Tag header. A deliberately public app page needs a separate indexing decision. Crawlers must be able to fetch a URL to see its noindex directive, so blocking that URL in robots.txt prevents the directive from being read. Neither mechanism protects private data; authentication does. Production public pages must not inherit preview indexing restrictions.

Limited client JavaScript, sized images, and stable layouts support loading and interaction quality. Core Web Vitals measure those outcomes; a rendering choice alone does not establish performance or ranking. The deployment checks cover raw HTML, metadata, search, and status codes. Search Console and PageSpeed Insights supply production evidence.

Scaling the stack

A distributed stateless API does not give PostgreSQL unlimited throughput or make writes local to every user. Useful evidence includes slow queries, CPU and I/O, lock waits, connection-pool waits, and API tail latency. Registered-user counts alone do not identify the bottleneck.

Indexes, bounded results, fewer SQL round trips, and short transactions are the first improvements. External calls inside a transaction occupy connections while doing no database work. Increasing a pool can worsen overload. Hyperdrive pooling reuses origin connections, but its budget must leave room for other clients and configurations. Neon autoscaling adds compute within configured bounds; it cannot remove contention on a frequently updated row.

Different workloads need different additions

These services are options for a measured bottleneck, not baseline dependencies.

WorkloadOptionConsequence
Repeated public HTTP responsesCloudflare cacheAvoids SQL on a hit. Cache API entries and deletion are data-center-local; shared responses must not leak personalized data.
Infrequently changed configuration or derived valuesWorkers KVEventually consistent; changes can take 60 seconds or more to appear elsewhere. Unsuitable for immediate permission revocation or strict counters.
Repeated SQL reads that tolerate stale dataHyperdrive query cachingCaches eligible reads. Writes do not invalidate results.
Strict quotas, rooms, or per-resource coordinationDurable ObjectsStrong coordination within each object; one global object can become a bottleneck.
Best-effort abuse limitsWorkers Rate Limiting bindingApproximate, location-local limits rather than a strict worldwide quota.
Write bursts, notifications, or importsCloudflare QueuesAt-least-once delivery needs idempotent effects. Bounded consumer concurrency protects the database; a queue cannot fix sustained overload.
Reads or reporting exhausting primary compute after tuningNeon read replicasAdds read-only compute with explicit routing and eventual consistency, not more write capacity.
Expensive recurring reportsPrecomputed summaries or separate analyticsReduces transactional work at the cost of freshness and pipeline complexity.
Hot-row writes or a dominant tenantData-model changes, tenant isolation, then sharding if justifiedAddresses write contention; sharding adds routing, migration, and cross-shard query costs.

Freshness determines the read path

Hyperdrive query caching is enabled by default. A cache-disabled binding retains pooling while providing the fresh-read path for authorization, billing, and read-after-write behavior. Separate cached and uncached database clients make that boundary explicit. Replica reads also cannot serve flows that require the latest committed primary state.

For example, a public catalog may tolerate cached results. A permission check after access has been revoked cannot use the same stale read path. Tenant-scoped cache keys, authorization checks, expiry, invalidation, and bounded cache-miss concurrency protect private data and recovery under load.

KV is not an atomic Redis substitute. Durable Objects can own coordinated state, but their consistency does not extend into a PostgreSQL transaction. Making both systems authoritative for the same value creates a synchronization problem. Redis remains useful for its specific structures, atomic operations, or existing integrations, at the cost of another network dependency.

Geography still matters

Edge execution does not eliminate distance to the database writer. Fewer sequential SQL calls and cached reads help global users; writes still reach the primary. Neon read replicas are in the primary's region. Cross-region replicas require a separate project and logical replication. Regional tenant placement or a different write architecture is a larger decision driven by measured latency and consistency requirements.

On this page