AbeDijkstra/MoneyBear_Streamlit
0
๐ป 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
- Clone the repository
git clone <repository-url>
cd MoneyBear_Streamlit- Install dependencies
pip install -r requirements.txt- Set up environment variables Create a
.envfile in the root directory:
EBAY_APP_ID=your_ebay_app_id
EBAY_CLIENT_SECRET=your_ebay_client_secret
EBAY_VERIFICATION_TOKEN=your_ebay_verification_token- Run the application
streamlit run src/streamlit_app.py- Open your browser Navigate to
http://localhost:8501
Docker Deployment
- Build the Docker image
docker build -t moneybear-streamlit .- Run the container
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
- Create a new Space
- Go to huggingface.co/spaces
- Click "Create new Space"
- Choose "Docker" as the SDK
- Set the license and visibility
- Configure Environment Variables
- Go to your Space's "Settings" tab
- 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- Deploy
- Push your code to the Space repository
- The Space will automatically build and deploy
Troubleshooting 403 Error
If you encounter a 403 Forbidden error:
Common Causes & Solutions:
- Missing Environment Variables
# Check if variables are set in Space settings
# Ensure all required variables are present:
# - EBAY_APP_ID
# - EBAY_CLIENT_SECRET
# - EBAY_VERIFICATION_TOKEN- Invalid eBay Credentials
- Verify your eBay Developer credentials are correct
- Ensure your eBay app is active and not suspended
- Check if your credentials have the required permissions
- Rate Limiting
- eBay API has rate limits
- Wait a few minutes and try again
- Consider implementing rate limiting in your app
- CORS Issues
- Add your Hugging Face Space URL to eBay app's allowed origins
- Update your eBay app settings to include the Space domain
- Docker Build Issues
- Check the Space's build logs for errors
- Ensure your Dockerfile is correct
- Verify all files are properly copied
Debug Steps:
- Check Space Logs
- Go to your Space's "Logs" tab
- Look for error messages during startup
- Test Environment Variables
# 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")- Verify eBay API Access
- Test your credentials locally first
- Use eBay's API testing tools
- Check Space Configuration
- Ensure the Space is set to "Docker" SDK
- Verify the app_port is set to 8501
- Check that the Dockerfile is in the root directory
Quick Fix Template:
If the issue persists, try this minimal configuration:
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:
python tests/run_tests.pyTest 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
eBay API Setup
- Create an eBay Developer account at developer.ebay.com
- Create a new application
- Get your App ID and Client Secret
- Set up webhook verification token
- Add credentials to your environment variables
๐ฏ Usage
- Upload or Capture Image
- Use the camera to take a photo, or
- Upload an image file from your device
- AI Processing
- The app automatically generates a caption describing the image
- Uses advanced BLIP model for accurate descriptions
- Product Search
- Searches eBay for similar products using the generated caption
- Displays results in a clean, card-based layout
- View Results
- See product images, titles, and prices
- Click "View on eBay" to open the product page
๐ ๏ธ Development
Adding New Features
- Create feature branch
git checkout -b feature/your-feature-name- Write tests first
# Add tests to appropriate test file
python tests/run_tests.py- Implement feature
- Follow existing code patterns
- Add proper error handling
- Update documentation
- Run tests and linting
python tests/run_tests.pyCode Style
- Follow PEP 8 guidelines
- Use type hints where appropriate
- Add docstrings to functions and classes
- Keep functions small and focused
๐ Deployment
Production Deployment
- Build optimized Docker image
docker build -t moneybear-streamlit:latest .- Deploy with environment variables
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:latestCloud Deployment
The app is ready for deployment on:
- AWS ECS/Fargate
- Google Cloud Run
- Azure Container Instances
- Heroku
- Railway
- Hugging Face Spaces
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- 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
