CoolFace
Apppublic

AbeDijkstra/MoneyBear_Streamlit

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

๐Ÿป MoneyBear Streamlit App

A powerful secondhand product search application that uses AI image captioning and eBay integration to help users find similar products by simply uploading a photo.

โœจ Features

  • โ€”๐Ÿ“ธ Image Upload & Camera Capture - Upload photos or take pictures directly in the app
  • โ€”๐Ÿค– AI Image Captioning - Uses BLIP model to generate descriptive captions from images
  • โ€”๐Ÿ” eBay Product Search - Searches eBay using generated captions to find similar products
  • โ€”๐ŸŽจ Beautiful UI - Modern, responsive interface with product cards and pricing
  • โ€”โšก Fast & Efficient - Built with Streamlit and optimized for performance
  • โ€”๐Ÿ”’ Secure - OAuth authentication with eBay API
  • โ€”๐Ÿณ Docker Ready - Containerized with UV for fast, reliable deployment

๐Ÿš€ Quick Start

Prerequisites

  • โ€”Python 3.11+
  • โ€”eBay Developer Account (for API credentials)
  • โ€”Docker (optional, for containerized deployment)

Local Development

  1. 1.Clone the repository
bash
   git clone <repository-url>
   cd MoneyBear_Streamlit
  1. 1.Install dependencies
bash
   pip install -r requirements.txt
  1. 1.Set up environment variables Create a .env file in the root directory:
env
   EBAY_APP_ID=your_ebay_app_id
   EBAY_CLIENT_SECRET=your_ebay_client_secret
   EBAY_VERIFICATION_TOKEN=your_ebay_verification_token
  1. 1.Run the application
bash
   streamlit run src/streamlit_app.py
  1. 1.Open your browser Navigate to http://localhost:8501

Docker Deployment

  1. 1.Build the Docker image
bash
   docker build -t moneybear-streamlit .
  1. 1.Run the container
bash
   docker run -p 8501:8501 \
     -e EBAY_APP_ID=your_ebay_app_id \
     -e EBAY_CLIENT_SECRET=your_ebay_client_secret \
     -e EBAY_VERIFICATION_TOKEN=your_ebay_verification_token \
     moneybear-streamlit

๐ŸŒ Hugging Face Spaces Deployment

Setup Instructions

  1. 1.Create a new Space
  2. 2.Go to huggingface.co/spaces
  3. 3.Click "Create new Space"
  4. 4.Choose "Docker" as the SDK
  5. 5.Set the license and visibility
  1. 1.Configure Environment Variables
  2. 2.Go to your Space's "Settings" tab
  3. 3.Add the following secrets:
     EBAY_APP_ID=your_ebay_app_id
     EBAY_CLIENT_SECRET=your_ebay_client_secret
     EBAY_VERIFICATION_TOKEN=your_ebay_verification_token
  1. 1.Deploy
  2. 2.Push your code to the Space repository
  3. 3.The Space will automatically build and deploy

Troubleshooting 403 Error

If you encounter a 403 Forbidden error:

Common Causes & Solutions:
  1. 1.Missing Environment Variables
bash
   # Check if variables are set in Space settings
   # Ensure all required variables are present:
   # - EBAY_APP_ID
   # - EBAY_CLIENT_SECRET  
   # - EBAY_VERIFICATION_TOKEN
  1. 1.Invalid eBay Credentials
  2. 2.Verify your eBay Developer credentials are correct
  3. 3.Ensure your eBay app is active and not suspended
  4. 4.Check if your credentials have the required permissions
  1. 1.Rate Limiting
  2. 2.eBay API has rate limits
  3. 3.Wait a few minutes and try again
  4. 4.Consider implementing rate limiting in your app
  1. 1.CORS Issues
  2. 2.Add your Hugging Face Space URL to eBay app's allowed origins
  3. 3.Update your eBay app settings to include the Space domain
  1. 1.Docker Build Issues
  2. 2.Check the Space's build logs for errors
  3. 3.Ensure your Dockerfile is correct
  4. 4.Verify all files are properly copied
Debug Steps:
  1. 1.Check Space Logs
  2. 2.Go to your Space's "Logs" tab
  3. 3.Look for error messages during startup
  1. 1.Test Environment Variables
python
   # Add this to your streamlit_app.py for debugging
   import os
   st.write("EBAY_APP_ID:", "SET" if os.getenv("EBAY_APP_ID") else "NOT SET")
   st.write("EBAY_CLIENT_SECRET:", "SET" if os.getenv("EBAY_CLIENT_SECRET") else "NOT SET")
  1. 1.Verify eBay API Access
  2. 2.Test your credentials locally first
  3. 3.Use eBay's API testing tools
  1. 1.Check Space Configuration
  2. 2.Ensure the Space is set to "Docker" SDK
  3. 3.Verify the app_port is set to 8501
  4. 4.Check that the Dockerfile is in the root directory
Quick Fix Template:

If the issue persists, try this minimal configuration:

dockerfile
FROM python:3.11-slim-bookworm

WORKDIR /app

COPY requirements.txt .
RUN pip install -r requirements.txt

COPY src/ ./src/
COPY static/ ./static/

EXPOSE 8501

CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]

๐Ÿงช Testing

Run the comprehensive test suite:

bash
python tests/run_tests.py

Test Coverage

  • โ€”โœ… Image Captioning - BLIP model functionality
  • โ€”โœ… eBay Search - OAuth authentication and API integration
  • โ€”โœ… Streamlit App - UI components and user interactions
  • โ€”โœ… Configuration - Environment variable handling
  • โ€”โœ… Error Handling - Graceful fallbacks and error recovery

๐Ÿ“ Project Structure

MoneyBear_Streamlit/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ streamlit_app.py      # Main Streamlit application
โ”‚   โ”œโ”€โ”€ image_to_text.py      # AI image captioning module
โ”‚   โ”œโ”€โ”€ text_in_ebay.py       # eBay search integration
โ”‚   โ”œโ”€โ”€ config.py             # Configuration management
โ”‚   โ””โ”€โ”€ webhook.py            # eBay webhook handlers
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ test_image_to_text.py # Image captioning tests
โ”‚   โ”œโ”€โ”€ test_text_in_ebay.py  # eBay search tests
โ”‚   โ”œโ”€โ”€ test_streamlit_app.py # UI and app logic tests
โ”‚   โ”œโ”€โ”€ test_config.py        # Configuration tests
โ”‚   โ””โ”€โ”€ run_tests.py          # Test runner
โ”œโ”€โ”€ static/                   # Static assets
โ”œโ”€โ”€ requirements.txt          # Python dependencies
โ”œโ”€โ”€ Dockerfile               # Docker configuration
โ””โ”€โ”€ README.md                # This file

๐Ÿ”ง Configuration

Environment Variables

VariableDescriptionRequired
EBAY_APP_IDeBay Developer Application IDYes
EBAY_CLIENT_SECRETeBay Developer Client SecretYes
EBAY_VERIFICATION_TOKENeBay Webhook Verification TokenYes
ALLOWED_EXTENSIONSComma-separated list of allowed image extensionsNo (default: .jpg,.jpeg,.png,.webp)
MAX_FILE_SIZEMaximum file size in bytesNo (default: 5MB)

eBay API Setup

  1. 1.Create an eBay Developer account at developer.ebay.com
  2. 2.Create a new application
  3. 3.Get your App ID and Client Secret
  4. 4.Set up webhook verification token
  5. 5.Add credentials to your environment variables

๐ŸŽฏ Usage

  1. 1.Upload or Capture Image
  2. 2.Use the camera to take a photo, or
  3. 3.Upload an image file from your device
  1. 1.AI Processing
  2. 2.The app automatically generates a caption describing the image
  3. 3.Uses advanced BLIP model for accurate descriptions
  1. 1.Product Search
  2. 2.Searches eBay for similar products using the generated caption
  3. 3.Displays results in a clean, card-based layout
  1. 1.View Results
  2. 2.See product images, titles, and prices
  3. 3.Click "View on eBay" to open the product page

๐Ÿ› ๏ธ Development

Adding New Features

  1. 1.Create feature branch
bash
   git checkout -b feature/your-feature-name
  1. 1.Write tests first
bash
   # Add tests to appropriate test file
   python tests/run_tests.py
  1. 1.Implement feature
  2. 2.Follow existing code patterns
  3. 3.Add proper error handling
  4. 4.Update documentation
  1. 1.Run tests and linting
bash
   python tests/run_tests.py

Code Style

  • โ€”Follow PEP 8 guidelines
  • โ€”Use type hints where appropriate
  • โ€”Add docstrings to functions and classes
  • โ€”Keep functions small and focused

๐Ÿš€ Deployment

Production Deployment

  1. 1.Build optimized Docker image
bash
   docker build -t moneybear-streamlit:latest .
  1. 1.Deploy with environment variables
bash
   docker run -d \
     --name moneybear-app \
     -p 8501:8501 \
     -e EBAY_APP_ID=your_app_id \
     -e EBAY_CLIENT_SECRET=your_client_secret \
     -e EBAY_VERIFICATION_TOKEN=your_token \
     moneybear-streamlit:latest

Cloud Deployment

The app is ready for deployment on:

  • โ€”AWS ECS/Fargate
  • โ€”Google Cloud Run
  • โ€”Azure Container Instances
  • โ€”Heroku
  • โ€”Railway
  • โ€”Hugging Face Spaces

๐Ÿค Contributing

  1. 1.Fork the repository
  2. 2.Create a feature branch
  3. 3.Make your changes
  4. 4.Add tests for new functionality
  5. 5.Ensure all tests pass
  6. 6.Submit a pull request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ†˜ Support

For support and questions:

  • โ€”Create an issue in the repository
  • โ€”Check the documentation
  • โ€”Review the test suite for usage examples

๐Ÿ”„ Version History

  • โ€”v1.0.0 - Initial release with image captioning and eBay search
  • โ€”v1.1.0 - Added comprehensive test suite and Docker support
  • โ€”v1.2.0 - Improved error handling and UI enhancements

Made with โค๏ธ by the MoneyBear team