Development Guide¶
This guide covers development workflows, coding standards, and best practices for AIEO.
Development Environment Setup¶
Prerequisites¶
- Python 3.9+
- Node.js 18+
- Docker and Docker Compose
- Git
Initial Setup¶
-
Clone and install:
-
Configure environment:
-
Start services:
Lightweight Setup (Scoring Engine Only)¶
If you only need the scoring engine (e.g., for batch auditing URLs), you can skip Docker, PostgreSQL, and Redis entirely:
This is sufficient to run run_audit.py and use the ScoringEngine and ContentParser classes directly from backend/app/services/.
Optional: Enable entity density scoring with spaCy:
Without spaCy, entity density (Pattern 2, worth 15 points max) scores 0 for all content. All other 9 patterns work without any external services.
Development Workflow¶
Backend Development¶
-
Activate virtual environment:
-
Run development server:
-
Run tests:
-
Format code:
-
Lint code:
Frontend Development¶
-
Install dependencies:
-
Run development server:
-
Build for production:
-
Run tests:
CLI Development¶
-
Install in development mode:
-
Test commands:
Code Standards¶
Python¶
- Style: PEP 8
- Type hints: Required for public APIs
- Line length: 100 characters
- Formatter: Black
- Linter: Ruff
- Docstrings: Google style
Example:
def score_content(content: str, format: str = "markdown") -> Dict[str, Any]:
"""
Score content against AIEO patterns.
Args:
content: Content to score
format: Content format ('markdown' or 'html')
Returns:
Dictionary with score, grade, and gaps
"""
...
TypeScript/React¶
- Style: ESLint + Prettier
- Type safety: Strict TypeScript
- Components: Functional with hooks
- Naming: PascalCase for components, camelCase for functions
Example:
interface AuditResult {
score: number;
grade: string;
gaps: Gap[];
}
export function AuditPage() {
const [result, setResult] = useState<AuditResult | null>(null);
...
}
Testing¶
Backend Tests¶
cd backend
pytest # Run all tests
pytest tests/test_scoring_engine.py # Run specific test
pytest -v # Verbose output
pytest --cov=app # With coverage
Frontend Tests¶
cd frontend
npm test # Run tests
npm test -- --watch # Watch mode
npm test -- --coverage # With coverage
Integration Tests¶
Database Migrations¶
Create Migration¶
Apply Migrations¶
Rollback¶
API Development¶
Adding New Endpoint¶
-
Create endpoint in
app/api/v1/: -
Add request/response models:
-
Update API documentation:
- Endpoints auto-document at
/docs - Add examples in docstrings
Debugging¶
Backend Debugging¶
# Run with debug logging
uvicorn app.main:app --reload --log-level debug
# Use Python debugger
import pdb; pdb.set_trace()
Frontend Debugging¶
- Use React DevTools
- Browser DevTools
- Console logging
Database Debugging¶
# Connect to database
docker-compose exec postgres psql -U aieo -d aieo
# View logs
docker-compose logs postgres
Git Workflow¶
Branch Naming¶
feature/- New featuresfix/- Bug fixesdocs/- Documentationrefactor/- Refactoringtest/- Tests
Commit Messages¶
Use Conventional Commits:
feat: add comparison table detection
fix: resolve scoring edge case
docs: update API documentation
refactor: improve content parser
test: add integration tests
Pull Request Process¶
- Create feature branch
- Make changes
- Write/update tests
- Update documentation
- Ensure tests pass
- Create PR with description
- Address review comments
- Merge after approval
Performance Optimization¶
Backend¶
- Use async/await for I/O operations
- Cache expensive operations
- Optimize database queries
- Use connection pooling
Frontend¶
- Code splitting
- Lazy loading
- Memoization
- Optimize re-renders
Common Tasks¶
Run Batch Audit on URL List¶
The quickest way to audit multiple URLs:
- Add URLs to
sites.txt(one per line) - Run the standalone audit script:
- Results are saved to a temp directory as JSON files (one per site +
summary.json)
Add New Pattern¶
- Update
scoring_engine.py - Add detection logic
- Update weight in
_calculate_total_score() - Add gap info in
_generate_gaps() - Update tests
- Update documentation (PATTERNS.md, CLI.md scoring table)
Add New Service¶
- Create service file in
app/services/ - Add tests
- Integrate with API
- Update documentation
Update Dependencies¶
# Backend
cd backend
pip list --outdated
pip install --upgrade package
# Frontend
cd frontend
npm outdated
npm update package
Troubleshooting¶
Common Issues¶
Backend won't start: - Check database connection - Verify environment variables - Check port availability
Frontend build fails: - Clear node_modules and reinstall - Check Node.js version - Verify dependencies
Tests fail: - Check test database setup - Verify environment variables - Check for port conflicts
Resources¶
Getting Help¶
- Check existing issues
- Review documentation
- Ask in discussions
- Open an issue with details