QuipuEco’s image classification pipeline is the core of the application. When a user photographs or uploads a waste item, theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/davidmpizarro/QuipuEco-Hackaton/llms.txt
Use this file to discover all available pages before exploring further.
ImageCapture component sends the image to a FastAPI backend that invokes Google Gemini’s vision model. Within seconds the model returns a structured JSON payload that drives the entire result view — from the material category badge and container color to the CO₂ savings estimate, preparation instructions, and the text that the voice agent reads aloud. The resultado.respuesta_voz field is consumed by App.jsx to seed the voice agent’s opening greeting, so users can immediately ask follow-up questions without re-describing the item. The classification is also saved to localStorage before the result view renders, ensuring it is captured in the Impact Dashboard history even if the user navigates away immediately.
How Classification Works
Select or capture an image
The user picks a file from their device or activates the environment-facing camera. The
ImageCapture component accepts JPG, PNG, and WEBP files up to 10 MB. Drag-and-drop is supported on the upload tab.Preview and confirm
After selection the image is rendered in a full-bleed preview panel. A “Clasificar Residuo” button becomes available; a “Volver” button lets the user discard and start over without making a network request.
POST /clasificar
Tapping the classify button calls
POST /clasificar as multipart/form-data with the file in a field named file. A scanning overlay animation plays while the request is in-flight.Gemini vision analysis
The FastAPI backend forwards the image to Google Gemini’s vision model together with a system prompt that enforces the eight-category taxonomy and the JSON response schema. The model returns a single JSON object.
Result rendered
The frontend receives the JSON, calls
agregarRegistro(resultado, imagen) to persist the classification to localStorage, then transitions to the ClassificationResult view. App.jsx’s handleResult function immediately invokes SpeechSynthesis with respuesta_voz (falling back to a generic description if the field is absent) — ClassificationResult itself does not call SpeechSynthesis directly.API Endpoint
ImageCapture.jsx:
API_URL is hardcoded to http://localhost:8000 in ImageCapture.jsx. The FastAPI backend must be running at that address before the PWA is used. Update the constant — or wire it to a VITE_API_URL env variable — before deploying to any non-local environment.Classification Result JSON
The frontend consumes the following fields from the response object.ClassificationResult.jsx reads resultado.nombre, resultado.tipo, resultado.co2_evitado_kg, resultado.peso_estimado_kg, resultado.instrucciones, resultado.punto_acopio, and resultado.consejo directly. The resultado.respuesta_voz field is read by App.jsx to initialise the voice agent greeting.
| Field | Type | Description |
|---|---|---|
nombre | string | Human-readable name of the identified object |
tipo | string | Material category key — one of the eight supported values |
co2_evitado_kg | number | Estimated CO₂ savings in kilograms if the item is recycled correctly |
peso_estimado_kg | number | Estimated weight of the item in kilograms |
instrucciones | string | Step-by-step preparation instructions for the Lima waste system |
punto_acopio | string | Recommended collection network ("Tiendas Tambo" or "Centro Verde Municipal") |
consejo | string | One eco-tip shown in the green advice card |
respuesta_voz | string | Text read aloud immediately by App.jsx’s handleResult via SpeechSynthesis when the result arrives — ClassificationResult does not call SpeechSynthesis directly |
Supported Waste Categories
TheClassificationResult component maps each tipo value to a visual theme via TIPO_CONFIG. All eight categories, their container colors, and display labels are shown below.
🧴 Plástico
Container: Amarillo 🟡
Bottles, bags, packaging, PET containers. Collected at Tambo stores.
Bottles, bags, packaging, PET containers. Collected at Tambo stores.
📦 Papel / Cartón
Container: Azul 🔵
Cardboard boxes, newspapers, office paper. Collected at Tambo stores.
Cardboard boxes, newspapers, office paper. Collected at Tambo stores.
🍶 Vidrio
Container: Verde 🟢
Bottles, jars, glass containers. Collected at Centro Verde Municipal.
Bottles, jars, glass containers. Collected at Centro Verde Municipal.
🥬 Orgánico
Container: Naranja 🟠
Food scraps, fruit peels, garden waste. Collected at Centro Verde Municipal.
Food scraps, fruit peels, garden waste. Collected at Centro Verde Municipal.
🥫 Metal
Container: Amarillo 🟡
Cans, aluminium foil, metal lids. Collected at Tambo stores.
Cans, aluminium foil, metal lids. Collected at Tambo stores.
📱 Electrónico
Container: Morado 🟣
Phones, batteries, cables, circuit boards. Collected at Centro Verde Municipal.
Phones, batteries, cables, circuit boards. Collected at Centro Verde Municipal.
☣️ Peligroso
Container: Rojo 🔴
Chemicals, paint, solvents, fluorescent bulbs. Collected at Centro Verde Municipal.
Chemicals, paint, solvents, fluorescent bulbs. Collected at Centro Verde Municipal.
🗑️ No Reciclable
Container: Gris ⚫
Contaminated waste that cannot be recovered. Standard trash disposal.
Contaminated waste that cannot be recovered. Standard trash disposal.
Capture Modes
TheImageCapture component exposes two tabs that share the same classification flow after an image is selected.
Upload
Drag-and-drop zone or a “Buscar en dispositivo” file picker button. Accepts
image/* (JPG, PNG, WEBP) up to 10 MB. An <input type="file" accept="image/*"> element is hidden and triggered programmatically via a ref.Camera
Activates the device rear camera via
navigator.mediaDevices.getUserMedia({ video: { facingMode: "environment" } }). A live viewfinder renders with a sci-fi scan-line overlay and corner brackets. Tapping “Capturar Foto” draws the current frame to an off-screen canvas and exports it as a JPEG blob at 0.85 quality.Category Reference
Plástico — Yellow container 🟡
Plástico — Yellow container 🟡
Includes PET bottles, HDPE jugs, plastic bags, polystyrene trays, and blister packaging. Before disposing, rinse clean, remove caps, and flatten to save space. Accepted directly at the Tambo counter — no appointment needed.
Papel / Cartón — Blue container 🔵
Papel / Cartón — Blue container 🔵
Newspapers, magazines, office paper, cardboard boxes, and paper bags. Must be dry and clean — greasy pizza boxes or food-soiled paper cannot be recycled. Flatten boxes before delivery.
Vidrio — Green container 🟢
Vidrio — Green container 🟢
Glass bottles, jars, and containers of any color. Remove lids (recycle separately as metal), rinse out, and do not break — broken glass is a safety hazard at collection points. Ceramics and tempered glass are not accepted.
Orgánico — Orange container 🟠
Orgánico — Orange container 🟠
Fruit and vegetable scraps, coffee grounds, eggshells, garden trimmings. Centro Verde processes these for composting. Meat, dairy, and cooked food should be checked with your local center before deposit.
Metal — Yellow container 🟡
Metal — Yellow container 🟡
Aluminium cans, tin cans, metal lids, and aluminium foil. Rinse cans, remove labels if possible, and crush to reduce volume. Accepted alongside plastic at Tambo stores.
Electrónico (RAEE) — Purple container 🟣
Electrónico (RAEE) — Purple container 🟣
Mobile phones, laptops, cables, batteries, chargers, and circuit boards. These are RAEE (Residuos de Aparatos Eléctricos y Electrónicos) and require certified handling. Never place them in general trash — they contain heavy metals. Always take to Centro Verde Municipal.
Peligroso — Red container 🔴
Peligroso — Red container 🔴
Paints, motor oil, solvents, pesticides, fluorescent tubes, and medical waste. These residues need authorized hazardous-waste handlers. Keep in original sealed containers. Centro Verde Municipal coordinates pickup with certified gestores.
No Reciclable — Grey container ⚫
No Reciclable — Grey container ⚫
Items that cannot be recovered in Lima’s current infrastructure: dirty multi-layer packaging, contaminated materials, and composite plastics. Dispose of in standard trash. The item still earns 2 eco points for the correct identification.