A modern, enterprise-grade inventory management dashboard built with React, TypeScript, and Supabase. Features a modular architecture, comprehensive testing, and production-ready codebase.
- ✅ Real Authentication - Email/password and OAuth (Google, GitHub)
- ✅ Product Management - Full CRUD with search and advanced filters
- ✅ Order Management - Create, edit, delete orders with item tracking
- ✅ Dashboard Analytics - Real-time KPIs and visualizations
- ✅ AI-Powered Reports - Generate optimization insights (mock AI for demo)
- ✅ Smart Notifications - Auto-alerts for low stock items
- ✅ Data Import/Export - CSV import and export functionality
- ✅ User Preferences - Dark mode, notifications, currency settings
- ✅ Responsive Design - Works on desktop, tablet, and mobile
- ✅ Modular Architecture - Clean, maintainable codebase
- ✅ Comprehensive Testing - Unit, integration, and E2E test setup
src/
├── pages/ # Page-level components
├── features/ # Feature modules (notifications, etc.)
├── ui/ # Reusable UI component library
├── hooks/ # Custom React hooks
├── services/ # Modular business logic
│ ├── products/
│ ├── orders/
│ ├── customers/
│ └── preferences/
├── utils/ # Utility functions
│ ├── formatting.ts
│ ├── validation.ts
│ └── helpers.ts
├── types/ # TypeScript definitions
├── contexts/ # React contexts
├── lib/ # Third-party configs
└── test/ # Testing infrastructure
- Modular - Each module < 100 lines, single responsibility
- Testable - Comprehensive test coverage
- Type-Safe - Full TypeScript support
- Reusable - Shared components and utilities
- Maintainable - Clear structure and documentation
- Node.js 18+
- Supabase account (sign up free)
-
Clone and install:
git clone <repository-url> cd stockflow-inventory npm install
-
Set up Supabase:
- Create project at supabase.com
- Run SQL migration from
supabase/migrations/001_initial_schema.sql - Enable OAuth providers (optional)
- Get API keys from Settings → API
-
Configure environment:
cp .env.example .env.local
Edit
.env.localwith your Supabase credentials:DATABASE_URL=postgresql://user:password@host:5432/database VITE_SUPABASE_URL=https://your-project.supabase.co VITE_SUPABASE_ANON_KEY=your-anon-key
[!WARNING] NEVER commit
.env.localto git! It contains sensitive credentials. If credentials are accidentally exposed, rotate them immediately in Supabase dashboard. -
Run development server:
npm run dev
-
Open browser: Navigate to
http://localhost:3000
# Run all tests
npm test
# Watch mode
npm run test:watch
# UI mode
npm run test:ui
# Coverage report
npm run test:coverageTest Coverage:
- Formatting utilities: ✅ 100%
- Validation utilities: ✅ 100%
- Services: ✅ Partial
- Hooks: ✅ Partial
- Frontend: React 19, TypeScript, Vite
- Backend: Supabase (PostgreSQL, Auth, Storage)
- Styling: Tailwind CSS
- Charts: Recharts
- Testing: Vitest, React Testing Library
- Notifications: React Hot Toast
- Total Files: 58 TypeScript files
- Total Lines: ~4,700 lines of code
- Build Size: 976 KB (284 KB gzipped)
- Test Coverage: Growing (utilities at 100%)
- Email/password authentication
- OAuth with Google and GitHub
- Session management
- Protected routes
- Add, edit, delete products
- Advanced search and filtering
- Category and status filters
- Price range filtering
- Stock level tracking
- Low stock alerts
- Create orders with multiple items
- Edit order status
- Delete orders
- Order history tracking
- Real-time dashboard KPIs
- Revenue trends chart
- Category distribution
- AI-powered optimization reports (mock)
- Smart notification center
- Auto-detects low stock
- Real-time updates
- Mark as read/unread
npm run dev # Start development server
npm run build # Build for production
npm run preview # Preview production build
npm test # Run tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
npm run type-check # TypeScript type checking- Components → Feature-specific components
- Pages → Page-level wrappers
- Features → Self-contained feature modules
- UI → Reusable UI components
- Hooks → Custom React hooks
- Services → Business logic (modular)
- Utils → Utility functions
- Types → TypeScript definitions
See DEPLOYMENT.md for detailed instructions.
Quick Deploy to Vercel:
npm i -g vercel
vercelAdd environment variables in Vercel dashboard.
| Variable | Description | Required |
|---|---|---|
VITE_SUPABASE_URL |
Your Supabase project URL | Yes |
VITE_SUPABASE_ANON_KEY |
Supabase anonymous key | Yes |
Reusable components available in src/ui/components/:
Button- Variants, sizes, loading statesInput- Form inputs with validationCard- Container component
Available hooks in src/hooks/:
useProducts- Product data managementuseOrders- Order data management
See supabase/migrations/001_initial_schema.sql for complete schema.
Main Tables:
products- Inventory itemsorders- Customer ordersorder_items- Order line itemscustomers- Customer informationuser_preferences- User settings
- ✅ Row Level Security (RLS) enabled on all tables
- ✅ User data isolation via
user_idfiltering - ✅ Supabase Auth with JWT tokens
- ✅ HTTPS enforced by default
- ✅ Session management and refresh tokens
Caution
Critical Security Notes:
.env.localis gitignored by default - verify it's not committedDATABASE_URLcontains credentials - only use server-sideVITE_SUPABASE_ANON_KEYis safe to expose (public anonymous key)- If credentials are exposed, rotate them immediately:
- Go to Supabase Dashboard → Settings → API
- Reset service role key (if exposed)
- Update
.env.localwith new credentials
- Never hardcode secrets in code
- Use environment variables for all sensitive data
- Enable RLS on all database tables
- Implement input validation on all user inputs
- Keep dependencies updated (run
npm auditregularly)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
MIT License
Built with ❤️ using React, TypeScript, and Supabase
Status: 🟢 Production Ready