A comprehensive sales rep dashboard with goal tracking, forecasting, inventory alerts, and CRM integration. Built with Next.js 15, Supabase, React Query, and modern TypeScript.
- Goal Progress Cards: Visual KPI tracking with traffic-light colors
- Goal Breakdown: Detailed drill-down by accounts and performance
- Multi-period Views: Day, week, month, and year-to-date tracking
- Brand-specific Goals: AO (At Once) and Prebook goal types
- Responsive Charts: Recharts with mobile-optimized area charts
- Confidence Intervals: Predictive modeling with uncertainty ranges
- Brand Filtering: Multi-select brand context switching
- Historical Analysis: 2+ years of sales data for trend analysis
- Real-time Stock Alerts: Low stock and out-of-stock notifications
- Brand-specific Monitoring: Filter alerts by selected brands
- Quick Resolution: One-click alert resolution workflow
- Health Indicators: Green/Yellow/Red status for sell-through rates
- Streak API: Native integration with Streak CRM
- Contact Tracking: Last contact dates and email open rates
- Task Management: Create and complete tasks from dashboard
- Opportunity Pipeline: View store-specific sales opportunities
- Responsive Design: Mobile-first with breakpoint optimization
- Accessibility: WCAG-compliant with screen reader support
- Real-time Updates: React Query for optimistic UI updates
- Brand Context: Persistent brand filtering via URL state
- Node.js 18+ and npm
- Supabase account and project
- Optional: Streak API key for CRM features
Clone the repository and install dependencies:
git clone <your-repo-url>
cd reporder
npm installCreate .env.local with required variables:
# Supabase Configuration
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
# CRM Integration (Optional)
NEXT_PUBLIC_STREAK_API_KEY=your_streak_api_key
# App Configuration
NEXT_PUBLIC_BASE_URL=http://localhost:3003Run the migrations to set up the database schema:
# Apply all migrations including the new MVP tables
npx supabase db push
# Or manually apply the migration
psql -h your-host -U postgres -d postgres -f supabase/migrations/005_create_rep_dashboard_tables.sqlPopulate the database with realistic sample data:
# Install tsx for running TypeScript scripts
npm install -g tsx
# Run the seed script
tsx scripts/seed_goals.tsThis will create:
- Rep goals for 6 months across multiple brands and stores
- Daily sales metrics for the last 90 days
- Historical sales data for 2 years (weekly aggregation)
- Sample stock alerts for testing inventory features
Run the development server:
npm run devVisit http://localhost:3003/dashboard to see the dashboard.
To enable Streak CRM integration:
- Get your Streak API key from Streak Settings
- Add it to your
.env.localasNEXT_PUBLIC_STREAK_API_KEY - Restart the development server
reporder/
βββ src/
β βββ app/dashboard/ # Main dashboard pages
β βββ components/dashboard/ # Dashboard components
β β βββ GoalProgressCard.tsx # KPI tracking cards
β β βββ LowStockAlert.tsx # Inventory alerts
β β βββ ForecastWidget.tsx # Sales forecasting charts
β β βββ BrandFilter.tsx # Multi-select brand filter
β β βββ StoreCRMPane.tsx # CRM integration panel
β βββ lib/services/ # Data services
β β βββ dashboard-goals.ts # Goal tracking & React Query hooks
β β βββ dashboard.ts # Existing sales analytics
β βββ lib/streak.ts # Streak CRM API wrapper
βββ supabase/
β βββ migrations/ # Database schema
β β βββ 005_create_rep_dashboard_tables.sql
β βββ functions/ # Edge Functions
β βββ syncBrandWebhook/ # Brand data ingestion
β βββ syncBuyerFeed/ # CSV stock alert processing
βββ scripts/
βββ seed_goals.ts # Database seeding script
npm run dev # Start development server (port 3003)
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
npm run quality # Run linting + TypeScript checks- Goal Progress: View goal tracking cards with realistic completion percentages
- Brand Filtering: Use the multi-select filter to switch dashboard context
- Forecasting: View 30-day revenue and unit predictions with confidence intervals
- Stock Alerts: See sample low-stock and out-of-stock notifications
- CRM Features: Connect Streak to see contact history and task management
The dashboard provides several API endpoints for data management:
POST /functions/v1/syncBrandWebhook- Ingest brand sales data (JSON)POST /functions/v1/syncBuyerFeed- Process stock alerts (CSV)- Internal React Query hooks handle all dashboard data fetching
The MVP adds four core tables:
rep_goals- Goal tracking by rep, store, brand, and typesales_metrics- Daily sales roll-ups from brand feedsstock_alerts- Inventory alerts with resolution trackinghistorical_sales- 2+ years of sales data for forecasting
All tables implement RLS policies:
- Reps can only see their own goals (
auth.uid() = rep_id) - Authenticated users can read sales metrics and alerts
- Proper isolation for multi-tenant scenarios
The dashboard uses React Query for:
- Optimistic Updates: Immediate UI feedback
- Background Refresh: Automatic data sync
- Caching Strategy: 2-15 minute cache times based on data type
- Error Handling: Automatic retry with user feedback
- Traffic Light Colors: Green (100%+), Yellow (75%+), Orange (50%+), Red (<50%)
- Accessibility: ARIA labels, keyboard navigation, screen reader support
- Click Actions: Drill-down to goal breakdown (placeholder for future modal)
- Responsive Charts: Line charts on desktop, area charts on mobile (<640px)
- Confidence Intervals: Visual uncertainty ranges with dashed lines
- Interactive Tooltips: Hover for detailed predictions
- View Switching: Toggle between revenue and units forecasting
- Multi-select: Checkbox-based selection with search
- Presets: Quick select for "All", "Favorites", "Top 5", "None"
- URL Persistence: Brand selection persisted in URL parameters
- Favorites: Star system for frequently used brands
- Priority Sorting: Out-of-stock alerts first, then by creation date
- Resolution Actions: One-click alert resolution with optimistic updates
- Real-time Updates: Auto-refresh every 2 minutes
- Visual Hierarchy: Color-coded alert types with clear iconography
The dashboard integrates with Streak CRM for:
- Contact History: Last contact dates and email engagement
- Task Management: Create and complete tasks from the dashboard
- Opportunity Tracking: View store-specific sales pipeline
- Activity Timeline: Recent CRM activity for each store
To configure Streak:
- Get API key from Streak settings
- Add to environment variables
- Test connection via the dashboard
Two Supabase Edge Functions handle data ingestion:
-
Brand Webhook (
/functions/syncBrandWebhook)- Accepts JSON payloads with sales data
- Validates store existence
- Upserts to
sales_metricstable
-
Buyer Feed (
/functions/syncBuyerFeed)- Processes CSV with inventory data
- Creates/resolves stock alerts automatically
- Handles product lookup by ID, SKU, or UPC
- Run the seed script to populate sample data
- Navigate to the dashboard and verify all components load
- Test brand filtering and URL persistence
- Try resolving stock alerts
- If Streak is configured, test CRM features
- Goals show realistic progress percentages
- Forecast charts display 30-day predictions
- Stock alerts prioritize out-of-stock items
- Brand filtering affects forecast context
- Set up Supabase production project
- Configure environment variables on your hosting platform
- Run migrations against production database
- Deploy Edge Functions to Supabase
- Optional: Set up Streak integration
# Production
NEXT_PUBLIC_SUPABASE_URL=https://prod-project.supabase.co
SUPABASE_SERVICE_ROLE_KEY=prod_service_role_key
NEXT_PUBLIC_STREAK_API_KEY=prod_streak_key
NEXT_PUBLIC_BASE_URL=https://your-domain.com- React Query Caching: Reduces API calls with smart cache invalidation
- Responsive Charts: Mobile-optimized visualizations switch automatically
- Lazy Loading: Components load data on-demand
- Optimistic Updates: UI responds immediately to user actions
- Recharts adds ~100KB for chart functionality
- React Query adds ~40KB for state management
- Total dashboard overhead: ~150KB gzipped
Dashboard shows no data:
- Run the seed script:
tsx scripts/seed_goals.ts - Check Supabase connection and table creation
- Verify environment variables are loaded
Forecast widget empty:
- Ensure historical sales data exists (seeded)
- Check browser console for API errors
- Verify brand filtering isn't excluding all data
CRM panel not working:
- Confirm
NEXT_PUBLIC_STREAK_API_KEYis set - Test API key at
https://www.streak.com/api/v1/me - Check browser console for authentication errors
Charts not responsive:
- Test window resize behavior
- Check that Recharts is properly installed
- Verify mobile breakpoint logic (640px)
Set NODE_ENV=development to enable:
- React Query DevTools
- Detailed console logging
- Error boundary details
- Goal breakdown modal with account-level details
- Health indicator component for sell-through rates
- Advanced forecasting with seasonality detection
- Real-time data sync via Supabase subscriptions
- Mobile app companion for on-the-go access
- Integration with additional CRM platforms
- Automated goal setting based on historical performance
- Machine learning for improved forecasting accuracy
- Inventory optimization recommendations
- Documentation: Check
PROJECT_OVERVIEW.mdfor detailed architecture - Issues: Open GitHub issues for bugs or feature requests
- Supabase: Dashboard for database management
- React Query: DevTools for debugging queries
Built with Next.js 15, Supabase, React Query, Recharts, and TypeScript
RepOrder Dashboard MVP - Empowering sales reps with data-driven insights