Skip to content

Adwerse/Language-detection-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LangDetect API

NLP-powered language detection service β€” trained on a custom dataset, served via FastAPI, containerized with Docker, deployed on Railway.

Built end-to-end: from raw data and model training in Jupyter to a live production endpoint with a web UI.

Why it exists: My first complete ML project shipped to production β€” not a notebook, not a tutorial result. A running service.

Live Demo πŸš€

Features ✨

  • Language prediction endpoint for user text
  • Clean web UI for manual testing
  • FastAPI OpenAPI documentation
  • Dockerized deployment flow
  • Railway hosting support

Project Structure

.
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ README.md
└── app
    β”œβ”€β”€ main.py
    β”œβ”€β”€ requirements.txt
    β”œβ”€β”€ static
    β”‚   └── index.html
    └── model
        β”œβ”€β”€ model.py
        β”œβ”€β”€ trained_pipeline-0.1.0.pkl
        └── LangDetetctionModel.ipynb

API πŸ€–

GET /

Returns service status and model version.

Example response:

{
  "health_check": "OK",
  "model_version": "0.1.0"
}

GET /ui

Serves the web interface for submitting text and viewing predictions.

POST /predict

Predicts the language of the provided text.

Request body:

{
  "text": "Bonjour, comment allez-vous aujourd'hui?"
}

Response:

{
  "language": "French"
}

Run Locally (Docker)

Build image:

docker build -t language-detection-app .

Run container:

docker run --rm -p 80:80 language-detection-app

Open in browser:

Quick Test with curl

curl -X POST "http://localhost/predict" \
  -H "Content-Type: application/json" \
  -d '{"text":"Hello, how are you today?"}'

Deployment Notes

  • Hosted on Railway using the repository Dockerfile.
  • For lower startup overhead on small instances, worker settings can be tuned with:
    • WEB_CONCURRENCY=1
    • MAX_WORKERS=1

Tech Stack

  • Python 3.9
  • FastAPI
  • scikit-learn
  • NumPy
  • Docker
  • Railway

Author

Adam Vakar

About

🌐NLP language detection API β€” trained in Jupyter, served with FastAPI, deployed on Railway

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages