AndesAI - Troubleshooting Guide
✅ Checklist de Configuración
1. Backend Configuration
- Backend está ejecutándose en
http://localhost:8000 - Base de datos SQLite está accesible en
./andesops.db - Variables de entorno configuradas en
backend/.env:MERCADO_PUBLICO_TICKET=99B4CA8C-C1DF-4E3F-B5CF-C1672D432A91 GEMINI_API_KEY=AIzaSyBidQBGcitskZaJZDQXUDNNSMjlSTF7jhQ DATABASE_URL=sqlite:///./andesops.db
2. Frontend Configuration
- Frontend
.env.localtiene:NEXT_PUBLIC_API_BASE=http://localhost:8000 - Frontend está corriendo en desarrollo o producción
3. API Endpoints - Test Manual
Prueba estos endpoints en tu navegador o curl:
# Health check
curl http://localhost:8000/api/health
# Get tenders (busca en BD local)
curl "http://localhost:8000/api/tenders?skip=0&limit=10"
# Get tenders by keyword (busca en Mercado Público)
curl "http://localhost:8000/api/tenders?keyword=software"
# Scrape Compra Ágil (nuevo endpoint)
curl "http://localhost:8000/api/tenders/scrape?keyword=tecnologia"
# Get Purchase Orders (OC) - HOY
curl "http://localhost:8000/api/purchase-orders"
# Get Purchase Orders (OC) - Fecha específica
curl "http://localhost:8000/api/purchase-orders?date=06052026&status=todos"
🔧 Problemas Comunes
Problema: "Connection Error" en Market Monitor
Causas:
- Backend no está ejecutándose
- URL del API_BASE es incorrecta
- CORS bloqueado
Solución:
# 1. Inicia el backend
cd backend
python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
# 2. Verifica que esté respondiendo
curl http://localhost:8000/api/health
# 3. Si falla, revisa los logs del backend
Problema: Órdenes de Compra devuelven vacías
Causas:
- Ticket de Mercado Público expirado/inválido
- No hay OC publicadas hoy
- Error en la API de Mercado Público
Solución:
# Test directo de OC
curl "http://localhost:8000/api/purchase-orders"
# Test con fecha específica
curl "http://localhost:8000/api/purchase-orders?date=06052026"
# Verifica el ticket en backend/.env
echo $MERCADO_PUBLICO_TICKET # Debe mostrar el ticket
Problema: "Compra Ágil" no trae resultados
Causas:
- Endpoint de Mercado Público devolvió error
- Keyword no tiene resultados
- API returns 500 (sin datos disponibles)
Solución:
# Test del scraper
curl "http://localhost:8000/api/tenders/scrape?keyword=tecnologia"
# Si falla, activará fallback sintético
# Verifica logs del backend: look for "[Scraper]" messages
Problema: Frontend no conecta con Backend
Diagnóstico:
- Abre Developer Tools (F12)
- Ve a Network tab
- Intenta hacer una búsqueda
- Busca peticiones fallidas
Soluciones:
# Verify frontend .env.local
cat frontend/.env.local
# Debe mostrar: NEXT_PUBLIC_API_BASE=http://localhost:8000
# Rebuild frontend if needed
cd frontend
npm run build
npm start
# Check if API_BASE is used in network requests
# Debe ver requests a http://localhost:8000/api/*
📋 Logs útiles para debugging
Backend Logs:
cd backend
python -m uvicorn app.main:app --reload
# Look for these messages:
# "[Scraper] 📡 Fetching..." - Scraper activo
# "✅ Success" - Búsqueda exitosa
# "⚠️ API blocked" - Error en API externa
# "❌ Scraper failure" - Fallback a datos sintéticos
Frontend Logs:
// En Developer Tools Console (F12)
// Look for:
// [API] messages - Llamadas API
// [TenderSearch] - Búsquedas de tenders
// Connection errors - Problemas de conexión
🚀 Como iniciar el sistema completo
Opción 1: Desarrollo Local (Recomendado)
# Terminal 1 - Backend
cd backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
python -m uvicorn app.main:app --reload --port 8000
# Terminal 2 - Frontend
cd frontend
npm install
npm run dev
# Abre http://localhost:3000
Opción 2: Docker Compose
docker-compose up -d
# Backend en http://localhost:8000
# Frontend en http://localhost:3000
✨ Features que debería ver
Tender Search Tab
- ✅ Buscar por keyword
- ✅ Filtrar por status, org, fecha
- ✅ Compra Ágil scraping
Market Monitor Tab
- ✅ Ver órdenes de compra del día
- ✅ Filtrar por estado
- ✅ Mostrar montos totales
Data Flow
- Frontend → Backend (HTTP) → Mercado Público API → Response
📞 Si aún no funciona
- Verifica los logs en ambas terminales
- Asegúrate que el backend esté respondiendo a
/api/health - Verifica que
NEXT_PUBLIC_API_BASEsea exactamentehttp://localhost:8000 - Limpia cache del navegador (Ctrl+Shift+R)
- Reinicia ambos servicios