Where language meets intelligence.
Slango is a full-stack AI translation application supporting 15 languages with automatic language detection, real-time translation, and a modern glassmorphic UI β powered by Hugging Face HelsinkiβNLP models (no Google Cloud credentials required).
API Docs Β· Report Bug Β· Request Feature
| Feature | Description |
|---|---|
| π Auto Language Detection | Detects the source language automatically β no manual selection needed |
| π 15 Languages Supported | English, Spanish, French, German, Italian, Portuguese, Russian, Japanese, Korean, Chinese, Arabic, Hindi, Bengali, Tamil, Telugu |
| β‘ Async Translation Engine | Non-blocking async API calls with configurable retry logic and linear backoff |
| π‘οΈ Rate Limiting | Per-IP rate limiting (10 req / 60 s by default) to prevent abuse |
| π Request Tracing | Every request gets a unique ID with structured duration logging |
| π Fallback Mode | Gracefully degrades when API credentials are unavailable (dev-friendly) |
| π©Ί Health Endpoint | /api/v1/health for uptime monitoring and deployment checks |
| π Interactive API Docs | Auto-generated Swagger UI at /docs and ReDoc at /redoc |
| π¨ Modern UI | Glassmorphic React frontend built with Vite for near-instant HMR |
| Technology | Version | Purpose |
|---|---|---|
| Python | 3.11 | Runtime |
| FastAPI | 0.115 | REST API framework |
| Uvicorn | 0.30 | ASGI server |
| Pydantic v2 | 2.9 | Data validation & settings |
| pydantic-settings | 2.5 | .env-based config management |
| pydantic-core | 2.23 | Pinned for pre-built wheel compatibility |
| httpx | 0.27 | Async HTTP client |
| langdetect | 1.0.9 | Offline language detection fallback |
| Google Cloud Translate | v2 | Primary translation engine |
| huggingface_hub | β₯0.25 | HF Inference API + model downloads |
| pytest / pytest-asyncio | β₯8.0 | Test suite |
| Technology | Version | Purpose |
|---|---|---|
| React | 19 | UI framework |
| Vite | 8 | Build tool & dev server |
| Axios | 1.15 | HTTP client |
| Vanilla CSS | β | Styling & animations |
| Service | Purpose |
|---|---|
| Render | Backend hosting (Python 3.11, free tier) |
| Vercel / Netlify | Frontend static hosting |
| Google Cloud | Translation API (primary) |
| Hugging Face | Alternative / extended translation models |
Slango's service layer is designed to be swappable. Hugging Face translation models can replace or supplement Google Cloud Translate β ideal for offline inference, cost control, or unsupported language pairs.
Go to the Hugging Face Hub and filter by task:
https://huggingface.co/models?pipeline_tag=translation
Recommended models:
| Model | Languages | Size |
|---|---|---|
Helsinki-NLP/opus-mt-en-es |
English β Spanish | ~300 MB |
Helsinki-NLP/opus-mt-en-fr |
English β French | ~300 MB |
Helsinki-NLP/opus-mt-mul-en |
Multilingual β English | ~300 MB |
facebook/nllb-200-distilled-600M |
200 languages | ~2.4 GB |
- Create a free account at huggingface.co
- Go to Settings β Access Tokens β New Token
- Select Read access and copy the token
Add to your backend/.env:
HF_TOKEN=hf_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
HF_MODEL_ID=Helsinki-NLP/opus-mt-en-esfrom huggingface_hub import InferenceClient
client = InferenceClient(token="hf_your_token_here")
result = client.translation(
"Hello, how are you?",
model="Helsinki-NLP/opus-mt-en-es"
)
print(result.translation_text) # β "Hola, ΒΏcΓ³mo estΓ‘s?"The Inference API runs the model on Hugging Face's servers β no local GPU needed. Free tier supports most Helsinki-NLP models.
Install extra dependencies:
pip install transformers torch sentencepiecefrom transformers import pipeline
translator = pipeline("translation", model="Helsinki-NLP/opus-mt-en-es")
result = translator("Hello, how are you?")
print(result[0]["translation_text"])Requirement: β₯ 4 GB RAM. Use the Inference API for lightweight/serverless deployments.
- Python 3.11+
- Node.js 18+ and npm
- Google Cloud project with Translation API enabled (or run in fallback mode without credentials)
git clone https://github.com/KishoreB25/CodeAlpha_Slango.git
cd CodeAlpha_Slangocd backend
# Create and activate a virtual environment
python -m venv venv
# Windows
venv\Scripts\activate
# macOS / Linux
source venv/bin/activate
# Install dependencies
pip install -r requirements.txtcp .env.example .envEdit backend/.env:
# ββ App βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
APP_NAME=Slango
APP_VERSION=1.0.0
APP_ENV=development
DEBUG=true
# ββ Server ββββββββββββββββββββββββββββββββββββββββββββββββββββ
HOST=0.0.0.0
PORT=8000
# ββ CORS ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Comma-separated list of allowed frontend origins
ALLOWED_ORIGINS=http://localhost:5173
# ββ Rate Limiting βββββββββββββββββββββββββββββββββββββββββββββ
RATE_LIMIT_MAX_REQUESTS=10
RATE_LIMIT_WINDOW_SECONDS=60
# ββ Hugging Face Inference API ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Get your free token at: https://huggingface.co/settings/tokens
HF_API_TOKEN=hf_your_token_here
# Models are resolved dynamically by ModelResolver (Helsinki-NLP/opus-mt-*)
# ββTranslation settings ββββββββββββββββββββββββββββββββββββββββββββββββββββββ
TRANSLATE_TIMEOUT_SECONDS=10
TRANSLATE_MAX_RETRIES=2
TRANSLATE_RETRY_DELAY_SECONDS=0.5uvicorn app.main:app --reload| Endpoint | URL |
|---|---|
| Base API | http://localhost:8000 |
| Swagger UI | http://localhost:8000/docs |
| ReDoc | http://localhost:8000/redoc |
| Health | http://localhost:8000/api/v1/health |
cd ../frontend
npm install
npm run devFrontend: http://localhost:5173
All endpoints are prefixed with /api/v1.
Translate text between supported languages.
Request body:
{
"text": "Hello, how are you?",
"source_lang": "auto",
"target_lang": "es"
}| Field | Type | Required | Description |
|---|---|---|---|
text |
string | β | Text to translate (1β500 characters) |
source_lang |
string | β | ISO 639-1 code or "auto" for auto-detection |
target_lang |
string | β | ISO 639-1 target language code |
Response:
{
"translated_text": "Hola, ΒΏcΓ³mo estΓ‘s?",
"source_lang": "en",
"target_lang": "es"
}Error codes:
| Code | Error | Description |
|---|---|---|
400 |
unsupported_language |
Invalid language code supplied |
400 |
same_language |
Source and target languages are identical |
429 |
rate_limit_exceeded |
Too many requests β see retry_after in response |
502 |
translation_failed |
Service unavailable after all retries |
504 |
translation_timeout |
Request exceeded timeout |
Returns all supported language codes.
Response:
{
"languages": {
"en": "English",
"es": "Spanish",
"fr": "French",
"de": "German",
"it": "Italian",
"pt": "Portuguese",
"ru": "Russian",
"ja": "Japanese",
"ko": "Korean",
"zh": "Chinese (Simplified)",
"ar": "Arabic",
"hi": "Hindi",
"bn": "Bengali",
"ta": "Tamil",
"te": "Telugu"
},
"count": 15
}Health check for uptime monitoring.
Response:
{
"status": "healthy",
"version": "1.0.0",
"timestamp": "2026-07-06T00:00:00+00:00"
}CodeAlpha_Slango/
βββ backend/
β βββ app/
β β βββ api/
β β β βββ routes/
β β β βββ translate.py # /translate, /health, /languages
β β βββ core/
β β β βββ config.py # Pydantic settings (loads .env)
β β β βββ logging.py # Structured logger
β β βββ schemas/
β β β βββ translation.py # Request / response models
β β βββ services/
β β β βββ base.py # Abstract TranslatorService
β β β βββ google_translate.py # Google Cloud Translate v2
β β βββ utils/
β β β βββ rate_limiter.py # Per-IP in-memory rate limiter
β β βββ main.py # App, middleware, lifespan
β βββ tests/ # pytest test suite
β βββ requirements.txt
β βββ runtime.txt # Pins Python 3.11.9 (for Render)
β βββ .env.example
β
βββ frontend/
βββ src/ # React components & pages
βββ public/
βββ index.html
βββ vite.config.js
βββ package.json
cd backend
# With venv active
pytest
# Verbose output
pytest -v
# Specific file
pytest tests/test_translate.py -v- API credentials are never logged - only metadata (text length, language codes) is recorded
- User input is never stored server-side
- CORS is scoped to explicitly configured origins only
- Per-IP rate limiting guards against abuse
- Fork the repository
- Create a feature branch:
git checkout -b feat/your-feature - Commit your changes using Conventional Commits:
git commit -m "feat: add xyz" - Push and open a Pull Request