A production-grade internal inventory management system for automobile spare-parts business built with Next.js, MongoDB, and Cloudinary.
- Secure Authentication: Username/password login with session management
- Dashboard: Overview of total parts, inventory value, and recent activities
- Parts Management: Full CRUD operations for inventory items
- Global Search: Search across part name, number, brand, supplier, location, and description
- Image & Bill Upload: Cloudinary integration for storing part images and bills
- Activity Tracking: Automatic logging of all inventory changes
- Responsive UI: Business-friendly interface optimized for daily operations
- Framework: Next.js 16 (App Router)
- Database: MongoDB
- Image Storage: Cloudinary
- Authentication: Session-based with bcrypt password hashing
- Styling: Tailwind CSS
- Language: TypeScript
- Node.js 18+ and pnpm (or npm/yarn)
- MongoDB instance (local or cloud)
- Cloudinary account
pnpm installCreate a .env file in the root directory:
# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB_NAME=stockrakh
# Authentication Credentials
ADMIN_USERNAME=admin
ADMIN_PASSWORD=your-plain-password
# Cloudinary Configuration
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
# Next.js
NODE_ENV=developmentSimply set ADMIN_PASSWORD to your desired password in plain text. For example:
ADMIN_PASSWORD=mySecurePassword123Note: The password is stored in plain text in the .env.local file. Keep this file secure and never commit it to version control.
After starting the server, visit /api/init-db to create the necessary database indexes, or they will be created automatically on first use.
pnpm devOpen http://localhost:3000 in your browser.
stockrakh/
├── app/
│ ├── api/
│ │ ├── auth/ # Authentication endpoints
│ │ ├── dashboard/ # Dashboard stats
│ │ ├── parts/ # Parts CRUD and search
│ │ └── upload/ # Image upload
│ ├── dashboard/ # Dashboard page
│ ├── login/ # Login page
│ └── parts/ # Parts management page
├── components/
│ └── parts/ # Part modal component
├── lib/
│ ├── db/ # MongoDB connection
│ ├── models/ # Data models
│ ├── services/ # Cloudinary service
│ ├── middleware/ # Auth middleware
│ └── validators/ # Zod schemas
└── scripts/ # Utility scripts
POST /api/auth/login- LoginPOST /api/auth/logout- LogoutGET /api/auth/me- Check authentication status
GET /api/parts- Get all partsPOST /api/parts- Create new partGET /api/parts/[id]- Get part by IDPUT /api/parts/[id]- Update partDELETE /api/parts/[id]- Delete partGET /api/parts/search?q=query- Search parts
GET /api/dashboard/stats- Get dashboard statistics
POST /api/upload/image- Upload image to Cloudinary
{
partName: string; // Required
partNumber: string; // Required
quantity: number; // Required
location: string; // Required
unitOfMeasure: string; // Required
partImages?: string[]; // Optional - Cloudinary URLs
brand?: string; // Optional
description?: string; // Optional
buyingPrice?: number; // Optional
mrp?: number; // Optional
supplier?: string; // Optional
billingDate?: Date; // Optional
billImages?: string[]; // Optional - Cloudinary URLs
createdAt: Date;
updatedAt: Date;
}- Password hashing with bcrypt
- Session-based authentication
- Protected API routes
- Server-side input validation
- Secure cookie handling
The system is designed to easily extend with:
- Multi-user support with roles
- Low-stock alerts
- CSV import/export
- Advanced reporting
- Email notifications
Private - Internal use only