A production-ready sentiment analysis API built with FastAPI, Hugging Face Transformers, and deployed using modern MLOps practices.
- ✅ Real-time sentiment analysis using DistilBERT model
- ✅ RESTful API with FastAPI
- ✅ Dockerized application
- ✅ CI/CD pipeline with GitHub Actions
- ✅ Deployed on Render (free tier)
- ✅ Interactive API documentation (Swagger UI)
- Backend: Python 3.10, FastAPI
- ML Model: Hugging Face Transformers (DistilBERT)
- Containerization: Docker
- CI/CD: GitHub Actions
- Deployment: Render.com
API URL: https://your-app-name.onrender.com
Endpoints:
GET /- Welcome messageGET /health- Health checkPOST /predict- Sentiment predictionGET /docs- Interactive API documentationGET /examples- Example texts to test
- Python 3.10+
- Docker (optional)
- Clone the repository:
git clone https://github.com/yourusername/sentiment-mlops.git
cd sentiment-mlops- Install dependencies:
pip install -r app/requirements.txt- Run the application:
cd app
python main.py- Open browser:
http://localhost:8000/docs
# Build image
docker build -t sentiment-mlops .
# Run container
docker run -p 8000:8000 sentiment-mlopscurl -X POST "http://localhost:8000/predict" \
-H "Content-Type: application/json" \
-d '{"text": "I love machine learning!"}'import requests
response = requests.post(
"http://localhost:8000/predict",
json={"text": "This MLOps project is awesome!"}
)
print(response.json()){
"text": "I love machine learning!",
"sentiment": "POSITIVE",
"confidence": 0.9998,
"model": "distilbert-base-uncased-finetuned-sst-2"
}- Code Push → GitHub
- Automated Testing → GitHub Actions
- Docker Build → Containerization
- Deployment → Render.com
- Live API → Production
- Machine Learning model deployment
- API development with FastAPI
- Docker containerization
- CI/CD pipeline implementation
- Cloud deployment (Render)
- Git version control
- RESTful API design
- Add unit tests with pytest
- Implement API rate limiting
- Add authentication
- Support batch predictions
- Add model monitoring
- Implement A/B testing for models
Your Name
- GitHub: @yourusername
- LinkedIn: Your LinkedIn
MIT License
⭐ If you found this project helpful, please give it a star!