A comprehensive web application that uses machine learning to predict e-commerce return probabilities, helping businesses reduce return costs and improve customer satisfaction.
π Status: Automated CI/CD Pipeline Active - Deploys to Vercel (Frontend) + Railway (Backend)
- AI-Powered Predictions: Advanced ML models with 98.5% accuracy
- Email Authentication: Complete auth system with email confirmation
- Custom Email Templates: Beautiful, responsive email templates
- Real-time Analytics: Comprehensive dashboard with insights
- Data Management: CSV upload and processing capabilities
- Responsive Design: Works perfectly on all devices
- Secure Backend: Supabase with Row Level Security
- React 19 with Vite
- Tailwind CSS for styling
- React Router for navigation
- Heroicons for icons
- Supabase JS for backend integration
- Supabase (PostgreSQL, Auth, Storage, Real-time)
- Custom Email Templates with Go Templates
- Row Level Security for data protection
- Real-time subscriptions
- Node.js 18+
- npm or yarn
- Supabase CLI (for local development)
git clone <your-repo-url>
cd ecommerce-return-predictioncd frontend
npm install- Install Supabase CLI:
npm install -g @supabase/cli- Initialize Supabase:
cd frontend
supabase init- Start local Supabase:
supabase start- The CLI will output your local connection details. Copy them to
.env.local:
cp .env.example .env.local
# Edit .env.local with your local Supabase credentials- Create a new project at supabase.com
- Get your project URL and anon key from Settings β API
- Create
.env.local:
VITE_SUPABASE_URL=https://your-project-id.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-keyIf using Supabase CLI:
supabase db resetIf using cloud Supabase, run the SQL from supabase/migrations/20241225000001_initial_schema.sql in the SQL editor.
The custom email templates are already configured in config.toml. If using local development, they'll work automatically. For production, update the templates in your Supabase dashboard.
npm run devThe app will be available at http://localhost:5173
The application includes custom email templates for:
- Sign-up Confirmation: Welcome email with email verification
- Password Reset: Secure password reset with branded design
- Magic Link: Passwordless login option
Templates are responsive and include:
- Beautiful branding with gradients
- Security information
- Mobile-friendly design
- Clear call-to-action buttons
Email templates are located in supabase/templates/:
confirmation.html- Sign-up confirmationrecovery.html- Password resetmagic_link.html- Magic link login
Templates use Go template syntax with variables like:
{{ .SiteURL }}- Your site URL{{ .TokenHash }}- Auth token hash{{ .Email }}- User's email address{{ .RedirectTo }}- Redirect URL after auth
- User fills out registration form
- System creates account in Supabase
- Confirmation email sent with custom template
- User clicks confirmation link
- Redirected to dashboard after verification
The email templates work in both development and production by using:
- Local development:
http://localhost:5173 - Production: Your configured production domain
- Confirmation required:
enable_confirmations = true - Secure password changes:
secure_password_change = true - Rate limiting: 60 seconds between emails
- profiles: User profile information
- predictions: ML prediction results and history
- data_uploads: Uploaded dataset tracking
- Row Level Security (RLS) enabled on all tables
- Users can only access their own data
- Automatic profile creation on signup
Create production environment variables:
VITE_SUPABASE_URL=https://your-production-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-production-anon-keyIn your production Supabase project:
- Update Auth URLs: Add your production domain to additional redirect URLs
- Configure Email Templates: Upload custom templates via API or dashboard
- Set Site URL: Update to your production domain
- Run Migrations: Execute the SQL migrations
npm run build
# Deploy dist/ folder to your hosting providerEnsure email templates use your production domain:
href="{{ .SiteURL }}/auth/confirm?token_hash={{ .TokenHash
}}&type=email&next=/dashboard"- Real-time statistics and metrics
- Recent activity feed
- Quick action buttons
- Performance indicators
- Interactive form with all ML model inputs
- Real-time prediction results
- Confidence scores and risk levels
- Recommendation engine
- Monthly trend analysis
- Category-wise return rates
- Model performance metrics
- Exportable reports
- Drag-and-drop CSV upload
- Data schema validation
- Upload history tracking
- Sample data downloads
- Use local development with Supabase CLI
- Check email in Inbucket (usually http://127.0.0.1:54324)
- Test all auth flows: signup, signin, password reset
All major UI components are modular:
PredictionForm.jsx- ML prediction interfaceAnalyticsDashboard.jsx- Analytics and chartsDataUpload.jsx- File upload and managementProtectedRoute.jsx- Authentication guard
Use Supabase client for all database operations:
import { client } from "../supabase/client";
const { data, error } = await client
.from("predictions")
.select("*")
.eq("user_id", user.id);-
Email confirmation not working
- Check
site_urlin config.toml - Verify
additional_redirect_urlsincludes your domain - Ensure email templates have correct URLs
- Check
-
CORS errors
- Verify Supabase URL and keys
- Check additional_redirect_urls configuration
-
Database permissions
- Ensure RLS policies are correctly set
- Check user authentication state
-
Email templates not updating
- Restart Supabase:
supabase stop && supabase start - Clear browser cache
- Check template file paths in config.toml
- Restart Supabase:
// Make a prediction
const prediction = await client.from("predictions").insert({
product_category: 1,
product_price: 99.99,
// ... other fields
});// Update user profile
const { data, error } = await client
.from("profiles")
.update({
first_name: "John",
last_name: "Doe",
company: "Acme Inc",
})
.eq("id", user.id);- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is licensed under the MIT License.
For support and questions:
- Check the troubleshooting section
- Review Supabase documentation
- Open an issue on GitHub
ReturnPredict - Reducing e-commerce returns with AI π