A modern, AI-powered inventory management dashboard for retail businesses built with Next.js 16, TypeScript, Prisma ORM, and OpenAI integration. This project demonstrates enterprise-grade software development practices including Clean Architecture, Test-Driven Development, comprehensive documentation, and professional code annotation.
- π¦ Product Management - Complete CRUD operations for products with SKU tracking
- π Real-time Analytics - Interactive charts and KPI dashboards
- π·οΈ Category Management - Hierarchical product categorization
- π Stock Level Monitoring - Real-time inventory tracking with alerts
- π Stock Movement Tracking - Complete audit trail of all inventory changes
- π₯ Supplier Management - Comprehensive supplier database with performance metrics
- π€ Smart Reordering - AI-driven reorder recommendations based on sales velocity
- π Predictive Analytics - Machine learning predictions for demand forecasting
- π― Seasonal Adjustments - Automatic seasonal demand pattern recognition
- π‘ Optimization Insights - AI-generated suggestions for inventory optimization
- π¨ Intelligent Alerts - Smart low-stock and overstock notifications
- β‘ Next.js 16 - Latest React framework with App Router and Server Components
- π¨ TailwindCSS - Utility-first CSS framework for rapid UI development
- π Prisma ORM - Type-safe database access with PostgreSQL
- π Recharts - Interactive and responsive data visualization
- π§ͺ Jest + React Testing Library - Comprehensive testing framework
- π TypeScript - Full type safety across the entire application
This application follows Clean Architecture principles with clear separation of concerns:
src/
βββ app/ # Next.js App Router pages
β βββ layout.tsx # Root layout with providers
β βββ page.tsx # Dashboard homepage
βββ components/ # Reusable UI components
β βββ providers.tsx # React Query and other providers
β βββ dashboard/ # Dashboard-specific components
β βββ DashboardHeader.tsx # Navigation and user menu
β βββ DashboardStats.tsx # KPI cards with live data
β βββ DashboardCharts.tsx # Interactive analytics charts
β βββ QuickActions.tsx # Common action buttons
β βββ StockAlerts.tsx # Low stock notifications
β βββ AIRecommendations.tsx # AI-powered suggestions
β βββ RecentActivity.tsx # Activity feed
β βββ DashboardSkeleton.tsx # Loading states
βββ lib/ # Utility functions and configurations
βββ types/ # TypeScript type definitions
βββ utils/ # Helper functions
prisma/
βββ schema.prisma # Database schema with full inventory model
βββ seed.ts # Sample data for development
__tests__/ # Test suites
βββ components/ # Component tests
βββ pages/ # Page tests
βββ utils/ # Utility function tests
The application uses a comprehensive PostgreSQL schema designed for enterprise inventory management:
- Users - Role-based access control (Admin, Manager, Staff)
- Products - Complete product information with SKU, pricing, and stock levels
- Categories - Hierarchical product categorization
- Suppliers - Supplier management with performance tracking
- Stock Movements - Complete audit trail of inventory changes
- Purchase Orders - Purchase order management with line items
- AI Recommendations - Machine learning predictions and suggestions
- Node.js 18.0.0 or higher
- npm 9.0.0 or higher
- PostgreSQL 12 or higher
- OpenAI API Key (for AI features)
-
Clone the repository
git clone https://github.com/your-username/inv-dash.git cd inv-dash -
Install dependencies
npm install
-
Environment setup
# Copy environment template cp .env.example .env # Edit .env with your configuration: # - DATABASE_URL: PostgreSQL connection string # - OPENAI_API_KEY: Your OpenAI API key # - Other required environment variables
-
Database setup
# Generate Prisma client npm run db:generate # Create and migrate database npm run db:migrate # Seed with sample data npm run db:seed
-
Start development server
npm run dev
Open http://localhost:3000 to view the application.
Create a .env file with the following variables:
# Database Configuration
DATABASE_URL="postgresql://username:password@localhost:5432/inv_dash"
# OpenAI API Configuration
OPENAI_API_KEY="your_openai_api_key_here"
# Next.js Configuration
NEXTAUTH_SECRET="your-nextauth-secret"
NEXTAUTH_URL="http://localhost:3000"
# Application Settings
NODE_ENV="development"This project implements Test-Driven Development (TDD) with comprehensive test coverage:
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Generate coverage report
npm run test:coverage- Unit Tests - Individual component and function testing
- Integration Tests - API endpoint and database integration
- Component Tests - React component rendering and interaction
- E2E Tests - Complete user workflow testing
- Red-Green-Refactor - TDD methodology implementation
- Test Coverage - Minimum 90% code coverage requirement
- Behavior Testing - Focus on user behavior over implementation details
- Mock Strategy - Strategic mocking of external dependencies
- Total Products - Complete product count with growth metrics
- Inventory Value - Real-time inventory valuation
- Low Stock Alerts - Critical stock level monitoring
- Monthly Revenue - Sales performance tracking
- Inventory Trends - Historical inventory level analysis
- Sales Performance - Revenue and sales velocity charts
- Category Distribution - Product category breakdown
- Reorder Patterns - AI-identified reorder recommendations
- Reorder Recommendations - ML-based stock replenishment suggestions
- Seasonal Adjustments - Historical pattern-based demand forecasting
- Overstock Alerts - Excess inventory identification
- Trend Analysis - Market trend impact on inventory needs
The application integrates OpenAI's API for intelligent inventory management:
-
Demand Forecasting
- Historical sales data analysis
- Seasonal pattern recognition
- Market trend integration
-
Reorder Optimization
- Lead time consideration
- Safety stock calculation
- Economic order quantity optimization
-
Anomaly Detection
- Unusual sales pattern identification
- Inventory discrepancy alerts
- Supplier performance analysis
interface AIRecommendation {
type: 'reorder' | 'overstock' | 'seasonal' | 'trend'
product: string
currentStock: number
suggestedAction: string
reasoning: string
confidence: number // 0-1 confidence score
factors: {
salesVelocity: number
seasonalFactor: number
leadTime: number
safetyStock: number
}
}- TypeScript - Full type safety with strict mode enabled
- ESLint - Consistent code style enforcement
- Prettier - Automatic code formatting
- Husky - Git hooks for quality gates
- Lint-staged - Pre-commit code quality checks
# Development server
npm run dev
# Type checking
npm run type-check
# Linting
npm run lint
npm run lint:fix
# Code formatting
npm run format
npm run format:check
# Database management
npm run db:generate # Generate Prisma client
npm run db:push # Push schema changes
npm run db:migrate # Run migrations
npm run db:studio # Open Prisma Studio
npm run db:seed # Seed database- Component Architecture - Modular, reusable components
- Custom Hooks - Business logic encapsulation
- Type Definitions - Centralized TypeScript interfaces
- Utility Functions - Pure, testable helper functions
- Constants - Configuration and magic number elimination
# Create production build
npm run build
# Start production server
npm start- Vercel - Recommended for Next.js applications
- Docker - Containerized deployment
- AWS/GCP/Azure - Cloud platform deployment
- Traditional VPS - Server-based deployment
- Environment variable configuration
- Database connection pooling
- CDN setup for static assets
- Monitoring and logging implementation
- Backup and disaster recovery planning
All code is extensively documented with:
- JSDoc comments - Function and class documentation
- Type annotations - Complete TypeScript typing
- Inline comments - Complex logic explanation
- README files - Feature-specific documentation
- Database Schema - ERD and relationship documentation
- API Documentation - Endpoint specifications
- Component Library - Storybook component documentation
- Deployment Guide - Production setup instructions
This project is designed as a portfolio demonstration but follows enterprise development standards:
- Feature Planning - Issue creation and discussion
- Branch Strategy - Feature branch workflow
- Code Review - Pull request review process
- Testing - Comprehensive test coverage requirement
- Documentation - Update documentation with changes
- Follow TypeScript strict mode
- Maintain test coverage above 90%
- Use semantic commit messages
- Update documentation for new features
- Follow established code patterns
This project is created for demonstration purposes. Please see the LICENSE file for details.
For questions, suggestions, or issues:
- GitHub Issues - Technical problems and bug reports
- Documentation - Comprehensive guides and examples
- Code Comments - Inline documentation and explanations
Built with β€οΈ using modern TypeScript, Next.js, and AI technologies for enterprise-grade inventory management