This repository contains the complete backend and deployment scripts for an AI-powered application designed to solve a practical agricultural problem: the rapid and accurate detection of fruit diseases. It showcases a modern, event-driven, and cost-effective serverless architecture on AWS.
- Key Features
- Live Demo & Examples
- System Architecture
- Getting Started
- Usage
- Project Structure
- Future Enhancements
- AI-Powered Analysis: Uses Amazon Bedrock with the Claude 3.5 Sonnet model for state-of-the-art image recognition.
- Serverless Backend: No servers to manage. The application runs on-demand, ensuring high availability and cost-efficiency.
- Scalable by Design: Built with API Gateway and Lambda, the system automatically scales to handle any amount of traffic.
- Infrastructure as Code (IaC): All AWS resources are defined in a
template.yamlfile and deployed automatically with AWS SAM, ensuring consistent and repeatable environments. - Secure by Default: Follows the Principle of Least Privilege with a fine-grained IAM role for the Lambda function.
This project includes both a user-friendly web interface for easy demonstration and a command-line script for testing the backend API directly.
1. Web Interface Demo
The primary way to interact with the application is through the simple web UI. A user can upload an image and receive the analysis in seconds.

2. API Testing
The backend API can also be tested directly from the command line after deployment:
Example Request:
./test_api.sh path/to/the/fruit_image.jpgThe application follows a classic serverless, event-driven pattern. The architecture is designed for low latency, high scalability, and minimal operational overhead.
Follow these instructions to deploy the application in your own AWS account.
- AWS CLI configured with your credentials.
- AWS SAM CLI installed.
- Python 3.9+ installed.
- Docker installed and running.
- Clone the repository:
git clone https://github.com/AYassin01/aws-serverless-fruit-detection.git
cd aws-serverless-fruit-detection- Enable Model Access:
- Navigate to the Amazon Bedrock console in your AWS account.
- Go to Model access and ensure you have been granted access to Anthropic's Claude 3.5 Sonnet.
- Run the deployment script:
- The deploy.sh script automates the entire process, including creating the Boto3 layer, building the application, and deploying the AWS resources.
chmod +x deploy.sh
./deploy.sh- Follow the prompts from the SAM CLI. This will create a CloudFormation stack and deploy all the necessary resources.
After a successful deployment, the 'deploy.sh' script will create a 'test_api.sh' script for you.
- Make the test script executable:
chmod +x test_api.sh- Run the script with the path to a fruit image:
./test_api.sh path/to/the/fruit_image.jpgThe repository is organized to separate application code from deployment configuration.
├── images/
├── src/
│ └── lambda_function.py
├── .gitattributes
├── .gitignore
├── create_boto3_layer.sh
├── deploy.sh
├── index.html
├── LICENSE
├── README.md
├── samconfig.toml
├── template.yaml
└── test_api.sh
- CI/CD Pipeline: Implement a CI/CD pipeline using GitHub Actions to automatically deploy changes pushed to the main branch.
- Asynchronous Processing: For very large images or videos, refactor the architecture to use S3 event notifications and an SQS queue for asynchronous processing.

