A comprehensive inventory management system built with Next.js 15, TanStack Query, and TypeScript. This application provides a complete solution for managing inventory, sales, and customer data with role-based access control.
Backend url: https://github.com/brooktewabe/Inventory-API-Nest.js-v2
- Dashboard: Real-time analytics and overview with quick actions
- Inventory Management: Store and warehouse stock management
- Sales Management: Single and batch sales processing with persistence
- Customer Management System (CMS): Customer data and purchase history
- Stock Movement Tracking: Complete audit trail of inventory changes
- Stock Transfer: Move inventory between warehouse and store
- Notifications: Real-time alerts for low stock and important events
- Reporting: Comprehensive sales and inventory reports with export
- User Administration: Role-based access control with permissions
- Next.js 15: Latest Next.js with App Router and server components
- TanStack Query: Efficient data fetching, caching, and synchronization
- TypeScript: Type safety for critical components and data structures
- Responsive Design: Mobile-first approach with adaptive sidebar
- Real-time Updates: Optimistic updates and automatic cache invalidation
- Persistent State: Batch sale data persistence across sessions
- Authentication: JWT-based auth with automatic token refresh
- File Uploads: Image handling for products and receipts
- Advanced Search: Debounced search with real-time filtering
- Frontend: Next.js 15, React 18, TypeScript
- State Management: TanStack Query, React Hooks, Context API
- Styling: Tailwind CSS with custom components
- Authentication: JWT with HTTP-only cookies
- Forms: Formik with Yup validation
- Notifications: React Toastify, SweetAlert2
- Icons: React Icons
- File Handling: Native File API with preview support
βββ app/ # Next.js App Router pages
β βββ dashboard/ # Enhanced dashboard with widgets
β βββ sales/ # Sales management
β βββ batch-sale/ # Batch sales with persistence
β βββ warehouse/ # Warehouse inventory
β βββ customers-list/ # Customer management
β βββ stock-movement/ # Stock movement tracking
β βββ transfer-stock/ # Stock transfer between locations
β βββ reports/ # Report generation and export
β βββ settings/ # User and system settings
β βββ login/ # Authentication
β βββ forgot-password/ # Password recovery
β βββ reset-password/ # Password reset
β βββ layout.tsx # Root layout with providers
βββ components/ # Reusable components
β βββ Layout.tsx # Main layout with dynamic sidebar
β βββ Navbar.tsx # Responsive navigation sidebar
β βββ ProtectedRoute.tsx # Route protection with permissions
β βββ DashboardStats.tsx # Dashboard statistics widgets
β βββ StockAlert.tsx # Low stock alert component
β βββ QuickActions.tsx # Dashboard quick action buttons
β βββ RecentActivity.tsx # Recent activity feed
β βββ InventoryChart.tsx # Inventory visualization
β βββ SalesChart.tsx # Sales trend visualization
β βββ SearchCustomer.tsx # Customer search component
β βββ ... # Other feature components
βββ hooks/ # Custom React hooks
β βββ useAuth.ts # Authentication state management
β βββ useSidebar.ts # Sidebar state with persistence
β βββ useBatchSale.ts # Batch sale state with localStorage
βββ lib/ # Utility libraries
β βββ auth.ts # Authentication utilities
β βββ axios.ts # API client with interceptors
βββ middleware.ts # Next.js middleware for route protection
- Install dependencies:
npm install- Start the development server:
npm run dev- Build for production:
npm run build
npm startThe system implements a comprehensive permission system:
- Dashboard:
dashboardpermission - Access to main dashboard - Store Management:
storepermission - Sales and store operations - Inventory Management:
inventorypermission - Warehouse operations - Add Products:
addpermission - Product creation and bulk upload - Customer Management:
cmspermission - Customer data management - Settings:
settingspermission - System and user settings - Notifications:
notificationpermission - Notification management
- Admin: Full system access with user management
- Manager: Limited administrative access without user management
- Data Clerk: Basic operational access for daily tasks
- Automatic Caching: TanStack Query caches API responses intelligently
- Background Updates: Data refreshes automatically in the background
- Optimistic Updates: UI updates immediately for better perceived performance
- Debounced Search: Reduces API calls during typing (400ms delay)
- Pagination: Efficient data loading for large datasets
- Image Optimization: Next.js automatic image optimization
- Code Splitting: Automatic route-based code splitting
- Prefetching: Next.js prefetches linked pages
- Middleware Protection: Server-side route protection before rendering
- Token Management: Secure JWT handling with HTTP-only cookies
- Permission Validation: Component-level permission checks
- CSRF Protection: Built-in Next.js CSRF protection
- XSS Prevention: Automatic sanitization and validation
- API Interceptors: Automatic token refresh and error handling
- Mobile-first: Optimized for mobile devices with touch-friendly interfaces
- Adaptive Sidebar: Automatically collapses on mobile, expandable on desktop
- Dynamic Layout: No white space when sidebar is hidden
- Touch-friendly: Large touch targets and swipe gestures
- Flexible Grids: Responsive grid systems that adapt to screen size
- Breakpoint Management: Consistent breakpoints across components
// useAuth hook manages authentication globally
const { user, loading, logout, login, isAuthenticated } = useAuth()// useSidebar hook manages sidebar state with persistence
const { isCollapsed, isMobile, toggle } = useSidebar()// useBatchSale hook manages batch sale data with localStorage
const { batchData, updateBatchData, addItem, clearBatchData } = useBatchSale()// TanStack Query manages all server state
const { data, isLoading, error, refetch } = useQuery({
queryKey: ['key'],
queryFn: fetchFunction
})- Consistent Design Language: Unified color scheme and typography
- Loading States: Proper loading indicators throughout the app
- Error Handling: User-friendly error messages and recovery
- Form Validation: Real-time validation with clear error messages
- Micro-interactions: Hover states and smooth transitions
- Accessibility: Proper ARIA labels and keyboard navigation
- Visual Feedback: Toast notifications and confirmation dialogs
- Authentication: JWT tokens stored in HTTP-only cookies
- API Calls: Axios interceptors handle token attachment and refresh
- Caching: TanStack Query manages all server state caching
- Persistence: Critical data (batch sales, sidebar state) stored in localStorage
- Real-time Updates: Optimistic updates with automatic rollback on error
- First Contentful Paint: Improved with Next.js optimization
- Time to Interactive: Reduced with code splitting
- Bundle Size: Optimized with tree shaking
- API Calls: Reduced with intelligent caching
- Memory Usage: Optimized with proper cleanup
- Follow the established file structure and naming conventions
- Use TypeScript for new components when beneficial
- Implement proper error handling and loading states
- Add comprehensive form validation
- Follow the existing code style and patterns
- Test authentication flows and permission checks
- Ensure responsive design across all screen sizes
This project is proprietary software for inventory management purposes.
- Layout: Dynamic margin calculation based on sidebar state
- Navbar: Responsive sidebar with proper state management
- ProtectedRoute: Permission-based route protection
- Spinner: Consistent loading indicator
- DashboardStats: Key metrics and KPIs
- StockAlert: Low stock notifications
- QuickActions: Shortcut buttons for common tasks
- RecentActivity: Activity feed with real-time updates
- InventoryChart: Visual inventory breakdown
- SalesChart: Sales trend visualization
- SearchCustomer: Customer search with autocomplete
- ItemSelector: Product selection with search
- Revenue: Sales amount tracking with period selection
- Total: Total inventory value calculation
- useAuth: Global authentication state management
- useSidebar: Sidebar state with responsive behavior
- useBatchSale: Persistent batch sale data management
This rewrite addresses all the issues you mentioned while maintaining the exact same UI and functionality, but with significantly improved architecture, performance, and user experience.
.png)
.png)
.png)