Web services that are used to enhance Triple Performance
π Interactive API Documentation: Automatic API documentation is included! See API_DOCUMENTATION.md for details.
This repository contains Python-based web services and scheduled workers for Triple Performance. The services are containerized using Docker and include:
- POST /translation/translate/{source_lang}/{dest_lang}/page - Translate page content between languages
- POST /fetch_transcripts/{page} - Get transcripts for a specific page
- GET / - Health check endpoint
- check-all-interwiki_links - Validates interwiki links (runs weekly via cron on Sunday at 2 AM)
- Docker
- Docker Compose
# Build the Docker image
docker-compose build
# Start the services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the services
docker-compose down# Build the Docker image
docker build -t tripleperformance-services .
# Run the container
docker run -p 8000:8000 tripleperformance-servicesInteractive documentation is automatically generated and available as soon as you start the service!
FastAPI provides beautiful, interactive API documentation out-of-the-box. No additional setup required.
Once the service is running, access the documentation at:
URL: http://localhost:8000/docs
The Swagger UI provides:
- β¨ Interactive API explorer - Try endpoints directly from your browser
- π Request/Response examples - See example data for all endpoints
- π Schema inspection - View detailed models and data structures
- π§ͺ Live testing - Execute API calls and see real responses
- π Copy-paste curl commands - Easy integration with command line
URL: http://localhost:8000/redoc
The ReDoc interface offers:
- π Clean, readable format - Professional documentation layout
- π Search functionality - Quickly find endpoints
- π¨οΈ Print-friendly - Great for PDF exports
- π± Responsive design - Works on all devices
- π¨ Better for presentations - Polished look for stakeholders
URL: http://localhost:8000/openapi.json
Machine-readable API specification:
- π€ API client generation - Use with Swagger Codegen, OpenAPI Generator
- π Integration tools - Import into Postman, Insomnia, etc.
- π API testing frameworks - Integrate with automated tests
- π Contract testing - Validate API implementations
All endpoints include:
- Detailed descriptions with markdown formatting
- Parameter examples showing valid inputs
- Response schemas with field descriptions
- Example requests and responses
- Tags for organization (Health, Translation, Transcripts)
- HTTP status codes for different scenarios
-
Start the service:
docker-compose up
-
Open your browser to:
http://localhost:8000/docs -
Try the "Health Check" endpoint:
- Click on
GET / - Click "Try it out"
- Click "Execute"
- See the live response!
- Click on
-
Test the Translation endpoint:
- Click on
POST /translation/translate/{source_lang}/{dest_lang}/page - Click "Try it out"
- Enter
enfor source_lang andfrfor dest_lang - Modify the request body if desired
- Click "Execute"
- Click on
- URL: http://localhost:8000/
- Method: GET
- Purpose: Verify service is running
curl http://localhost:8000/curl -X POST "http://localhost:8000/translation/translate/en/fr/page" \
-H "Content-Type: application/json" \
-d '{"content": {"text": "Hello World"}}'curl -X POST "http://localhost:8000/fetch_transcripts/example-page" \
-H "Content-Type: application/json" \
-d '{"options": {}}'tripleperformance-services/
βββ app/ # FastAPI application
β βββ __init__.py
β βββ main.py # Main application with API endpoints
βββ workers/ # Scheduled workers
β βββ __init__.py
β βββ check_interwiki_links.py # Interwiki links checker
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Docker image definition
βββ docker-entrypoint.sh # Container startup script
βββ requirements.txt # Python dependencies
βββ README.md # This file
To manually run the interwiki links checker:
# Inside the container
docker exec -it tripleperformance-services python /app/workers/check_interwiki_links.py
# Or from host (if you have Python and dependencies installed)
python workers/check_interwiki_links.py# View cron logs
docker exec -it tripleperformance-services tail -f /var/log/cron.logCurrently, no environment variables are required. Add them to docker-compose.yml as needed for your implementation.
The endpoints are currently scaffolded (implementation pending). To test the scaffolding:
# Test health check
curl http://localhost:8000/
# Test translation endpoint
curl -X POST "http://localhost:8000/translation/translate/en/fr/page" \
-H "Content-Type: application/json" \
-d '{}'
# Test transcripts endpoint
curl -X POST "http://localhost:8000/fetch_transcripts/test-page" \
-H "Content-Type: application/json" \
-d '{}'The following items are scaffolded and require implementation:
-
Translation Service Implementation
- Add translation logic in
/translation/translate/{source_lang}/{dest_lang}/page - Integrate with translation APIs or libraries
- Add translation logic in
-
Transcripts Service Implementation
- Add transcript retrieval logic in
/fetch_transcripts/{page} - Connect to data source
- Add transcript retrieval logic in
-
Interwiki Links Checker Implementation
- Add link validation logic in
workers/check_interwiki_links.py - Connect to Triple Performance database
- Implement link checking and reporting
- Add link validation logic in
See LICENSE file for details