About the Project

💡 Inspiration

E-commerce returns are a logistical and environmental nightmare. Millions of perfectly good, open-box items are shipped back to central warehouses every day, resulting in massive reverse-logistics costs and thousands of tons of unnecessary carbon emissions.

We realized that while someone in an apartment is returning a new laptop, someone two blocks away might be looking to buy that exact model at a discount. We were inspired to build a system that connects these two endpoints directly.


🚀 What it does

Re-Route is a hyper-local circular logistics engine. Instead of sending returned e-commerce products back to a distant warehouse, Re-Route intercepts them and immediately lists them for a hyper-local flash sale (typically a 48-hour window) in the same neighborhood.

Workflow

  • The Returner (User A) initiates a return, uploads a photo, and gets a guaranteed 100% refund.
  • The Buyer (User B) sees local returned items at a flat 30% discount with hyper-fast local delivery.
  • The Delivery Agent picks up the item from User A and hands it directly to User B using a strict Two-Factor OTP verification system.

The core business and environmental logic is driven by the following economic equation:

[ Net_Savings = (Cost_{WarehouseReturn} + Emission_{Penalty}) - (Discount_{Local} + Cost_{LocalDelivery}) ]

As long as the net savings remain positive, the platform stays highly profitable while reducing the carbon footprint to near zero.


⚙️ How we built it

We used a modern, scalable tech stack:

  • Frontend: React + TypeScript
  • Styling: Tailwind CSS + Radix UI
  • Backend & Database: Supabase (PostgreSQL)

We mapped complex database relations between Users, Products, and Orders to maintain a single source of truth across the platform.

We also utilized an AI-powered development environment called MeDo to accelerate UI/UX prototyping and boilerplate generation, allowing us to focus more deeply on state management and business logic.


🚧 Challenges we ran into

Building a three-sided marketplace involving Seller, Buyer, and Admin/Delivery Agent introduced several complex synchronization and security challenges.

1. Silent Trigger Failures & Row Level Security (RLS)

When a buyer purchased an item, our database triggers initially failed to update the product status to "Sold Out".

We discovered that Supabase’s strict Row Level Security (RLS) policies were blocking buyers from modifying seller-owned records.

Solution

We redesigned our PostgreSQL triggers to run as SECURITY DEFINER, enabling the system to securely bypass RLS while still maintaining database integrity and controlled permissions.


2. Real-time State Synchronization

We needed the marketplace to instantly reflect product availability changes across multiple dashboards without requiring a page refresh.

Requirements

  • Purchased items should immediately appear as "SOLD OUT" on the marketplace.
  • Seller dashboards should instantly update to "Sold - Awaiting Pickup".
  • Buyers and sellers should receive synchronized live updates.

Solution

We implemented concurrent real-time state handling using Supabase Realtime WebSockets.


3. Secure Handover Logic

Designing a secure and foolproof handover mechanism was another major challenge.

System Design

  • Sellers receive a Pickup OTP
  • Buyers receive a Delivery OTP
  • Neither user can access the OTP verification input fields
  • Only the Delivery Agent can verify and complete the transaction

This ensured secure item transfer and prevented fraudulent confirmations.


🎓 What we learned

This project taught us that in e-commerce systems, the real complexity lies far beyond the UI.

We significantly improved our understanding of:

  • PostgreSQL triggers
  • Database joins and relational modeling
  • Real-time synchronization using WebSockets
  • Concurrent state management
  • Secure marketplace architecture
  • Debugging complex Row Level Security (RLS) policies in cloud databases

Most importantly, we learned that database integrity and state management are the true backbone of scalable commerce platforms.

Built With

  • built-with-frontend-framework:-react
  • radix-ui
  • react-hooks-(usestate
  • routing-&-state:-react-router
  • shadcn/ui-icons:-lucide-react-backend-&-database:-supabase-(postgresql)-ai-development-engine:-medo-(for-rapid-prototyping-&-logic-acceleration)-routing-&-state:-react-router
  • typescript
  • vite-styling-&-ui:-tailwind-css
Share this project:

Updates