Skip to content

dev-api-org/ai-app-containerization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— AI Car Inspector

An AI-powered low-code application that uses Google's Gemini 2.0 Flash to analyze car images and provide detailed information about make, model, year, and more. Built with Gradio, containerized with Docker, and deployed on Kubernetes.

Python Gradio Docker Kubernetes

🌟 Features

  • βœ… Car Detection: Automatically identifies if uploaded image contains a car
  • πŸš— Detailed Analysis: Extracts make, model, year, body type, color, and condition
  • 🎨 Minimal UI: Clean, user-friendly Gradio interface
  • 🐳 Containerized: Fully dockerized for easy deployment
  • ☸️ Kubernetes Ready: Complete K8s manifests included
  • πŸ”„ CI/CD Pipeline: Automated build and deployment with GitHub Actions
  • πŸ€– AI-Powered: Uses Gemini 2.0 Flash with optimized temperature settings

πŸ—οΈ Architecture

User Browser β†’ Gradio UI (Port 7860) β†’ Python Backend β†’ Gemini 2.0 Flash API β†’ Response

Tech Stack

  • Frontend: Gradio (Low-code UI framework)
  • Backend: Python 3.11
  • AI Model: Gemini 2.0 Flash (gemini-2.0-flash-exp)
  • Container: Docker
  • Orchestration: Kubernetes/OpenShift
  • CI/CD: GitHub Actions
  • Registry: Docker Hub

πŸ“‹ Prerequisites

  • Python 3.11+
  • Docker
  • Kubernetes cluster (or Minikube/OpenShift)
  • Gemini API key (Get one here)
  • Docker Hub account
  • kubectl configured

πŸš€ Quick Start

Local Development

  1. Clone the repository
git clone https://github.com/your-username/car-inspector.git
cd car-inspector
  1. Set up environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
pip install -r requirements.txt
  1. Configure API key
cp .env.example .env
# Edit .env and add your Gemini API key
  1. Run the application
python app.py
  1. Open browser
http://localhost:7860

Docker Deployment

  1. Build Docker image
docker build -t car-inspector:latest .
  1. Run container
docker run -p 7860:7860 -e GEMINI_API_KEY=your_api_key car-inspector:latest
  1. Access application
http://localhost:7860

Kubernetes Deployment

  1. Create secret with API key
kubectl create secret generic car-inspector-secret \
  --from-literal=GEMINI_API_KEY=your_actual_api_key
  1. Update deployment image Edit kubernetes/deployment.yaml and replace your-dockerhub-username with your actual Docker Hub username.

  2. Apply Kubernetes manifests

kubectl apply -f kubernetes/secret.yaml
kubectl apply -f kubernetes/deployment.yaml
kubectl apply -f kubernetes/service.yaml
  1. Check deployment status
kubectl get pods
kubectl get services
  1. Access application
# For LoadBalancer
kubectl get service car-inspector-service

# For NodePort
kubectl get nodes -o wide
# Access at http://<node-ip>:30860

πŸ”§ Configuration

Hardcoded Settings

These settings are intentionally hardcoded for consistency:

MODEL_NAME = "gemini-2.0-flash-exp"
TEMPERATURE = 0.4

Environment Variables

  • GEMINI_API_KEY: Your Gemini API key (required)

πŸ“ Project Structure

car-inspector/
β”œβ”€β”€ app.py                    # Main Gradio application
β”œβ”€β”€ requirements.txt          # Python dependencies
β”œβ”€β”€ Dockerfile               # Docker configuration
β”œβ”€β”€ .dockerignore            # Docker ignore file
β”œβ”€β”€ .env.example             # Environment template
β”œβ”€β”€ README.md                # This file
β”œβ”€β”€ kubernetes/
β”‚   β”œβ”€β”€ deployment.yaml      # K8s deployment
β”‚   β”œβ”€β”€ service.yaml         # K8s service
β”‚   └── secret.yaml          # K8s secret template
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci-cd.yaml       # CI/CD pipeline
└── capstone_reflection.md   # Project documentation

πŸ”„ CI/CD Pipeline

The project includes a GitHub Actions workflow that:

  1. Builds and tests the application
  2. Creates Docker image with commit SHA and latest tags
  3. Pushes to Docker Hub
  4. Deploys to Kubernetes (manual trigger or automated)

Setup GitHub Secrets

Add these secrets to your GitHub repository:

  • DOCKER_USERNAME: Your Docker Hub username
  • DOCKER_PASSWORD: Your Docker Hub password/token
  • KUBECONFIG: Your Kubernetes config (optional, for auto-deployment)

πŸ§ͺ Testing

Test with Sample Images

  1. Upload a car image: Should provide detailed analysis
  2. Upload a non-car image: Should display warning message
  3. Test various car types: Sedans, SUVs, trucks, sports cars
  4. Test edge cases: Poor lighting, multiple cars, partial views

Expected Output Example

βœ… Car Detected Successfully!

πŸš— AI Analysis Results:

- Make: Toyota
- Model: Camry
- Year: 2020-2023 (8th generation)
- Body Type: Sedan
- Color: Silver/Gray
- Condition: Excellent
- Features: LED headlights, modern design
- Facts: One of the best-selling sedans globally

πŸ“Š Monitoring

Check Pod Health

kubectl get pods -w
kubectl logs -f deployment/car-inspector

View Service Status

kubectl describe service car-inspector-service

Resource Usage

kubectl top pods

πŸ”’ Security

  • API keys stored in Kubernetes Secrets
  • No hardcoded credentials in code
  • Environment variable injection
  • Resource limits applied
  • Regular security updates

πŸ› Troubleshooting

Common Issues

1. Gradio not accessible in container

  • Ensure server_name="0.0.0.0" in app.py
  • Check port 7860 is exposed

2. Gemini API errors

  • Verify API key is correct
  • Check API quota/rate limits
  • Ensure internet connectivity

3. Kubernetes pods not starting

kubectl describe pod <pod-name>
kubectl logs <pod-name>

4. CI/CD pipeline failing

  • Check Docker Hub credentials
  • Verify Dockerfile syntax
  • Ensure all files are committed

πŸ“š Documentation

🀝 Team Contributions

  • Person 1: Application development and AI integration
  • Person 2: Containerization and CI/CD setup
  • Person 3: Kubernetes deployment and documentation

πŸ“ License

This project is for educational purposes as part of the DevOps Capstone project.

πŸ™ Acknowledgments

  • Google Gemini API for AI capabilities
  • Gradio for the low-code UI framework
  • IBM Docker/Kubernetes course for guidance

πŸ“§ Contact

For questions or issues, please open an issue on GitHub. #Done by Dev-Api-Org

About

A low-code AI app that will be containerised and deployed to the Kubernetes using a CI/CD pipeline.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors