# Check backend
curl http://localhost:8000/health
# Expected: {"status": "healthy"}
# Check Celery worker is active
ps aux | grep celery# Using curl
curl -X POST http://localhost:8000/api/v1/analysis/start \
-H "Content-Type: application/json" \
-d '{
"source_type": "user_story",
"source_data": "def add(a, b):\n return a + b"
}'
# Response:
# {"job_id": "xxxxx", "status": "PENDING", "created_at": "..."}curl http://localhost:8000/api/v1/analysis/xxxxx
# Wait a few seconds, then:
# Returns full analysis with generated testsimport requests
import time
# Submit analysis
response = requests.post(
'http://localhost:8000/api/v1/analysis/start',
json={
'source_type': 'user_story',
'source_data': '''
def divide(a, b):
if b == 0:
raise ValueError("Cannot divide by zero")
return a / b
'''
}
)
job_id = response.json()['job_id']
# Wait for completion
time.sleep(10)
# Get results
result = requests.get(f'http://localhost:8000/api/v1/analysis/{job_id}').json()
# View tests
for test in result['tests']:
print(f"Function: {test['target_function']}")
print(f"Test Type: {test['test_type']}")
print(f"Generated by: {test['generated_by']}")
print(f"Code:\n{test['content']}")// Submit analysis
const jobResponse = await fetch('http://localhost:8000/api/v1/analysis/start', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
source_type: 'user_story',
source_data: `
function calculateTotal(items) {
return items.reduce((sum, item) => sum + item.price, 0);
}
`
})
});
const { job_id } = await jobResponse.json();
// Wait and get results
await new Promise(resolve => setTimeout(resolve, 10000));
const resultResponse = await fetch(
`http://localhost:8000/api/v1/analysis/${job_id}`
);
const result = await resultResponse.json();
// Display tests
result.tests.forEach(test => {
console.log(`Function: ${test.target_function}`);
console.log(`Generated by: ${test.generated_by}`);
console.log(`Code:\n${test.content}`);
});{
"job_id": "8dd6c98f-9691-47e7-91c1-dde5890bbf02",
"status": "COMPLETED",
"structure": {
"languages": { "python": 2 },
"files": ["code.python"],
"functions": [
{ "name": "add", "file": "code.python" },
{ "name": "divide", "file": "code.python" }
]
},
"edge_cases": [...],
"tests": [
{
"id": "llm_test_add",
"test_type": "comprehensive",
"target_function": "add",
"language": "python",
"content": "import pytest...",
"file_path": "tests/test_add.py",
"generated_by": "demo" // "groq" when API key configured
}
],
"llm_provider": "groq",
"api_calls_made": 2
}| Field | Meaning |
|---|---|
id |
Unique test identifier |
test_type |
"comprehensive" or "edge_cases" |
target_function |
Which function this tests |
language |
"python" or "javascript" |
content |
The actual test code |
generated_by |
"demo" or "groq" |
Check:
# 1. Backend is running
curl http://localhost:8000/health
# 2. Celery worker is running
ps aux | grep celery
# 3. Redis is running
redis-cli ping # Should return PONGReason: Groq API key not configured
Fix:
- Get API key from https://console.groq.com
- Update backend/.env with your key
- Restart backend and Celery worker
Reason: Celery worker not processing tasks
Fix:
# Check worker status
ps aux | grep celery
# If not running, start it
cd backend
celery -A app.workers.celery_app worker --loglevel=info# Connect to SQLite
sqlite3 test.db
# List all analyses
SELECT id, status, json_array_length(results->'tests') as test_count
FROM analysis_jobs;
# View provider usage
SELECT
json_each.value->>'generated_by' as provider,
COUNT(*) as count
FROM analysis_jobs, json_each(analysis_jobs.results, '$.tests')
GROUP BY provider;
# Exit
.exitCheck Groq dashboard at https://console.groq.com/usage for:
- API calls count
- Token usage
- Rate limit status
-
Get Production API Key
# From https://console.groq.com # Create new key with name like "production-atcg"
-
Update Environment
# backend/.env GROQ_API_KEY=gsk_YOUR_PRODUCTION_KEY_HERE LLM_PROVIDER=groq GROQ_MODEL=llama-3.1-8b-instant -
Restart Services
# Restart backend pkill -f "uvicorn" python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 & # Restart Celery pkill -f "celery" celery -A app.workers.celery_app worker --loglevel=info &
-
Verify Integration
# Submit test analysis and check that generated_by = "groq" requests.get('...').json()['tests'][0]['generated_by'] # Should return: "groq"
Free tier limits: 30 requests/minute
For production:
- Upgrade Groq account for higher limits
- Implement queuing/batching
- Add retry logic (already built-in)
// In React/Next.js component
import { useState } from 'react';
export default function CodeAnalyzer() {
const [code, setCode] = useState('');
const [results, setResults] = useState(null);
const [loading, setLoading] = useState(false);
const analyzeCode = async () => {
setLoading(true);
// Submit analysis
const jobRes = await fetch('/api/v1/analysis/start', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
source_type: 'user_story',
source_data: code
})
});
const { job_id } = await jobRes.json();
// Poll for results
let result = null;
for (let i = 0; i < 60; i++) {
const res = await fetch(`/api/v1/analysis/${job_id}`);
if (res.status === 200) {
result = await res.json();
break;
}
await new Promise(r => setTimeout(r, 1000));
}
setResults(result);
setLoading(false);
};
return (
<div>
<textarea
value={code}
onChange={(e) => setCode(e.target.value)}
placeholder="Paste your code here..."
/>
<button onClick={analyzeCode} disabled={loading}>
{loading ? 'Analyzing...' : 'Generate Tests'}
</button>
{results && (
<div>
<h2>Generated Tests ({results.tests.length})</h2>
{results.tests.map(test => (
<div key={test.id}>
<h3>{test.target_function}</h3>
<p>Type: {test.test_type}</p>
<pre>{test.content}</pre>
</div>
))}
</div>
)}
</div>
);
}- GROQ_SETUP.md - Detailed setup guide
- GROQ_INTEGRATION_COMPLETE.md - Full technical details
- API Documentation - OpenAPI spec
- Check GROQ_SETUP.md for configuration issues
- Review Celery logs:
tail -f /tmp/celery_worker.log - Check database:
sqlite3 test.db - Enable debug logging in orchestrator
Happy testing! 🎉