Inspiration

Arca Continental moves millions of orders every month across México, Ecuador, Perú, and Argentina. But a silent problem erodes trust on both sides of the supply chain: products ordered by a store or restaurant sometimes arrive substituted with a different SKU, flavor, or size, completely without warning.

For a small store owner (tendero), this is not a minor inconvenience. It can mean running out of a key product on a busy day or receiving items they cannot sell. For Arca Continental, it means customer dissatisfaction that is hard to trace back to its root cause.

We wanted to give the small business owner the same visibility that large retailers enjoy: to know before the truck arrives.


What it does

Order Rescue is a B2B web app for store owners and restaurateurs who buy from Arca Continental. It delivers three core capabilities:

  • Order Tracker: Paste your order ID and instantly see which product lines are at risk of substitution. Results are color coded by risk level (Verde, Amarillo, Rojo) along with the most probable replacement product for each.
  • Order Simulator: Do you lack an active order? Build your list, select your country, and verify availability before committing. The simulator predicts substitution probability per product using historical data from your distribution zone.
  • Market Alerts: An interactive choropleth map of Latin America showing substitution risk by country, plus ranked lists of the most frequently substituted products and the most common swap pairs across the network.

An AI assistant powered by Groq and LLaMA 3.3 70B with Gemini 2.0 Flash as a fallback answers questions in plain Spanish. Expect no jargon and no codes, just live data from the system.


How we built it

  • Frontend: NextJS 14 App Router with tRPC and Tailwind CSS 3. It is fully responsive with a sidebar nav on desktop and a bottom nav on mobile. It ships as a PWA with a Service Worker for offline support.
  • Auth: NextAuthJS v4 with Google OAuth using JWT sessions. No database adapter needed.
  • Data Layer: MongoDB Atlas M0 with five collections: EDA aggregates, scoring lookup, semaforo risk summary, and orders. A LightStore pattern keeps hot data cached in process memory to avoid repeated Atlas round trips.
  • Scoring Model: Each product line gets a risk score from a three tier weighted formula. When historical data exists for a warehouse and product combination, we use the direct lookup. Otherwise, we fall back to a weighted mix: 50% global prior (5%) + 20% product level substitution rate + 30% warehouse level substitution rate. This ensures the score degrades gracefully instead of failing hard.
  • Map: react simple maps v3 with a local TopoJSON file for offline safety, using a Natural Earth projection centered on Latin America.
  • Chatbot: Lightweight RAG where context is assembled from live EDA data (top substituted products and most frequent swap pairs) and injected into the system prompt. No vector database is needed at this scale.

Challenges we ran into

  • Warehouse Selection: Displaying 178 distribution centers in a flat dropdown was completely unusable. We built a searchable picker component and later replaced the whole concept with country based auto detection so users never see warehouse codes at all.
  • ID Collision: Multiple logical orders share the same order ID in the source data. We had to detect and surface ambiguity gracefully rather than silently returning wrong results.
  • Missing Types: react simple maps v3 ships without TypeScript types. We authored a custom declaration file to unblock the build.

Accomplishments that we are proud of

  • Graceful Degradation: A scoring system that degrades gracefully across three tiers. When there is no order history for a product and warehouse pair, it falls back to product level data, then warehouse level data, then a global prior. Never a hard failure.
  • Clean UX: A fully client facing UX where no internal terminology leaks through to the end user.
  • Auto Detection: The simulator auto detects the user distribution zone from either a previously searched order for exact accuracy or their country selection for a statistical default. The user never has to know their warehouse code.
  • Offline Capability: A PWA that works offline. The map and cached data are fully usable without network.

What we learned

  • Designing for end users like tenderos is a completely different challenge than building for analysts. Removing information is sometimes harder than adding it.
  • A lightweight RAG with live data injection can outperform a fine tuned model for narrow structured domains and costs nothing.
  • MongoDB Atlas M0 free tier is enough for a hackathon if you cache aggressively and avoid N plus 1 queries.
  • Statistical fallback hierarchies make machine learning adjacent features robust without needing a full machine learning pipeline.

What is next for Order Rescue

  • Push Notifications: Alert the client 24 hours before delivery if high risk substitutions are detected on their active order.
  • Per Client Personalization: Once a user order history is linked to their account, the simulator uses their exact warehouse and product mix instead of country defaults.
  • Substitution Acceptance Flow: Let the client pre approve or reject probable substitutions before the order ships, reducing returns and friction.
  • Scale: Expand to more SKUs and regions. The scoring model is data agnostic and can be retrained as new countries or product lines are added.

Built With

  • google-gemini-2.0-flash
  • google-oauth
  • groq
  • llama-3.3-70b
  • mongodb-atlas
  • next.js-14
  • nextauth.js
  • react-18
  • react-simple-maps
  • service-worker
  • t3
  • tailwind-css-3
  • trpc
  • typescript
  • vercel
  • web-app-manifest
  • world-atlas-topojson
Share this project:

Updates