Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/juadariasmar/inventory_project/llms.txt

Use this file to discover all available pages before exploring further.

Vercel is the primary deployment target for Inventory System. The application is built on Next.js 16 and relies on serverless functions for all API routes, which pair naturally with Neon Serverless Postgres — a connection-pooling-aware Postgres service that communicates over WebSockets via the @neondatabase/serverless driver instead of traditional TCP. This means cold-start latency is minimal and you never exhaust database connections under concurrent load.

Prerequisites

Before you begin, make sure you have the following in place:

Vercel Account

A Vercel account with permission to create new projects. The free Hobby tier is sufficient for testing.

Neon Project with Auth

A Neon project with the Neon Auth feature enabled. You will need both a pooled and a direct (unpooled) connection string, plus the Auth base URL and secrets.

Upstash Redis (optional)

An Upstash Redis instance for rate limiting. If omitted, rate limiting is disabled — acceptable for low-traffic deployments.

Deployment steps

1

Import the repository on Vercel

Log in to the Vercel dashboard and click Add New → Project. Select the Git provider where the repository lives, then choose inventory_project from the list and click Import.Vercel will auto-detect the Next.js framework and set sensible defaults. No changes to the framework preset are needed.
2

Confirm the build command

In the Build & Output Settings section, verify that the build command is set to:
npm run build
This script (defined in package.json) runs prisma generate && next build — it generates the Prisma Client from the schema before compiling the application, ensuring the correct engine binary is bundled with the output.
3

Set environment variables

Navigate to Settings → Environment Variables and add each of the following variables. Apply them to the Production, Preview, and Development environments as appropriate.
VariableDescription
DATABASE_URLPooled Neon connection string (used by the app at runtime). Format: postgresql://user:pass@host-pooler/dbname?sslmode=require
DATABASE_URL_UNPOOLEDDirect (unpooled) Neon connection string (used by Prisma CLI and migrations). Format: postgresql://user:pass@host/dbname?sslmode=require
NEXTAUTH_SECRETA long random string used to sign session tokens. Generate with openssl rand -base64 32.
NEXTAUTH_URLThe canonical URL of the production deployment, e.g. https://inventory.example.com. Must match the domain you configure in Neon Auth.
NEXT_PUBLIC_BASE_URLSame value as NEXTAUTH_URL. Exposed to the browser for building absolute links.
NEON_AUTH_BASE_URLThe Neon Auth base URL from the Neon Console, e.g. https://your-project.neonauth.tech/dbname/auth.
NEON_AUTH_COOKIE_SECRETSecret used to encrypt Neon Auth session cookies. Must be at least 32 characters.
NEON_WEBHOOK_SECRETSigning secret for the Neon Auth webhook. Copy this from the Neon Console after creating the webhook endpoint.
SUPER_ADMIN_EMAILEmail address that receives the SUPER_ADMIN role on first login.
ADMIN_EMAILSComma-separated list of emails that receive the ADMIN role automatically, e.g. [email protected],[email protected].
RESEND_API_KEYAPI key from Resend for transactional emails (invitations, notifications).
EMAIL_FROMSender address used in outgoing emails, e.g. [email protected]. Must be verified in Resend.
UPSTASH_REDIS_REST_URLREST URL for your Upstash Redis database, e.g. https://your-db.upstash.io. Leave blank to disable rate limiting.
UPSTASH_REDIS_REST_TOKENAuthentication token for the Upstash Redis REST API.
For preview deployments, set NEXTAUTH_URL and NEXT_PUBLIC_BASE_URL to the Vercel preview URL pattern (https://$\{VERCEL_URL\}) or manage them automatically using the npm run sync:secrets script described below.
4

Configure Neon Auth allowed origins

In the Neon Console, open your project and navigate to Auth → Settings. Under Allowed Origins, add your production domain:
https://your-domain.vercel.app
If you use a custom domain, add that too. Without this step the Neon Auth token exchange will be blocked by CORS and users will be unable to log in.
5

Set up the Neon Auth webhook

Neon Auth fires a webhook whenever a user is created or updated so the application can sync the user record into its own Usuario table. In the Neon Console, go to Auth → Webhooks and add a new endpoint:
https://your-domain.vercel.app/api/webhooks/neon
Copy the signing secret that Neon generates and paste it into the NEON_WEBHOOK_SECRET environment variable you set in the previous step.
6

Deploy

Click Deploy. Vercel will run npm run build (which includes prisma generate), package the output, and route traffic to the serverless functions. The first deploy typically takes two to three minutes.Once complete, open the deployment URL and verify that the login page loads and that you can authenticate with the credentials seeded by npm run seed.

Critical next.config.ts settings for Prisma

The following two settings in next.config.ts are required for Prisma to work correctly on Vercel. Omitting either one causes a runtime error where the Prisma engine binary cannot be located after deployment.
const nextConfig: NextConfig = {
  // Tells Next.js file-tracing where the project root is so the Prisma
  // query engine binary is included in the output bundle.
  outputFileTracingRoot: process.cwd(),

  // Prevents Next.js from bundling these packages — they must be loaded
  // as native Node.js modules by the serverless runtime.
  serverExternalPackages: [
    "@prisma/client",
    "@prisma/adapter-neon",
    "@neondatabase/serverless",
    "ws",
  ],
};
outputFileTracingRoot is set to process.cwd() (equivalent to __dirname at the config level) so that Next.js file tracing resolves the Prisma engine binary relative to the project root. serverExternalPackages prevents the bundler from inlining these packages — they rely on native bindings and WebSocket connections that cannot be serialised into a webpack bundle.

Preview deployments

Every pull request automatically gets a preview deployment on Vercel. Two helper scripts in package.json make preview environment management easier:
  • npm run clean:previews — runs scripts/cleanup-vercel.ts to delete stale preview deployments and free up Vercel project limits.
  • npm run sync:secrets — runs scripts/sync-github-secrets.ts to push updated secrets to GitHub Actions, keeping CI and Vercel preview environments in sync.
Preview deployments share the same Neon database by default. If you want to isolate preview data, create a separate Neon branch per PR and override DATABASE_URL in Vercel’s preview environment scope.

Post-deploy checklist

After your first successful deployment, confirm the following:

Webhook is firing

Register a new test user and check the Neon Console webhook delivery logs. A successful 200 response confirms that Usuario records are being created in the database.

Allowed origins include deploy URL

Log in on the production domain. If the Neon Auth modal fails to redirect, re-check that the exact production URL (including https://) is listed under Auth → Settings → Allowed Origins in the Neon Console.

NEXTAUTH_URL matches domain

Confirm NEXTAUTH_URL is set to the exact canonical URL (no trailing slash). A mismatch causes callback redirect failures after OAuth sign-in.

Emails are delivering

Trigger an invitation email from the admin panel and verify it arrives. Check Resend’s delivery dashboard if it does not.

Build docs developers (and LLMs) love