Multi-tenant dashboard application for tracking business metrics with Google Sheets integration.
Status: π’ PRODUCTION READY - Core functionality complete and optimized
- β Projections & Pacing: Goal tracking with progress bars and performance summaries
- β Permission System Refactor: Migrated to feature-based permission system
- β Database Schema Update: New roles, userRoles, and profiles tables
- β Component Architecture: Updated all components to use new permission system
- β Backward Compatibility: Maintained compatibility during migration
- β Codebase Cleanup: Removed unused components and optimized structure
- β Metric Filtering: Fixed metric display and configuration system
- β Logging System: Replaced console.log with centralized logger
- Multi-tenant architecture with role-based access
- Dynamic Google Sheets synchronization
- Configurable metric tracking with real-time updates
- Goal tracking with projections and pacing insights
- Modern, responsive UI with Tailwind CSS
- Secure authentication and data isolation
- New Instance Setup Guide - Complete walkthrough for deploying to a new Supabase project and Google account
- Database Restore Guide - Complete guide for restoring from SQL backups
- AGENTS.md - Comprehensive architecture guide for AI agents and developers
- CHANGELOG.md - Detailed version history
- Secure user authentication with Supabase
- NEW: Feature-based permission system with granular control
- NEW: Role-based access control (admin, staff, client)
- NEW: Global admin flag for system-wide access
- Session persistence across page refreshes
- Password reset functionality
- Row Level Security (RLS) for multi-tenant data isolation
- User-configurable metric selection from Google Sheets columns
- Automatic metric discovery and configuration
- Real-time Google Sheets synchronization
- Metric type support (currency, percentage, count, number)
- Sheet-based metric organization with independent configurations
- Monthly goal target setting for key metrics
- Real-time progress tracking with visual indicators
- Over/under target arrows and color-coded progress bars
- Performance summary with ROAS and ATV calculations
- Synchronized with date filter for accurate tracking
- Clean, responsive design with Tailwind CSS
- Enhanced client dashboards with toggle functionality
- Error boundaries and network status monitoring
- Loading states and visual feedback
- Debounced interactions for better UX
- Automatic data synchronization
- Dynamic column detection
- Support for custom sheet names and ranges
- Error handling and retry mechanisms
- Fallback sync options
- Client-specific data isolation
- Configurable metric permissions
- Staff and client user roles
- Scalable database design
For a complete deployment guide, see New Instance Setup Guide
-
Install Dependencies
npm install
-
Environment Setup
# Copy example environment file cp .env.example .env.local # Edit .env.local and add your credentials: # - VITE_SUPABASE_URL # - VITE_SUPABASE_ANON_KEY # - VITE_GOOGLE_SERVICE_ACCOUNT_EMAIL # - VITE_GOOGLE_PRIVATE_KEY
-
Database Setup
# Link to your Supabase project npx supabase link --project-ref your-project-ref # Run all migrations npx supabase db push # Or restore from backup (see Database Restore Guide) node scripts/restore-database.js --target local --file supabase/backups/sql-scripts/complete_production_schema.sql
-
Development Server
npm run dev
-
Access the Application
- Open http://localhost:5173
- Sign up for an admin account
- Configure your first client and Google Sheet
src/
βββ components/ # React components
β βββ shared/ # Reusable shared components
β βββ UndeniableDashboard.tsx
β βββ ClientDashboard.tsx
β βββ UserManagement.tsx
β βββ MainLayout.tsx
βββ contexts/ # React contexts
β βββ AuthContext.tsx
β βββ AppContext.tsx
β βββ DashboardContext.tsx
βββ hooks/ # Custom React hooks
β βββ useUnifiedRouting.ts
β βββ useRoleBasedPermissions.ts
β βββ useTaskQueue.ts
βββ lib/ # Utility libraries
β βββ database.ts
β βββ logger.ts
β βββ supabase.ts
βββ types/ # TypeScript definitions
supabase/
βββ functions/ # Edge Functions
β βββ google-metric-sync/
β βββ invite-user/
βββ migrations/ # Database migrations
- UndeniableDashboard: Staff dashboard with full system access
- ClientDashboard: Client-specific dashboard with limited access
- UserManagement: Unified user and client management interface
- UnifiedMetricsDisplay: Reusable metrics display with filtering
- SheetSelector: Google Sheets selection component
- AuthContext: Authentication and user session management
- AppContext: Global application state and client management
- DashboardContext: Dashboard-specific state and sheet configuration
- google-metric-sync: Handles Google Sheets data synchronization
- invite-user: User invitation and access management
clients- Client information and configurationclient_tabs- Client-specific sheet configurationsdiscovered_metrics- Sheet metadata and metric configurations (JSONB)metric_entries- Historical metric dataunified_sync_status- Synchronization status tracking
- Row Level Security (RLS) enabled on all tables
- Client-specific data isolation
- Role-based access control
- Update the
AVAILABLE_METRICSarray inMetricSelector.tsx - Add corresponding database migration if needed
- Update Edge Function column mappings
- Test with sample data
# Create new migration
supabase migration new migration_name
# Apply migrations
supabase db push# Export database to SQL file
node scripts/export-database.js
# Restore from backup file (local)
node scripts/restore-database.js --target local --file supabase/backups/sql-scripts/complete_production_schema.sql
# Restore to production (requires confirmation)
node scripts/restore-database.js --target production --file backup.sql
# Validate backup file without restoring
node scripts/restore-database.js --dry-run --file backup.sqlSee Database Restore Guide for detailed instructions.
# Deploy Edge Function
supabase functions deploy sync-google-sheets-dynamicVITE_SUPABASE_URL- Supabase project URLVITE_SUPABASE_ANON_KEY- Supabase anonymous keyGOOGLE_SERVICE_ACCOUNT_EMAIL- Google Sheets service accountGOOGLE_PRIVATE_KEY- Google Sheets private key
- Create service account in Google Cloud Console
- Share spreadsheet with service account email
- Configure sheet structure with proper headers
- Set up metric configurations in dashboard
- Follow the existing code style and patterns
- Add tests for new functionality
- Update documentation and changelog
- Ensure all migrations are reversible
See CHANGELOG.md for detailed version history and changes.
[Add your license information here]
Built with React, TypeScript, Supabase, and Tailwind CSS