Inventory Desk is a complete Next.js product-management application with a responsive frontend dashboard, REST API endpoints, MongoDB Atlas persistence, validation, and Vercel-ready deployment configuration.
- Create, list, update, and delete products from the frontend UI.
- REST API route handlers for product CRUD operations.
- MongoDB Atlas integration with a serverless-safe cached client.
- Automatic
totalPricecalculation fromunitPrice * quantity. - Field-level validation with consistent API error responses.
- Responsive dashboard for desktop and mobile product management.
- API documentation with request and response examples.
- Next.js 16 App Router
- React 19
- TypeScript
- Tailwind CSS 4
- MongoDB Node.js Driver
- Zod
- Lucide React
- Node.js 20.9 or newer.
- npm.
- MongoDB Atlas cluster connection string.
Install dependencies:
npm installCreate a local environment file:
cp .env.example .env.localSet the MongoDB Atlas values in .env.local:
MONGODB_URI=mongodb+srv://<username>:<password>@<cluster-host>/?retryWrites=true&w=majority
MONGODB_DB=product_managementRun the development server:
npm run devOpen http://localhost:3000.
npm run dev
npm run lint
npm run build
npm run startapp/page.tsxrenders the product-management dashboard.app/components/contains the client-side product form, list, and dashboard shell.app/api/products/route.tshandles product list and creation.app/api/products/[id]/route.tshandles product update and deletion.lib/mongodb.tsmanages the cached MongoDB connection.lib/products.tscontains the product data access layer.lib/product-validation.tscontains shared validation and total-price calculation.types/product.tscontains shared product and API response types.docs/api.mddocuments API requests, responses, validation, and errors.
See docs/api.md for all endpoints and examples.
- Create a MongoDB Atlas project and cluster.
- Create a database user with read/write permissions.
- Add your local IP address for development, and configure production access according to your security policy.
- Copy the connection string into
MONGODB_URI. - The app creates a unique index on
productCodeautomatically.
- Push the repository to GitHub, GitLab, or Bitbucket.
- Import the project in Vercel.
- Add these environment variables in the Vercel project settings:
MONGODB_URIMONGODB_DB
- Deploy with the default Next.js framework settings.
The API route handlers use the Node.js runtime because the MongoDB driver is not compatible with the Edge runtime.
- No authentication or authorization is included yet, by request.
- Product codes are unique and normalized to uppercase.
totalPriceis computed on the server and should not be trusted from client input.- API errors are sanitized before being returned to clients.