A modern, full-stack inventory management application built with Next.js 16, featuring real-time stock tracking, analytics dashboard, and user authentication.
- π Analytics Dashboard - Visual insights with charts and key metrics
- π¦ Inventory Management - Add, view, search, and delete products
- π Product Search - Quick search functionality across your inventory
- π Stock Level Tracking - Monitor low stock alerts and inventory levels
- π¨ Modern UI - Beautiful, responsive interface with dark mode support
- π Secure Authentication - User authentication powered by Stack Auth
- π± Responsive Design - Works seamlessly on desktop and mobile devices
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Database: PostgreSQL with Prisma ORM
- Authentication: Stack Auth
- Styling: Tailwind CSS
- UI Components: Radix UI
- Charts: Recharts
- Icons: Lucide React
Before you begin, ensure you have the following installed:
- Node.js 18+
- npm, yarn, pnpm, or bun
- PostgreSQL database (local or cloud)
- Stack Auth account (app.stack-auth.com)
git clone <repository-url>
cd inventory-management-nextjsnpm install
# or
yarn install
# or
pnpm installCreate a .env.local file in the root directory and add the following variables:
# Stack Auth Configuration
NEXT_PUBLIC_STACK_PROJECT_ID='your-project-id'
NEXT_PUBLIC_STACK_PUBLISHABLE_CLIENT_KEY='your-publishable-key'
STACK_SECRET_SERVER_KEY='your-secret-server-key'
# Database Connection
DATABASE_URL='your-postgresql-connection-string'Getting Stack Auth Keys:
- Visit app.stack-auth.com
- Create a new project or select an existing one
- Navigate to your project settings
- Copy the Project ID, Publishable Client Key, and Secret Server Key
- Paste them into your
.env.localfile
Database Setup:
- For local development, you can use a local PostgreSQL instance
- For production, consider using services like Neon, Supabase, or Railway
- Your connection string should follow this format:
postgresql://user:password@host:port/database
Run Prisma migrations to create the database schema:
npx prisma migrate devThis will:
- Create the database tables
- Generate the Prisma Client
- Apply all migrations
If you want to populate the database with sample data:
npx prisma db seednpm run dev
# or
yarn dev
# or
pnpm devOpen http://localhost:3000 in your browser to see the application.
inventory-management-nextjs/
βββ app/ # Next.js app directory
β βββ (root)/ # Protected routes group
β β βββ dashboard/ # Dashboard page
β β βββ inventory/ # Inventory management page
β β βββ add-products/ # Add product page
β β βββ settings/ # Settings page
β β βββ layout.tsx # Root layout with sidebar
β βββ sign-in/ # Authentication page
β βββ handler/ # Stack Auth handler
β βββ layout.tsx # Root layout
βββ components/ # React components
β βββ dashboard/ # Dashboard-specific components
β βββ inventory/ # Inventory-specific components
β βββ ui/ # Reusable UI components
βββ lib/ # Utility functions and configurations
β βββ actions/ # Server actions
β βββ auth.ts # Authentication utilities
β βββ prisma.ts # Prisma client instance
βββ prisma/ # Database schema and migrations
β βββ schema.prisma # Prisma schema
β βββ migrations/ # Database migrations
βββ stack/ # Stack Auth configuration
β βββ client.tsx # Client-side Stack Auth setup
β βββ server.tsx # Server-side Stack Auth setup
βββ middleware.ts # Next.js middleware for route protection
npm run dev- Start the development servernpm run build- Build the application for productionnpm run start- Start the production servernpm run lint- Run ESLint to check code quality
To visually inspect and edit your database:
npx prisma studioThis opens Prisma Studio at http://localhost:5555
When you modify the Prisma schema:
npx prisma migrate dev --name your-migration-namenpx prisma migrate reset- Key Metrics: Total products, total inventory value, and low stock alerts
- Weekly Product Chart: Visual representation of products added over time
- Stock Levels: Overview of recent products and their stock status
- Efficiency Metrics: Breakdown of in-stock, low-stock, and out-of-stock items
- Product List: View all products in a paginated table
- Search: Search products by name
- Delete: Remove products from inventory
- Pagination: Navigate through large product lists
- Product Details: Add name, SKU, price, quantity, and low stock threshold
- Validation: Form validation ensures data integrity
- Automatic Redirect: Redirects to inventory page after successful addition
- Account Management: Manage your account settings through Stack Auth
The application uses Stack Auth for authentication:
- Unauthenticated users are redirected to
/sign-in - Authenticated users accessing
/are redirected to/dashboard - Protected routes require authentication (middleware handles this automatically)
- User data is isolated per authenticated user
npm run buildMake sure to set all environment variables in your hosting platform:
- Vercel: Add variables in Project Settings β Environment Variables
- Railway: Add variables in Project Settings β Variables
- Other platforms: Follow their respective documentation
Ensure your production database is accessible and the DATABASE_URL environment variable is correctly set.
- Verify your
DATABASE_URLis correct - Ensure your database server is running
- Check if your database allows connections from your IP address
- Verify all Stack Auth environment variables are set correctly
- Check that your Stack Auth project is properly configured
- Ensure the redirect URLs in Stack Auth match your application URL
- Run
npx prisma generateto regenerate Prisma Client - Clear
.nextfolder and rebuild:rm -rf .next && npm run build - Ensure all environment variables are set
For issues related to:
- Next.js: Check Next.js Documentation
- Prisma: Check Prisma Documentation
- Stack Auth: Check Stack Auth Documentation