QuipuEco’s backend is a lightweight FastAPI service that acts as the intelligence layer between the React PWA and Google Gemini. Every time a Lima resident photographs a piece of waste or speaks a question to the voice agent, one of two endpoints handles the heavy lifting:Documentation 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.
/clasificar runs the image through Gemini’s vision model and returns a structured recycling decision, while /chat maintains a stateless conversational turn and can instruct the frontend to navigate to the map or dashboard. Both endpoints are stateless — all session context (conversation history, classification result, and geolocation) is owned by the frontend and sent on each request.
Base URL
The frontend hardcodes the backend origin in bothImageCapture.jsx and AgenteVoz.jsx:
http://localhost:8000 by default. Update API_URL in both components if you deploy the backend to a remote host.
The frontend (Vite dev server) runs on
http://localhost:5173. FastAPI must
have CORS enabled for that origin, otherwise the browser will block all
requests. Add http://localhost:5173 to the allow_origins list in your
CORSMiddleware configuration.Authentication
There is no client-side authentication. The Google Gemini API key is stored exclusively on the server as theGEMINI_API_KEY environment variable and is never exposed to the browser. Requests from the frontend carry no tokens or headers beyond Content-Type.
AI Model
Both endpoints use Google Geminigemini-3.1-flash-lite — a multimodal model optimized for low-latency mobile use cases. /clasificar sends the image bytes alongside a structured classification prompt; /chat sends the conversation history and waste context alongside a conversational prompt. The backend constructs all prompts server-side (app/prompts.py) so the frontend never needs to know the prompt format.
Endpoints
POST /clasificar
Classify a waste image using Gemini vision. Accepts a multipart image
upload and returns material type, CO₂ impact, weight, recycling
instructions, and a TTS-ready voice response.
POST /chat
Send a conversational message to the QuipuEco voice agent. Accepts message
text, conversation history, waste context, and optional geolocation.
Returns a response and an optional app navigation action.
Interactive Docs
FastAPI auto-generates two interactive API explorers from the OpenAPI schema. Both are available immediately after starting the server:| Interface | URL |
|---|---|
| Swagger UI | http://localhost:8000/docs |
| ReDoc | http://localhost:8000/redoc |
Error Format
All errors follow FastAPI’s standarddetail envelope. The frontend reads this field directly:
500 Internal Server Error with a plain string detail message.
Architecture Overview
The following diagram shows how a classification request flows from the PWA to Gemini and back:useHistorial hook and persisted in localStorage.