Architecture
Tech Stack

Technology Stack

All choices confirmed. This is not a wishlist — it's what we're building with.


Core Stack

LayerChoiceWhy
RuntimeNode.js + TypeScriptConsistent language front-to-back. Strong ecosystem. Existing expertise from savvy-engine.
FrameworkNext.js (App Router)Handles authenticated dashboard, public questionnaire, SEO landing pages, and API — all in one app.
AIAnthropic Claude (direct SDK)No abstraction layers. Synthesis quality requires precise prompt engineering with direct API control.
DatabasePostgreSQL + Drizzle ORMType-safe, lightweight ORM. Data model is relational (collections → invitations → responses).
AuthClerkGoogle OAuth, Microsoft OAuth, magic links, session management, org support — out of the box. Saves 2–3 weeks of build time.
PaymentsStripeCheckout for one-offs, Billing for subscriptions, Customer Portal for self-service.
EmailResend + React EmailTransactional email with JSX templates. Same ecosystem as the rest of the codebase.
File StorageGoogle Cloud StoragePDF reports, company logos, static assets. CDN-served.
PDFReact-PDF or GotenbergReport generation in JSX (React-PDF) or HTML-to-PDF (Gotenberg).
StylingTailwind CSS + shadcn/uiProfessional UI without custom design. Consistent design system.

Infrastructure

ConcernChoiceNotes
HostingVercel (recommended)Zero ops, preview deployments, edge functions. Natural fit for Next.js. Alternative: existing K8s cluster.
Database hostingNeonServerless-friendly connection pooling. Works well with Vercel's edge runtime.
Background jobsInngestDurable functions for the synthesis pipeline. Also handles scheduled reminders and cleanup.
MonitoringSentry + Vercel AnalyticsError tracking + performance. PostHog for product analytics.
Domainenvara.aiAll services under this domain.

Application Structure

envara.ai/                          ← Marketing (SSR, SEO)
envara.ai/dashboard/                ← Creator dashboard (authenticated)
envara.ai/collections/new           ← Setup wizard
envara.ai/r/[token]                 ← Respondent questionnaire (public, no auth)
envara.ai/reports/[id]              ← Report viewer (optional auth gate)

API Routes

/api/collections/                   ← CRUD, wizard state
/api/collections/[id]/invitations/  ← Send, track, remind
/api/collections/[id]/responses/    ← Submit, retrieve
/api/collections/[id]/synthesis/    ← Trigger, retrieve, regenerate
/api/ai/questions/                  ← Question generation
/api/ai/guardrails/                 ← Purpose/question review
/api/billing/                       ← Stripe webhooks, usage
/api/users/                         ← Profile, prefs (Clerk sync)

Relationship to Savvy-Engine

Envara is an independent codebase. It does not extend or depend on savvy-engine.

ReuseDon't Reuse
Prompt sectioning patternData model (single-respondent)
Report config structureAPI routes
Questionnaire rendering patternsSubmission pipeline
PDF template approachEnrichment logic