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.

This guide walks you through cloning the repository, pointing it at a Neon Postgres database, running migrations, seeding initial data, and launching the development server. By the end you will have a fully functional local instance of Inventory System with seeded user records ready to authenticate through Neon Auth.

Prerequisites

Before you begin, make sure you have the following ready:
  • Node.js 20 or later — the project targets the Node.js 20 runtime. Run node -v to confirm.
  • A Neon Postgres project — create one for free at neon.tech. You will need both the pooled (DATABASE_URL) and direct (DATABASE_URL_UNPOOLED) connection strings from the Neon Console.
  • Neon Auth configured — enable Neon Auth in your Neon project and note the NEON_AUTH_BASE_URL, NEON_AUTH_COOKIE_SECRET, and NEON_WEBHOOK_SECRET values from the Auth settings panel.
Upstash Redis is optional for local development. When UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN are not set, the middleware automatically falls back to an in-memory rate limiter that works fine for a single local process. See the Environment Variables reference for full details.

Steps

1

Clone the repository and install dependencies

Clone the project and install all Node.js dependencies. The postinstall hook runs prisma generate automatically, so the Prisma Client is ready as soon as npm install completes.
git clone https://github.com/juadariasmar/inventory_project.git
cd inventory_project
npm install
2

Configure environment variables

Copy the example environment file to .env and fill in your values. At minimum you must supply the six variables listed below — everything else is optional for local development.
cp .env.example .env
Open .env in your editor and set:
# Neon Postgres — both strings are required
DATABASE_URL="postgresql://user:pass@pooler-host/dbname?sslmode=require"
DATABASE_URL_UNPOOLED="postgresql://user:pass@direct-host/dbname?sslmode=require"

# NextAuth / Neon Auth
NEXTAUTH_SECRET="replace-with-a-random-32-character-string"
NEON_AUTH_BASE_URL="https://your-project.neonauth.tech/dbname/auth"
NEON_AUTH_COOKIE_SECRET="replace-with-another-random-secret"
NEON_WEBHOOK_SECRET="replace-with-your-neon-webhook-secret"
For the full list of available variables — including email, rate limiting, and admin promotion — see the Environment Variables reference.
3

Generate the Prisma Client

Generate the typed Prisma Client from prisma/schema.prisma. This step is already run by postinstall, but re-run it any time you modify the schema.
npm run prisma:generate
4

Run database migrations

Apply all pending Prisma migrations against your Neon database. This command uses the DATABASE_URL_UNPOOLED direct connection under the hood, which is required for DDL operations.
npm run prisma:migrate
If you are starting a brand-new database and prefer to skip the migration history, you can use npm run prisma:dbpush instead to push the schema directly. Reserve prisma:migrate for production and team environments where migration history matters.
5

Seed the database

Populate the database with initial data: a SUPER_ADMIN user (email taken from SUPER_ADMIN_EMAIL, defaulting to [email protected]), an ADMIN user ([email protected]), a USUARIO user ([email protected]), and a set of default categories — each scoped to their own demo Empresa.
npm run seed
The seed script prints each created user’s email and role to the console. Because authentication is handled by Neon Auth, these database records must be paired with a real Neon Auth account — sign in through the Neon Auth UI using the email addresses printed by the seed script.
6

Start the development server

Launch the Next.js development server. The application will be available at http://localhost:3000.
npm run dev

Available Scripts

The following scripts are defined in package.json and cover the full development, testing, and deployment lifecycle.
ScriptCommandDescription
Development servernpm run devStarts Next.js in development mode with fast refresh.
Production buildnpm run buildRuns prisma generate then builds the Next.js production bundle.
Production servernpm run startStarts the compiled production server.
Lintnpm run lintRuns ESLint across all source files.
Unit testsnpm run testRuns all Jest tests with --runInBand (required because tests share the database).
Test coveragenpm run test:coverageRuns Jest and generates an Istanbul coverage report.
End-to-end testsnpm run test:e2eRuns Playwright tests against the running application.
Seed databasenpm run seedExecutes prisma/seed.ts to load initial users and categories.
Generate Prisma Clientnpm run prisma:generateRegenerates the Prisma Client from the current schema.
Push schemanpm run prisma:dbpushPushes schema changes directly to the database without creating a migration file. Useful for rapid prototyping.
Deploy migrationsnpm run prisma:migrateApplies all pending migrations using prisma migrate deploy. Use this in CI and production.
Always run npm run test with the --runInBand flag (already included in the script). The Jest test suite shares a single Neon database connection and will deadlock or produce flaky results when tests run in parallel workers.

Build docs developers (and LLMs) love