A TypeScript API for translating media articles with editorial guidelines review using Anthropic's Claude LLM.
- Translation service with LLM-powered editorial review
- Uses Anthropic's Claude API for intelligent text analysis
- Comprehensive editorial guidelines compliance checking
- RESTful API with Express.js
-
Install dependencies:
npm install
-
Copy the environment variables:
cp .env.example .env
-
Configure your environment variables in
.env:ANTHROPIC_API_KEY=your_actual_api_key_here # Redis Configuration (choose one approach) # Option A: Use Upstash Cloud Redis (Production) KV_REST_API_URL=https://your-upstash-redis.upstash.io KV_REST_API_TOKEN=your_upstash_token # Option B: Use Local Redis via Docker (Development) # These will be set automatically when using docker-compose # KV_REST_API_URL=http://localhost:8080 # KV_REST_API_TOKEN=local_dev_token -
Build the project:
npm run build
-
Start the server:
npm start
Reviews and translates media articles against editorial guidelines using Claude LLM.
Request Body:
{
"mediaArticle": {
"text": "Your article text here",
"title": "Article Title"
},
"editorialGuidelines": {
"tone": "professional",
"style": "journalistic",
"targetAudience": "general public",
"restrictions": ["no technical jargon"],
"requirements": ["maintain engaging tone"]
},
"destinationLanguages": ["es", "fr", "de"]
}Response:
{
"originalArticle": { ... },
"translations": [
{
"language": "es",
"translatedText": "...",
"reviewNotes": ["LLM-generated review comments"],
"complianceScore": 95.2
}
],
"processedAt": "2025-01-01T00:00:00.000Z"
}Health check endpoint.
This application uses Redis for task storage and can work with both local and cloud Redis instances.
For local development, use the included Docker Compose setup that provides a local Redis instance with Serverless Redis HTTP (SRH) proxy:
# Start local Redis and proxy
docker-compose up redis redis-proxy
# Or start everything including the app
docker-compose upThis setup includes:
- Redis: Local Redis server (port 6379)
- SRH Proxy: HTTP proxy that makes local Redis compatible with Upstash SDK (port 8080)
- App: Your application with environment variables pre-configured
The proxy allows you to use the same @upstash/redis SDK for both local and production environments.
For production, set these environment variables to your Upstash Redis credentials:
KV_REST_API_URL=https://your-upstash-redis.upstash.io
KV_REST_API_TOKEN=your_upstash_tokenThe application supports multiple environment variable names for flexibility:
KV_REST_API_URLorUPSTASH_REDIS_REST_URLKV_REST_API_TOKENorUPSTASH_REDIS_REST_TOKEN
npm run dev- Start development server with hot reloadnpm run build- Build TypeScript to JavaScriptnpm run typecheck- Run TypeScript type checking
When running tests, you can use the local Redis setup:
# Start Redis services
docker-compose up redis redis-proxy -d
# Run tests with local Redis
npm test