Primeros pasos
1. Instalación
git clone https://github.com/eCondorDigital/exercise-engine.gitcd exercise-enginenpm install2. Configurar variables de entorno
cp .env.example .envEdita .env:
HTTP_PORT=4000TCP_PORT=4001TCP_HOST=0.0.0.0API_KEY=sk_default_dev_key_change_in_productionTTS_SERVICE_URL=http://tts-service:80003. Generar tu primera API Key
Opción A: Usar la key por defecto
La variable API_KEY en tu .env ya funciona:
sk_default_dev_key_change_in_production⚠️ Cámbiala en producción.
Opción B: Generar una nueva key vía API
Inicia el servidor:
npm run start:devLuego llama al endpoint de administración:
curl -X POST http://localhost:4000/api/v1/admin/keys \ -H "Content-Type: application/json" \ -d '{"name": "mi-app-frontend"}'Respuesta:
{ "key": "sk_a1b2c3d4e5f6...", "message": "Save this key securely. It will not be shown again."}Guarda la key inmediatamente. Nunca se mostrará de nuevo.
Opción C: Generar manualmente
node -e "console.log('sk_' + require('crypto').randomBytes(24).toString('hex'))"Luego configúrala en tu .env:
API_KEY=tu_key_generada4. Listar API keys activas
curl http://localhost:4000/api/v1/admin/keysRespuesta:
[ { "keyPreview": "sk_a1b2c...xyz9", "name": "mi-app-frontend", "createdAt": "2026-05-04T13:00:00.000Z", "lastUsedAt": "2026-05-04T13:05:00.000Z", "isActive": true }]5. Evaluar un ejercicio
curl -X POST http://localhost:4000/api/v1/exercises/evaluate \ -H "x-api-key: sk_your_api_key" \ -H "Content-Type: application/json" \ -d '{ "exerciseId": "ex_001", "area": "listening", "type": "multiple_choice", "answer": "B", "correctAnswer": "B", "difficulty": 2 }'Respuesta:
{ "correct": true, "score": 10, "feedback": "Correct!", "metadata": { "area": "listening", "type": "multiple_choice" }}6. Explorar API Docs
Abre tu navegador en:
http://localhost:4000/api/docsVerás la interfaz Swagger con:
- Todos los endpoints documentados
- Ejemplos de request/response
- Botón “Authorize” para agregar tu API key
- Testing interactivo (Try it out)
7. Correr con Docker
docker compose up -d --buildAmbos servicios (NestJS + TTS) corren juntos.
Siguientes pasos
- API Reference — Documentación completa de endpoints
- Exercise Types — Tipos de ejercicio soportados
- Grid Engines — Generación de Word Search y Crossword