Skip to content

Getting Started

1. Installation

Ventana de terminal
git clone https://github.com/eCondorDigital/exercise-engine.git
cd exercise-engine
npm install

2. Configure environment variables

Ventana de terminal
cp .env.example .env

Edit .env:

HTTP_PORT=4000
TCP_PORT=4001
TCP_HOST=0.0.0.0
API_KEY=sk_default_dev_key_change_in_production
TTS_SERVICE_URL=http://tts-service:8000

3. Generate your first API Key

Option A: Use the default key

The API_KEY variable in your .env already works:

sk_default_dev_key_change_in_production

⚠️ Change it in production.

Option B: Generate a new key via API

Start the server:

Ventana de terminal
npm run start:dev

Then call the admin endpoint:

Ventana de terminal
curl -X POST http://localhost:4000/api/v1/admin/keys \
-H "Content-Type: application/json" \
-d '{"name": "my-app-frontend"}'

Response:

{
"key": "sk_a1b2c3d4e5f6...",
"message": "Save this key securely. It will not be shown again."
}

Save the key immediately. It will never be shown again.

Option C: Generate manually

Ventana de terminal
node -e "console.log('sk_' + require('crypto').randomBytes(24).toString('hex'))"

Then set it in your .env:

API_KEY=your_generated_key

4. List active API keys

Ventana de terminal
curl http://localhost:4000/api/v1/admin/keys

Response:

[
{
"keyPreview": "sk_a1b2c...xyz9",
"name": "my-app-frontend",
"createdAt": "2026-05-04T13:00:00.000Z",
"lastUsedAt": "2026-05-04T13:05:00.000Z",
"isActive": true
}
]

5. Evaluate an exercise

Ventana de terminal
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
}'

Response:

{
"correct": true,
"score": 10,
"feedback": "Correct!",
"metadata": {
"area": "listening",
"type": "multiple_choice"
}
}

6. Explore API Docs

Open your browser at:

http://localhost:4000/api/docs

You’ll see the Swagger UI with:

  • All endpoints documented
  • Request/response examples
  • “Authorize” button to add your API key
  • Interactive testing (Try it out)

7. Run with Docker

Ventana de terminal
docker compose up -d --build

Both services (NestJS + TTS) run together.

Next steps