A comprehensive API for English-Yoruba translations, proverbs, and tone marking with AI-powered translation capabilities.
- β English β Yoruba dictionary with 10,000+ translations
- β AI-powered translations using OpenAI GPT-4o
- β Yoruba proverbs collection
- β Tone marking service for Yoruba text
- β RESTful API with comprehensive documentation
- β Docker containerization
- β CI/CD pipeline with GitHub Actions
- β Kubernetes deployment ready
- π Rate limiting and security features
- π Caching and performance optimization
- Python 3.9+
- Docker and Docker Compose
- PostgreSQL (for production)
- OpenAI API key (for AI translations)
-
Clone the repository
git clone https://github.com/yourusername/yoruba-language-api.git cd yoruba-language-api
-
Set up virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt pip install -r requirements-dev.txt # For development tools
-
Environment setup
cp .env.example .env # Edit .env with your configuration
-
Initialize database
python scripts/init_db.py
-
Run the server
python run.py # Or use uvicorn directly uvicorn app.main:app --reload
-
Build and run with Docker Compose
# Start all services (API, PostgreSQL, Redis, Nginx) docker-compose up -d # View logs docker-compose logs -f api # Stop services docker-compose down
-
Build Docker image manually
docker build -t yoruba-language-api . docker run -p 8000:8000 yoruba-language-api
# View all available commands
make help
# Development
make install # Install dependencies
make test # Run tests
make lint # Run linting
make format # Format code
make run # Run server locally
# Docker
make docker-build # Build Docker image
make docker-run # Start with Docker Compose
make docker-stop # Stop Docker Compose
make docker-clean # Clean up Docker resources
# CI/CD
make ci-check # Run all CI checks locally
make security # Run security checks
make coverage # Run tests with coverage
The application includes a production-ready Dockerfile with:
- Multi-stage build for optimization
- Non-root user for security
- Health checks
- Minimal base image (Python 3.11 slim)
Full-stack development environment with:
- API: FastAPI application
- PostgreSQL: Primary database
- Redis: Caching layer
- Nginx: Reverse proxy with SSL
Production-ready Kubernetes manifests in k8s/
:
- Deployment with 3 replicas
- Service and Ingress configuration
- ConfigMaps and Secrets
- Health checks and resource limits
- SSL/TLS termination
-
CI Pipeline (
ci.yml
)- Linting and code formatting
- Security checks (bandit, safety)
- Unit tests across Python versions
- Integration tests
- Docker image building
- Automated deployment
-
Release Pipeline (
release.yml
)- Triggered on version tags
- Docker image publishing
- GitHub releases
- Asset uploads
- Code Quality: flake8, black, isort, mypy
- Security: bandit, safety
- Testing: pytest with coverage
- Formatting: Pre-commit hooks
- Dependencies: Security updates
Automated code quality checks:
# Install pre-commit hooks
pre-commit install
# Run manually
pre-commit run --all-files
- Translation: English-Yoruba word pairs
- Proverb: Yoruba proverbs with meanings
- ToneMarking: Tone marking history and analysis
Populate with 10,000 translations:
# Generate translations dataset
python scripts/generate_translations.py
# Seed database (if script exists)
python scripts/seed_database.py
# Reset database
make db-reset
# Database shell
make db-shell
# View database status
make status
Variable | Description | Default |
---|---|---|
DATABASE_URL |
Database connection string | sqlite:///./yoruba.db |
API_KEY |
API authentication key | Required |
OPENAI_API_KEY |
OpenAI API key for AI translations | Optional |
AI_MODEL |
OpenAI model to use | gpt-4o |
DEBUG |
Enable debug mode | false |
HOST |
Server host | 0.0.0.0 |
PORT |
Server port | 8000 |
CORS_ORIGINS |
Allowed CORS origins | * |
# Production environment file
cp .env.example .env.prod
# Production Docker build
make prod-build
make prod-run
# Run all tests
pytest
# Run with coverage
pytest --cov=app --cov-report=html
# Run specific test categories
pytest -m "unit"
pytest -m "integration"
# Run linting
make lint
# Run security checks
make security
- Unit Tests:
tests/test_*.py
- Integration Tests: API endpoint testing
- Mock Services: AI service mocking for testing
GET /
- API informationGET /health
- Health checkGET /config
- Configuration details
GET /api/v1/translations
- List all translationsGET /api/v1/translations/{id}
- Get specific translationPOST /api/v1/translations
- Create new translationPUT /api/v1/translations/{id}
- Update translationDELETE /api/v1/translations/{id}
- Delete translationGET /api/v1/translate?word={word}&use_ai={true/false}
- Translate wordPOST /api/v1/translate
- Translate with POST request
GET /api/v1/ai/status
- Check AI service availabilityGET /api/v1/translate?use_ai=true
- Use AI for translation
GET /api/v1/proverbs
- List all proverbsGET /api/v1/proverbs/random
- Get random proverbPOST /api/v1/proverbs
- Add new proverb
POST /api/v1/tone-mark
- Add tone marks to textGET /api/v1/tone-mark
- Get tone marking historyPOST /api/v1/tone-mark/analyze
- Analyze text for tone marking
# Production build
docker build -t yoruba-language-api:prod .
# Run with environment file
docker run -d \
--name yoruba-api \
-p 8000:8000 \
--env-file .env.prod \
yoruba-language-api:prod
# Create namespace
kubectl create namespace yoruba-api
# Apply configurations
kubectl apply -f k8s/
# Check status
kubectl get all -n yoruba-api
- Development: Local Docker Compose
- Staging: Automated deployment on main branch
- Production: Manual deployment with approval
- API key authentication
- CORS configuration
- Rate limiting
- Input validation
- SQL injection prevention
- XSS protection headers
- Non-root Docker containers
- Kubernetes security contexts
- Health check endpoints
- Prometheus metrics (planned)
- Structured logging
- Error tracking with Sentry
- Performance monitoring
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
- Follow PEP 8 style guide
- Use type hints
- Write comprehensive tests
- Update documentation
- Run pre-commit hooks
- Maintain >80% test coverage
- Include unit and integration tests
- Mock external dependencies
- Test error conditions
- Core API structure
- Database models and schemas
- Translation endpoints
- AI translation integration
- Tone marking service
- Docker containerization
- CI/CD pipeline
- Kubernetes manifests
- Performance optimization
- Caching implementation
- Advanced search features
- User authentication system
- Translation memory
- Community contributions
- Mobile app
- Advanced analytics
- Multi-language support
-
Database Connection Errors
- Check
DATABASE_URL
in.env
- Ensure database service is running
- Verify network connectivity
- Check
-
AI Translation Failures
- Check
OPENAI_API_KEY
is valid - Verify API quota and billing
- Check network connectivity
- Check
-
Docker Issues
- Ensure Docker daemon is running
- Check port conflicts
- Verify image builds successfully
- Check the Issues page
- Review Discussions
- Create detailed bug reports with logs
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenAI for AI translation capabilities
- FastAPI community for the excellent framework
- Yoruba language experts and contributors
- Open source community for tools and libraries
Made with β€οΈ for the Yoruba language community