🌐 A lightweight AI microservice for real-time sentiment analysis — containerized, production-ready, and lightning fast ⚡
Nginx-hosted Flask API performing real-time sentiment prediction powered by Hugging Face Transformers.
git clone https://github.com/<your-username>/TextPilot.git
cd TextPilot
docker compose up -d✅ Instantly launches the Flask API and Nginx reverse proxy with one command.
- 🔍 Real-time sentiment prediction (Positive / Negative / Neutral)
- ⚙️ Flask-based REST API served with Gunicorn
- 🐳 Containerized using Docker Compose
- 🚦 Health check endpoint for orchestration
- ⚡ Pre-cached Hugging Face model for faster startup
- 🔐 Nginx reverse proxy with production configuration
| Layer | Technology |
|---|---|
| Language | Python 3.11 |
| Framework | Flask |
| Model | Hugging Face Transformers (distilbert-base-uncased-finetuned-sst-2-english) |
| Server | Gunicorn |
| Proxy | Nginx |
| Containerization | Docker & Docker Compose |
TextPilot/
├── app/
│ ├── __init__.py
│ ├── main.py
│ ├── model.py
│ ├── wsgi.py
│ └── requirements.txt
├── nginx/
│ └── default.conf
├── Dockerfile
├── docker-compose.yml
├── .env
├── install_docker.sh
├── README.md
└── Textpilot.PNG
MODEL_ID=distilbert-base-uncased-finetuned-sst-2-english
TRANSFORMERS_DEVICE=-1
chmod +x install_docker.sh
./install_docker.shdocker compose build
docker compose up -d| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check for Docker orchestration |
/analyze |
POST | Returns sentiment prediction for input text |
curl -s -X POST http://localhost:80/analyze \
-H "Content-Type: application/json" \
-d '{"text": "TextPilot is an awesome project!"}'Expected Output:
{"label": "POSITIVE", "score": 0.9993}| Service | Role | Port |
|---|---|---|
api |
Flask app + Transformers model (served by Gunicorn) | 8000 |
nginx |
Reverse proxy to the Flask service | 80 |
Nginx handles all external traffic and routes requests internally to the Flask API.
# Check logs
docker compose logs -f
# Restart containers
docker compose restart
# Stop services
docker compose down- 🔐 Add JWT authentication
- 📊 Add Swagger/OpenAPI documentation
- 🧠 Support multiple NLP models (emotion, toxicity, etc.)
- ☁️ Deploy on AWS ECS or DigitalOcean with HTTPS
This project is licensed under the MIT License.