A high-performance, containerized language detection microservice built with Rust, Actix-Web, and the Lingua library. Detects over 75 languages with high accuracy and low latency.
- 🔍 Accurate Detection: Supports 75+ languages with confidence scoring
- ⚡ High Performance: Built with Rust for exceptional speed and low memory usage
- 🐳 Container Ready: Full Docker support with multi-stage builds
- 📊 JSON API: Simple RESTful interface with detailed response format
- 🔒 Production Ready: Proper error handling and logging
- Docker and Docker Compose
- or Rust 1.88+ toolchain
- Clone the repository:
git clone https://github.com/101t/lang_detect --depth 1 -b master
cd language-detection-service- Start the service:
docker-compose up -d- Test the service:
curl -X POST -H "Content-Type: application/json" \
-d '{"text": "Bonjour, comment allez-vous?"}' \
http://localhost:8080/predict- Install Rust:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh- Build and run:
cargo build --release
cargo runPOST /predict
curl -X POST -H "Content-Type: application/json" \
-d '{"text": "Your text to analyze here"}' \
http://localhost:8080/predict{
"language": "French",
"confidence": 0.95,
"is_reliable": true
}language: Detected language name (e.g., "French", "English")confidence: Confidence score between 0.0 and 1.0is_reliable: Boolean indicating if detection is reliable (confidence > 0.75)
version: '3.8'
services:
language-detection:
build: .
ports:
- "8080:8080"
environment:
- RUST_LOG=info
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8080/health_check"]
interval: 30s
timeout: 10s
retries: 3docker build -t language-detection-service .docker run -p 8080:8080 language-detection-serviceThe service supports the following environment variables:
| Variable | Default | Description |
|---|---|---|
RUST_LOG |
info |
Logging level (error, warn, info, debug, trace) |
PORT |
8080 |
HTTP server port |
The service detects a wide range of languages including:
- English, Spanish, French, German, Italian
- Chinese, Japanese, Korean
- Arabic, Hindi, Russian
- And many more (75+ total)
.
├── src/
│ └── main.rs # Application entry point
├── Cargo.toml # Rust dependencies
├── Dockerfile # Container configuration
├── docker-compose.yml # Service orchestration
└── Makefile # Build shortcuts
cargo build
cargo runcargo test
make testThe service is optimized for:
- Low latency (< 10ms for most requests)
- High throughput (> 1000 req/sec on modest hardware)
- Minimal memory footprint (~20MB RAM)
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Actix-Web for the powerful web framework
- Lingua for the accurate language detection
- Rust for the memory-safe language
If you have any questions or issues, please open an issue on the GitHub repository.
Language Detection Service - Fast, accurate language detection as a microservice. Built with ❤️ using Rust.