Skip to content

el-noir/retail-system-frontend

Repository files navigation

Store Master Frontend

A modern, responsive retail management system frontend built with Next.js 16, React 19, TypeScript, and Tailwind CSS. This application provides an intuitive interface for managing inventory, sales, procurement, and analytics.

πŸ—οΈ Tech Stack

  • Framework: Next.js 16 (App Router)
  • UI Library: React 19
  • Language: TypeScript
  • Styling: Tailwind CSS 4
  • State Management: Redux Toolkit (@reduxjs/toolkit)
  • Form Handling: React Hook Form with Zod validation
  • UI Components: Radix UI primitives
  • HTTP Client: Axios
  • Charts: Recharts
  • Payments: Stripe (@stripe/react-stripe-js, @stripe/stripe-js)
  • Icons: Lucide React
  • Theme: next-themes (Dark/Light mode)
  • Notifications: Sonner (Toast notifications)
  • Date Utilities: date-fns

πŸ“ Project Structure

frontend/
β”œβ”€β”€ src/                          # Source code directory
β”‚   β”œβ”€β”€ app/                      # Next.js App Router pages
β”‚   β”‚   β”œβ”€β”€ layout.tsx            # Root layout with providers
β”‚   β”‚   β”œβ”€β”€ page.tsx              # Landing/home page
β”‚   β”‚   β”œβ”€β”€ globals.css           # Global styles and Tailwind imports
β”‚   β”‚   β”œβ”€β”€ favicon.ico           # Favicon
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ sign-in/              # Authentication - Sign In
β”‚   β”‚   β”‚   └── page.tsx          # Sign in page
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ sign-up/              # Authentication - Sign Up
β”‚   β”‚   β”‚   └── page.tsx          # Sign up page
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ verify-otp/           # OTP Verification
β”‚   β”‚   β”‚   └── page.tsx          # OTP verification page
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ sales/                # Sales pages (for cashier)
β”‚   β”‚   β”‚   └── page.tsx          # Sales/POS page
β”‚   β”‚   β”‚
β”‚   β”‚   └── dashboard/            # Main dashboard (protected routes)
β”‚   β”‚       β”œβ”€β”€ page.tsx          # Dashboard home page
β”‚   β”‚       β”‚
β”‚   β”‚       β”œβ”€β”€ admin/            # Admin-specific pages
β”‚   β”‚       β”‚   β”œβ”€β”€ page.tsx      # Admin dashboard
β”‚   β”‚       β”‚   └── categories/   # Category management
β”‚   β”‚       β”‚       └── page.tsx  # Categories page
β”‚   β”‚       β”‚
β”‚   β”‚       β”œβ”€β”€ cashier/          # Cashier-specific pages
β”‚   β”‚       β”‚   └── page.tsx      # Cashier dashboard
β”‚   β”‚       β”‚
β”‚   β”‚       β”œβ”€β”€ analytics/        # Analytics & reports
β”‚   β”‚       β”‚   └── page.tsx      # Analytics dashboard
β”‚   β”‚       β”‚
β”‚   β”‚       β”œβ”€β”€ products/         # Product management
β”‚   β”‚       β”‚   └── page.tsx      # Products page
β”‚   β”‚       β”‚
β”‚   β”‚       β”œβ”€β”€ suppliers/        # Supplier management
β”‚   β”‚       β”‚   └── page.tsx      # Suppliers page
β”‚   β”‚       β”‚
β”‚   β”‚       β”œβ”€β”€ purchase-orders/  # Purchase order management
β”‚   β”‚       β”‚   └── page.tsx      # Purchase orders page
β”‚   β”‚       β”‚
β”‚   β”‚       └── restock-recommendations/  # Restock alerts
β”‚   β”‚           └── page.tsx      # Restock recommendations page
β”‚   β”‚
β”‚   β”œβ”€β”€ components/               # React components
β”‚   β”‚   β”œβ”€β”€ AdminSidebar.tsx      # Admin navigation sidebar
β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx           # General sidebar component
β”‚   β”‚   β”œβ”€β”€ Navbar.tsx            # Navigation bar
β”‚   β”‚   β”œβ”€β”€ ProtectedRoute.tsx    # Route protection HOC
β”‚   β”‚   β”œβ”€β”€ ErrorBoundary.tsx     # Error boundary component
β”‚   β”‚   β”œβ”€β”€ Toast.tsx             # Toast notification component
β”‚   β”‚   β”œβ”€β”€ DataTable.tsx         # Reusable data table
β”‚   β”‚   β”œβ”€β”€ ProductForm.tsx       # Product form component
β”‚   β”‚   β”œβ”€β”€ ProductModal.tsx      # Product modal dialog
β”‚   β”‚   β”œβ”€β”€ ProductFilters.tsx    # Product filtering component
β”‚   β”‚   β”œβ”€β”€ SearchAndFilter.tsx   # Search and filter component
β”‚   β”‚   β”œβ”€β”€ EnhancedForm.tsx      # Enhanced form component
β”‚   β”‚   β”œβ”€β”€ ProcurementOverview.tsx  # Procurement overview
β”‚   β”‚   β”‚
β”‚   β”‚   └── ui/                   # Shadcn/Radix UI components
β”‚   β”‚       β”œβ”€β”€ badge.tsx         # Badge component
β”‚   β”‚       β”œβ”€β”€ button.tsx        # Button component
β”‚   β”‚       β”œβ”€β”€ card.tsx          # Card component
β”‚   β”‚       β”œβ”€β”€ checkbox.tsx      # Checkbox component
β”‚   β”‚       β”œβ”€β”€ dialog.tsx        # Dialog/Modal component
β”‚   β”‚       β”œβ”€β”€ dropdown-menu.tsx # Dropdown menu component
β”‚   β”‚       β”œβ”€β”€ form.tsx          # Form component wrapper
β”‚   β”‚       β”œβ”€β”€ input.tsx         # Input component
β”‚   β”‚       β”œβ”€β”€ label.tsx         # Label component
β”‚   β”‚       β”œβ”€β”€ select.tsx        # Select dropdown component
β”‚   β”‚       β”œβ”€β”€ skeleton.tsx      # Loading skeleton component
β”‚   β”‚       β”œβ”€β”€ sonner.tsx        # Sonner toast wrapper
β”‚   β”‚       β”œβ”€β”€ table.tsx         # Table component
β”‚   β”‚       β”œβ”€β”€ textarea.tsx      # Textarea component
β”‚   β”‚       └── responsive-table.tsx  # Responsive table wrapper
β”‚   β”‚
β”‚   └── lib/                      # Utility libraries
β”‚       β”œβ”€β”€ utils.ts              # Utility functions (cn, etc.)
β”‚       β”‚
β”‚       β”œβ”€β”€ api/                  # API client layer
β”‚       β”‚   β”œβ”€β”€ client.ts         # Axios client configuration
β”‚       β”‚   β”œβ”€β”€ auth.ts           # Authentication API calls
β”‚       β”‚   β”œβ”€β”€ products.ts       # Products API calls
β”‚       β”‚   β”œβ”€β”€ categories.ts     # Categories API calls
β”‚       β”‚   β”œβ”€β”€ sales.ts          # Sales API calls
β”‚       β”‚   β”œβ”€β”€ inventory.ts      # Inventory API calls
β”‚       β”‚   β”œβ”€β”€ suppliers.ts      # Suppliers API calls
β”‚       β”‚   β”œβ”€β”€ purchase-orders.ts # Purchase orders API calls
β”‚       β”‚   β”œβ”€β”€ payments.ts       # Payments API calls (Stripe)
β”‚       β”‚   β”œβ”€β”€ analytics.ts      # Analytics API calls
β”‚       β”‚   └── stock.ts          # Stock management API calls
β”‚       β”‚
β”‚       β”œβ”€β”€ store/                # Redux store configuration
β”‚       β”‚   β”œβ”€β”€ index.ts          # Store configuration & exports
β”‚       β”‚   β”œβ”€β”€ hooks.ts          # Typed Redux hooks (useAppDispatch, useAppSelector)
β”‚       β”‚   β”œβ”€β”€ ReduxProvider.tsx # Redux Provider wrapper component
β”‚       β”‚   β”‚
β”‚       β”‚   └── slices/           # Redux slices
β”‚       β”‚       β”œβ”€β”€ productsSlice.ts    # Products state management
β”‚       β”‚       β”œβ”€β”€ salesSlice.ts       # Sales state management
β”‚       β”‚       β”œβ”€β”€ suppliersSlice.ts   # Suppliers state management
β”‚       β”‚       β”œβ”€β”€ purchasesSlice.ts   # Purchase orders state
β”‚       β”‚       └── analyticsSlice.ts   # Analytics state
β”‚       β”‚
β”‚       β”œβ”€β”€ hooks/                # Custom React hooks
β”‚       β”‚   β”œβ”€β”€ index.ts          # Hook exports
β”‚       β”‚   β”œβ”€β”€ useDebounce.ts    # Debounce hook
β”‚       β”‚   β”œβ”€β”€ useDebouncedCallback.ts  # Debounced callback hook
β”‚       β”‚   └── useThrottle.ts    # Throttle hook
β”‚       β”‚
β”‚       └── validations/          # Zod validation schemas
β”‚           β”œβ”€β”€ signInSchema.ts   # Sign in form validation
β”‚           └── signUpSchema.ts   # Sign up form validation
β”‚
β”œβ”€β”€ public/                       # Static assets
β”‚   └── manifest.json             # PWA manifest
β”‚
β”œβ”€β”€ Configuration Files
β”‚   β”œβ”€β”€ package.json              # Dependencies and scripts
β”‚   β”œβ”€β”€ tsconfig.json             # TypeScript configuration
β”‚   β”œβ”€β”€ next.config.ts            # Next.js configuration
β”‚   β”œβ”€β”€ next-env.d.ts             # Next.js TypeScript declarations
β”‚   β”œβ”€β”€ tailwind.config.js        # Tailwind CSS configuration (implied)
β”‚   β”œβ”€β”€ postcss.config.mjs        # PostCSS configuration
β”‚   β”œβ”€β”€ components.json           # Shadcn UI configuration
β”‚   β”œβ”€β”€ eslint.config.mjs         # ESLint configuration
β”‚   β”œβ”€β”€ FRONTEND_UX_ENHANCEMENTS.md  # UX enhancement documentation
β”‚   └── README.md                 # This file

🎨 Design System

Color Scheme

  • Supports light and dark themes via next-themes
  • CSS variables for consistent theming
  • Tailwind CSS utility classes

UI Components

  • Built on Radix UI primitives for accessibility
  • Customized with Tailwind CSS
  • Consistent design patterns across all pages
  • Responsive design for mobile, tablet, and desktop

Typography

  • System font stack for optimal performance
  • Consistent heading hierarchy
  • Readable body text with proper line height

πŸ”‘ Key Features

1. Authentication & Authorization

  • User registration with email verification
  • OTP-based email verification
  • JWT-based authentication
  • Role-based access control (RBAC)
  • Protected routes with redirect
  • Persistent authentication state

2. Dashboard

  • Role-specific dashboards (Admin, Cashier, Manager, Procurement)
  • Real-time statistics and KPIs
  • Quick actions and shortcuts
  • Responsive sidebar navigation

3. Product Management

  • CRUD operations for products
  • Product search and filtering
  • Category-based organization
  • Image upload support
  • Stock level indicators
  • Bulk operations

4. Inventory Management

  • Real-time stock tracking
  • Stock adjustment interface
  • Low stock alerts
  • Restock recommendations
  • Stock movement history
  • Inventory valuation reports

5. Sales & Point of Sale (POS)

  • Fast and intuitive POS interface
  • Product search and quick add
  • Shopping cart management
  • Multiple payment methods (Cash, Card, Stripe)
  • Receipt generation
  • Sales history

6. Supplier Management

  • Supplier CRUD operations
  • Contact information management
  • Supplier product catalog
  • Performance tracking

7. Procurement

  • Purchase order creation and management
  • Supplier selection
  • Order status tracking
  • Receiving interface
  • Expected vs. actual delivery tracking

8. Analytics & Reporting

  • Sales analytics with charts
  • Revenue tracking
  • Product performance metrics
  • Inventory analytics
  • Custom date range selection
  • Export capabilities

9. Payment Processing

  • Stripe integration
  • Secure payment handling
  • Payment confirmation
  • Transaction history

10. Responsive Design

  • Mobile-first approach
  • Tablet optimization
  • Desktop layouts
  • Touch-friendly interfaces
  • Responsive tables

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn package manager
  • Backend API running (see backend README)

Installation

  1. Clone the repository

    cd frontend
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env.local file in the frontend directory:

    # API Configuration
    NEXT_PUBLIC_API_URL=http://localhost:3000
    
    # Stripe Configuration
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
    
    # Application Configuration
    NEXT_PUBLIC_APP_NAME="Store Master"
    NEXT_PUBLIC_APP_URL=http://localhost:3001
  4. Run the development server

    npm run dev
  5. Open the application

    Navigate to http://localhost:3001

Building for Production

# Build the application
npm run build

# Start production server
npm run start

πŸ“ Available Scripts

Script Description
npm run dev Start development server (hot reload)
npm run build Build for production
npm run start Start production server
npm run lint Run ESLint

🎯 Application Routes

Public Routes

  • / - Landing page
  • /sign-in - User sign in
  • /sign-up - User registration
  • /verify-otp - OTP verification

Protected Routes (Requires Authentication)

  • /dashboard - Main dashboard (role-based)
  • /dashboard/admin - Admin dashboard
  • /dashboard/admin/categories - Category management
  • /dashboard/cashier - Cashier dashboard
  • /dashboard/analytics - Analytics and reports
  • /dashboard/products - Product management
  • /dashboard/suppliers - Supplier management
  • /dashboard/purchase-orders - Purchase order management
  • /dashboard/restock-recommendations - Restock alerts
  • /sales - Point of Sale (POS) interface

πŸ” User Roles & Permissions

Admin

  • Full system access
  • User management
  • Category management
  • Product management
  • Sales management
  • Procurement management
  • Analytics access

Manager

  • Product management
  • Sales management
  • Procurement management
  • Analytics access
  • Inventory adjustments

Cashier

  • POS access
  • View products
  • Create sales
  • Limited dashboard access

Procurement

  • Supplier management
  • Purchase order management
  • Receive orders
  • View inventory

🎨 Styling

Tailwind CSS

The project uses Tailwind CSS 4 for styling:

  • Utility-first approach
  • Custom design tokens
  • Responsive breakpoints
  • Dark mode support

CSS Variables

Theme variables are defined in globals.css:

  • --background, --foreground
  • --primary, --secondary
  • --accent, --muted
  • --destructive, --success
  • Border radius, shadows, and more

πŸ“¦ State Management

Redux Toolkit

The application uses Redux Toolkit for global state management:

Products Slice

  • Product list
  • Selected product
  • Loading states
  • Filters

Sales Slice

  • Cart items
  • Active sale
  • Sales history

Suppliers Slice

  • Supplier list
  • Selected supplier

Purchases Slice

  • Purchase orders
  • PO status

Analytics Slice

  • Dashboard metrics
  • Chart data

Usage Example

import { useAppSelector, useAppDispatch } from '@/lib/store/hooks';
import { fetchProducts } from '@/lib/store/slices/productsSlice';

const products = useAppSelector(state => state.products.items);
const dispatch = useAppDispatch();

useEffect(() => {
  dispatch(fetchProducts());
}, [dispatch]);

πŸ”Œ API Integration

All API calls are centralized in the src/lib/api/ directory:

// Example: Fetching products
import { getProducts } from '@/lib/api/products';

const products = await getProducts({ page: 1, limit: 10 });

API Client Configuration

The Axios client is configured in client.ts:

  • Base URL from environment variables
  • JWT token interceptor
  • Error handling
  • Request/response interceptors

🎣 Custom Hooks

useDebounce

Debounce a value (useful for search inputs):

const debouncedSearch = useDebounce(searchTerm, 500);

useDebouncedCallback

Debounce a callback function:

const debouncedFn = useDebouncedCallback(handleSearch, 500);

useThrottle

Throttle a value:

const throttledValue = useThrottle(scrollY, 100);

πŸ§ͺ Form Validation

Forms use React Hook Form with Zod validation:

import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { signInSchema } from '@/lib/validations/signInSchema';

const form = useForm({
  resolver: zodResolver(signInSchema),
  defaultValues: { email: '', password: '' }
});

🌐 Environment Variables

Required environment variables:

Variable Description Example
NEXT_PUBLIC_API_URL Backend API URL http://localhost:3000
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY Stripe public key pk_test_...
NEXT_PUBLIC_APP_NAME Application name Store Master
NEXT_PUBLIC_APP_URL Frontend URL http://localhost:3001

🎨 Theme Customization

The application supports light and dark themes. Theme switching is handled by next-themes.

Adding a New Theme Color

  1. Add CSS variable to globals.css
  2. Add Tailwind utility class
  3. Use in components: className="bg-your-color"

πŸ“± Responsive Design

Breakpoints

  • sm: 640px
  • md: 768px
  • lg: 1024px
  • xl: 1280px
  • 2xl: 1536px

Mobile-First Approach

All components are designed mobile-first and scale up:

<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3">
  {/* Content */}
</div>

πŸ”” Notifications

Toast notifications use Sonner:

import { toast } from 'sonner';

toast.success('Product created successfully');
toast.error('Failed to create product');
toast.info('Processing...');

🧩 Component Library

The project uses Shadcn UI components built on Radix UI:

  • Fully accessible
  • Customizable
  • Type-safe
  • Composable

Adding New Shadcn Components

npx shadcn-ui@latest add [component-name]

πŸš€ Performance Optimization

  • Code Splitting: Automatic with Next.js App Router
  • Image Optimization: Next.js Image component
  • Lazy Loading: Dynamic imports for heavy components
  • Debouncing: Search and filter operations
  • Memoization: React.memo and useMemo for expensive computations

πŸ”’ Security Best Practices

  • JWT tokens stored in httpOnly cookies (handled by backend)
  • No sensitive data in localStorage
  • Input validation on client and server
  • XSS prevention with proper escaping
  • CSRF protection

πŸ› Error Handling

  • Error boundaries for component errors
  • Global error handling in API client
  • User-friendly error messages
  • Logging for debugging

🀝 Contributing

  1. Follow the existing code structure
  2. Use TypeScript types properly
  3. Write meaningful component names
  4. Add comments for complex logic
  5. Test on multiple screen sizes
  6. Follow ESLint rules

πŸ“„ License

UNLICENSED - Private project

πŸ‘¨β€πŸ’» Support

For support or questions, refer to the documentation or contact the development team.

🎯 Future Enhancements

See FRONTEND_UX_ENHANCEMENTS.md for planned improvements.


Built with ❀️ using Next.js, React, TypeScript, and Tailwind CSS

This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages