Skip to content

End-to-end MLOps system for sentiment classification with fine-tuned TinyBERT, production-grade architecture (Nginx + Docker Compose), and zero-downtime CI/CD deployment on AWS infrastructure

Notifications You must be signed in to change notification settings

CodeBy-HP/FinetuneTinyBERT-SentimentClassification-FastapiMicroservice

Repository files navigation

🎯 Sentiment Analysis API - Production Deployment

Fine-tuned TinyBERT with Nginx load balancing, Docker orchestration, and automated CI/CD on AWS

Python FastAPI Docker Nginx AWS GitHub Actions


🎯 Overview

Production-grade sentiment analysis API featuring fine-tuned TinyBERT model, Nginx load balancing, multi-container orchestration, and automated deployment on AWS with zero-downtime scaling capabilities.


🌈 Application Demo

[Image: Screenshot of sentiment analysis web interface]


🌈 Video Demo

Watch Demo

▶️ Click to watch architecture & deployment demo


🌈 Architecture Diagrams

[Image: System architecture showing Nginx → FastAPI → S3 flow]

[Image: CI/CD pipeline diagram: Git → GitHub Actions → ECR → EC2]

[Image: Docker Compose multi-container orchestration diagram]


✨ Key Features

🧠 FINE-TUNED ML MODEL

  • TinyBERT optimized for sentiment classification
  • Binary classification: Positive/Negative
  • Model stored and versioned in AWS S3

NGINX LOAD BALANCING

  • Reverse proxy architecture for production-grade setup
  • Automatic request distribution across scaled instances
  • Professional separation of concerns

🚀 AUTOMATED CI/CD PIPELINE

  • GitHub Actions for build and deployment
  • Automatic image push to AWS ECR
  • Zero-downtime deployments on EC2

📦 HORIZONTAL SCALING

  • Scale API instances with single command: --scale app=5
  • Nginx automatically load balances across all instances
  • Ready for production workloads

🛠️ Tech Stack

  • Machine Learning: PyTorch, Transformers, TinyBERT
  • Backend: FastAPI, Uvicorn
  • Infrastructure: Docker, Docker Compose, Nginx
  • DevOps & CI/CD: GitHub Actions, AWS (ECR, EC2, S3)

📁 Project Structure

FineTuningBERT/
├── fastapi_app/
│   ├── app.py                 # FastAPI application with container-info endpoint
│   ├── get_model.py          # S3 model downloader
│   ├── requirements.txt       # Python dependencies
│   └── templates/
│       └── index.html        # Web interface
├── tinybert-sentiment-analysis/
│   └── [Fine-tuned model files]
├── .github/workflows/
│   └── deploy.yml            # CI/CD pipeline (build → push → deploy)
├── nginx.conf                # Reverse proxy configuration
├── docker-compose.yml        # Multi-container orchestration
├── Dockerfile                # FastAPI container
├── Dockerfile.nginx          # Nginx container
└── .env.example              # Environment variables template

🏗️ Architecture Highlights

Request Flow:

User Request (Port 80)
    ↓
Nginx Container (Reverse Proxy)
    ↓
FastAPI Container(s) (Port 8000)
    ↓
TinyBERT Model (S3)
    ↓
Sentiment Prediction

CI/CD Pipeline:

Push to Main → Build Image → Push to ECR → Deploy on EC2 → docker-compose up

🚀 Quick Start

Local Development:

cp .env.example .env
docker-compose up -d
curl http://localhost/health

Deployment to EC2:

git push origin main  # Triggers automated CI/CD

👉 Complete Setup & Deployment Guide


🎓 What I Learned

  • Fine-tuning and deploying transformer models
  • Nginx reverse proxy and load balancing architecture
  • Docker Compose for multi-container orchestration
  • Horizontal scaling with Docker containers
  • GitHub Actions CI/CD pipeline automation
  • AWS cloud services (ECR, EC2, S3)
  • Production-ready application design
  • Health checks and monitoring best practices
  • Infrastructure as Code principles

🔮 Future Enhancements

  • Kubernetes Migration: Scale beyond Docker Compose
  • Rate Limiting: Implement rate limiting in Nginx
  • Monitoring: Prometheus + Grafana dashboards
  • Caching: Redis for prediction caching
  • Authentication: OAuth2/JWT for API security

👤 Author

Harsh Patel
📧 code.by.hp@gmail.com
🔗 GitHubLinkedIn


⭐ If you find this project helpful, please star it!

About

End-to-end MLOps system for sentiment classification with fine-tuned TinyBERT, production-grade architecture (Nginx + Docker Compose), and zero-downtime CI/CD deployment on AWS infrastructure

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published