A production React application for cannabis inventory tracking, barcode scanning, and thermal label generation. Handles multi-source CSV/Excel imports, automatic allergen detection, and Zebra ZT610-optimized label printing at 203 DPI. Cloud-synced master product list via Supabase with offline localStorage fallback.
Running in production since 2024. Currently at v7.4.1.
- Features
- Tech Stack
- Prerequisites
- Setup
- Environment Configuration
- Authentication
- Data Sources
- Label Generation
- Thermal Printer Configuration
- Development
- Build
- Production Deployment
- Security Notes
- Multi-Source Data Import: Support for Main Inventory, Sweed Reports, and Import Report CSV/Excel files
- User Authentication: Role-based access control with configurable user credentials
- Barcode Scanning: Real-time barcode scanning with product lookup across all data sources
- Thermal Label Generation: Professional labels optimized for Zebra ZT610 (4" × 6" thermal labels)
- Automatic Allergen Detection: Smart detection of allergen-containing products based on product names
- Enhanced Data Management: Batch IDs, harvest/package dates, case quantities, and box tracking
- Real-Time Session Tracking: Track scanned items and generate comprehensive reports
- Multi-Format Support: CSV and Excel file import with robust error handling
- Responsive Dark UI: Modern dark theme optimized for warehouse environments
- Label Preview: Live preview of labels before printing
- Calibration Tools: Printer alignment testing and calibration utilities
- Master List Cloud Sync: Supabase-backed product list with 1000+ record pagination
- Unmapped Product Admin: Override system for unrecognized products with remap history
- Multi-Location Support: HSTD (horizontal) and MTD (vertical) label formats
- Version-Aware State: Automatic cache invalidation on app updates
| Layer | Technology |
|---|---|
| Frontend | React 18, React Router 6 |
| Build | Vite 5 |
| Styling | Tailwind CSS 3.4 (custom dark theme, 400+ lines) |
| Labels | jsPDF (PDF generation), JsBarcode (Code 39) |
| Data Import | PapaParse (CSV), SheetJS (Excel) |
| Cloud Sync | Supabase (PostgreSQL, master product list) |
| Printer | Zebra Browser Print SDK (ZPL generation) |
| Hosting | Netlify (SPA routing, security headers, asset caching) |
Before setting up the project, ensure you have the following:
- Node.js (v18+) and npm: Install from nodejs.org
- Modern Web Browser: Chrome, Firefox, Safari, or Edge
- Zebra ZT610 Thermal Printer (optional): For physical label printing
- Label Stock: 4" × 6" thermal labels compatible with Zebra ZT610
- Git: For cloning the repository
Follow these steps to set up the project locally:
git clone https://github.com/claygeo/cannabis-inventory-system.git
cd cannabis-inventory-systemnpm installCopy the environment template and configure your credentials:
cp .env.example .envEdit the .env file with your preferred settings. For quick testing, the default demo credentials will work immediately.
npm run devThe application will be available at http://localhost:3000
npm run buildThe application uses environment variables for user authentication. This allows you to:
- Keep production credentials secure
- Use different credentials for different environments
- Share the project publicly without exposing sensitive data
If no environment variables are set, the system uses demo credentials:
| Username | Password | Role | Purpose |
|---|---|---|---|
| admin | admin123 | Administrator | Full system access |
| warehouse | warehouse123 | Warehouse | Basic scanning operations |
| manager | manager123 | Manager | Management functions |
Set up your own user accounts by editing the .env file:
# Example custom user
VITE_USER_JOHN_PASSWORD=secure_password_123
VITE_USER_JOHN_ROLE=Administrator
VITE_USER_JOHN_FULL_NAME=John Smith
VITE_USER_JOHN_DISPLAY_NAME=John- Administrator: Full system access, can import data and generate reports
- Manager: Management functions, reporting, and label generation
- Warehouse: Basic scanning and inventory operations
The application uses a frontend-only authentication system designed for:
- Demo purposes: Easy testing and development
- Internal networks: Controlled access environments
- Proof of concept: Showcasing functionality
Important: This is a demonstration-grade authentication system:
- Passwords are stored in environment variables (visible to frontend)
- No server-side validation or session management
- Suitable for internal tools and demos only
- For production use, implement proper backend authentication
The system supports multiple inventory data sources:
- File Type: CSV or Excel
- Required Columns:
- Column A: Product Name
- Column D: Quantity on Hand
- Column E: Barcode Number
- Column F: External Barcode (optional)
- Header Row: Row 1 (index 0)
- Data Starts: Row 2 (index 1)
- Login with appropriate credentials
- Navigate to Import Report page
- Select file (CSV or Excel format)
- Validate data structure and content
- Import processed data into the system
- Format: Single 4" × 6" labels per page
- Orientation: Horizontal landscape
- Content: Optimized layout with brand separation
- Printer: Optimized for Zebra ZT610 (203 DPI)
- Brand Detection: Automatic separation of brand and product names
- Allergen Warnings: Visual warnings for allergen-containing products
- Enhanced Layout:
- Large product names (up to 48pt font)
- Package ID reference box
- Harvest and package dates
- Case quantity and box tracking
- Batch ID squares
- Audit trail with timestamp and user
- Alignment Test: Generate calibration pages for printer setup
- Blank Templates: Empty label borders for custom projects
- Test Labels: Single and full-sheet test patterns
- Label Size: Configure for 4" × 6" (288 × 432 points)
- Print Mode: Thermal Transfer or Direct Thermal
- DPI Setting: 203 DPI
- Media Settings: Continuous media, no gaps
- Calibration: Use built-in alignment test pages
- Page Size: Actual Size (no scaling)
- Orientation: Portrait
- Margins: None (full bleed)
- Quality: High/Best quality
src/
├── components/ # React components
├── contexts/ # React context providers
├── hooks/ # Custom React hooks
├── utils/ # Utility functions
├── styles/ # CSS and styling
└── constants.js # Application constants
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLintProduction build via Vite with manual chunk splitting for optimal caching.
| Chunk | Raw | Gzip |
|---|---|---|
| react | 141 KB | 45 KB |
| utils (papaparse, jsbarcode, jspdf, xlsx) | 872 KB | 281 KB |
| html2canvas | 201 KB | 48 KB |
| app code | 482 KB | 118 KB |
| router | 21 KB | 8 KB |
| ui (lucide, toast) | 22 KB | 8 KB |
| CSS | 101 KB | 14 KB |
CI pipeline runs on every push and PR to master: npm ci and npm run build.
-
Create production
.envfile:cp .env.example .env # Edit .env with production credentials -
Build the application:
npm run build
-
**Deploy the
distfolder` to your web server
- Static hosting: Netlify, Vercel, GitHub Pages
- Web servers: Apache, Nginx, IIS
- CDN: CloudFront, CloudFlare
- HTTPS: Always use HTTPS in production
- Environment Variables: Keep credentials secure
- Browser Support: Test with target browsers
- Data Backup: Implement localStorage backup strategies
- Access Control: Consider network-level restrictions
This system uses frontend-only authentication which is appropriate for:
Good for:
- Internal company tools
- Demo applications
- Development and testing
- Controlled network environments
Not suitable for:
- Public-facing applications
- Multi-tenant systems
- Applications handling sensitive data
- Compliance-required environments
For production systems handling sensitive data:
- Backend Authentication: Implement server-side user management
- Database Storage: Use proper database instead of localStorage
- API Security: Add authentication tokens and rate limiting
- Access Controls: Implement proper role-based permissions
- Audit Logging: Add comprehensive activity logging
- Data Encryption: Encrypt sensitive data at rest and in transit
All data is stored locally in browser localStorage:
- Inventory Data: Main inventory, Sweed data, Import reports
- Scanned Items: Session tracking of scanned products
- Enhanced Data: Label configuration settings
- User Sessions: Authentication and activity logging
- Session History: Comprehensive activity tracking
- Setup: Copy
.env.exampleto.envand configure - Login: Authenticate with configured credentials
- Import Data: Upload inventory files from CSV/Excel sources
- Scan Products: Use barcode scanner or manual entry to track items
- Configure Labels: Set quantities, dates, batch IDs, and enhanced data
- Generate Labels: Preview and print thermal labels
- Session Management: Track progress and generate reports
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For support and questions:
- Issues: Create a GitHub issue for bugs or feature requests
- Documentation: Check the README and inline code comments
- Security: For security-related issues, please email privately
- Unmapped products admin dashboard with remap history
- Fix dark theme consistency on admin pages
- Supabase cloud sync for master product list
- Pagination support for 1000+ products
- Auto-fix strain placeholder with actual strain data
- Environment variable configuration for credentials
- Enhanced documentation and setup process