A Streamlit-based web application that analyzes images using Google Generative AI (Gemini) and stores both the original images and analysis in Amazon S3. I have also written a Medium article about this project, detailing its features and implementation.
- Overview
- Architecture
- Features
- Prerequisites
- Local Development
- Docker
- Terraform Deployment
- CI/CD with GitHub Actions
- Screenshots
- License
VisualInsight is a simple image-analysis solution that:
- Lets you upload an image (JPG/PNG) via the Streamlit interface.
- Sends the image to Google Generative AI (Gemini) for an analysis prompt.
- Stores the image in an AWS S3 bucket.
- Displays the AI-generated analysis to the user.
- Frontend: Streamlit application (Python).
- Backend:
- AWS S3 for file storage.
- Google Generative AI for text analysis.
- Infrastructure:
- Terraform for provisioning AWS resources (S3, ECR, ECS, IAM roles/policies, etc.).
- Docker: Container image for the Streamlit app.
- CI/CD:
- GitHub Actions workflow to build and push Docker images to ECR, and update the ECS service.
- Image Upload: Users can upload images (JPEG, PNG, etc.).
- AI Image Analysis: Using Google Generative AI API (Gemini).
- S3 Storage: Uploaded images are stored in an S3 bucket.
- Dockerized: Streamlit application wrapped in a Docker container.
- Scalable Infrastructure: Terraform-managed infrastructure on AWS.
- Continuous Deployment: GitHub Actions pipeline automates Docker builds and ECS deployments.
- Python 3.9+ (for local testing).
- Docker installed (for containerization).
- Terraform installed (if you plan to deploy via Terraform).
- AWS Account and credentials with appropriate permissions.
- Google Cloud API key for Generative AI (Gemini).
- GitHub Actions set up with secrets:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGION(e.g.,us-east-1)
Create a .env file in the project root (or set these in your environment) with the following values:
AWS_ACCESS_KEY_ID="YOUR_AWS_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY="YOUR_AWS_SECRET_ACCESS_KEY"
AWS_REGION="us-east-1"
S3_BUCKET_NAME="YOUR_S3_BUCKET_NAME"
GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"- Install dependencies:
pip install -r requirements.txt- Run the Streamlit app:
streamlit run app/main.py- Access the app by opening your browser to: http://localhost:8501
- Build the Docker image:
docker build -t visualinsight:latest .- Check that the image was built:
docker images- Run the Docker container:
docker run -p 8501:8501 \
-e AWS_ACCESS_KEY_ID="YOUR_AWS_ACCESS_KEY_ID" \
-e AWS_SECRET_ACCESS_KEY="YOUR_AWS_SECRET_ACCESS_KEY" \
-e AWS_REGION="us-east-1" \
-e S3_BUCKET_NAME="YOUR_S3_BUCKET_NAME" \
-e GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY" \
visualinsight:latest- Open the browser at http://localhost:8501.
This project includes Terraform configurations to create and manage AWS resources (S3 bucket, ECR repository, ECS cluster, etc.).
- Initialize Terraform:
cd infrastructure/terraform
terraform init- Validate the configuration:
terraform validate- Preview changes:
terraform plan -var="bucket_name=bucket_name"- Apply the changes:
terraform apply -var="bucket_name=bucket_name"Once complete, Terraform will:
- reate an S3 bucket (with the specified name).
- Create an ECR repository (for the Docker image).
- Create an ECS cluster, IAM roles, policies, etc.
The .github/workflows/deploy.yml file automates:
- Checkout of your code.
- AWS credentials configuration.
- Docker build and push to AWS ECR.
- Forcing a new ECS deployment to pull the latest image.
To use this workflow, you need to set the following GitHub Secrets: Go to Settings > Secrets and variables > Actions in your GitHub repository and add:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_REGIONS3_BUCKET_NAMEGOOGLE_API_KEY
With these secrets configured, any push to the main branch triggers the build-and-deploy workflow.
| Screenshot | Description |
|---|---|
![]() |
First analysis page demo |
![]() |
Second analysis page demo |
![]() |
Third analysis page demo |
| Screenshot | Description |
|---|---|
![]() |
Full GitHub Actions workflow |
![]() |
Partial view of the CI/CD steps |
This project is licensed under the MIT License.










