Skip to content

hill0106/artsy-web-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎨 Artsy Web Service

Python Flask Google App Engine License

A modern web application for searching and discovering artists using the Artsy API

πŸ“‹ Table of Contents

✨ Features

  • πŸ” Artist Search: Search for artists using the Artsy API
  • πŸ“± Responsive Design: Modern, mobile-friendly interface
  • ⚑ Real-time Results: Fast search with loading indicators
  • πŸ”„ Auto Token Refresh: Automatic API token renewal every 7 days
  • ☁️ Cloud Ready: Deployed on Google App Engine
  • 🎨 Beautiful UI: Clean, intuitive user interface

πŸš€ Quick Start

Prerequisites

  • Python 3.9+
  • pip (Python package installer)

Local Development

  1. Clone the repository

    git clone https://github.com/hill0106/Artsy-Web-Service.git
    cd Assignment2/app
  2. Install dependencies

    pip install -r requirements.txt
  3. Run the application

    python main.py
  4. Open your browser

    http://localhost:8080
    

πŸ› οΈ Installation

Dependencies

The application uses the following Python packages:

Flask==3.0.0          # Web framework
apscheduler==3.8.0    # Background task scheduler
requests==2.26.0      # HTTP library for API calls

Environment Setup

No additional environment variables are required for local development. The application uses hardcoded Artsy API credentials for demonstration purposes.

πŸ“– API Documentation

Endpoints

GET /

  • Description: Serves the main application interface
  • Response: HTML page with search functionality

GET /api/search?q={query}

  • Description: Search for artists by name
  • Parameters:
    • q (string, required): Artist name to search for
  • Response: JSON array of artist search results
  • Example:
    curl "http://localhost:8080/api/search?q=picasso"

GET /api/artist/{artist_id}

  • Description: Get detailed information about a specific artist
  • Parameters:
    • artist_id (string, required): Unique artist identifier
  • Response: JSON object with artist details
  • Example:
    curl "http://localhost:8080/api/artist/4d8b92b34eb68a1b2c0003f4"

Error Handling

  • 400 Bad Request: Missing required parameters
  • 500 Internal Server Error: API request failures or server errors

πŸ—οΈ Architecture

System Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Web Browser   │◄──►│   Flask App     │◄──►│   Artsy API     β”‚
β”‚                 β”‚    β”‚                 β”‚    β”‚                 β”‚
β”‚ - Search UI     β”‚    β”‚ - Routes        β”‚    β”‚ - Artist Data   β”‚
β”‚ - Results       β”‚    β”‚ - Token Mgmt    β”‚    β”‚ - Search API    β”‚
β”‚ - Responsive    β”‚    β”‚ - Error Handlingβ”‚    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

  • Flask Application: Main web server handling HTTP requests
  • Background Scheduler: Manages automatic token refresh
  • Artsy API Integration: Fetches artist data and search results
  • Static Assets: CSS, JavaScript, and images for the frontend

πŸ”§ Configuration

Token Management

The application automatically manages Artsy API tokens:

  • Initial Token: Fetched on application startup
  • Auto Refresh: Tokens are renewed every 7 days
  • Error Handling: Graceful fallback for token failures

API Credentials

Current implementation uses demo credentials:

  • Client ID: 208b20e0a3e74e677cef
  • Client Secret: 87014948d402d1d0b9934dd621e5ab0f

⚠️ Security Note: In production, store credentials as environment variables

πŸš€ Deployment

Google App Engine

The application is configured for Google App Engine deployment:

  1. Configuration File: app.yaml

    runtime: python39
    handlers:
      - url: /static
        static_dir: static
      - url: /.*
        script: auto
  2. Deploy Command:

    gcloud app deploy

Environment Variables

For production deployment, consider setting:

  • PORT: Application port (default: 8080)
  • ARTSY_CLIENT_ID: Artsy API client ID
  • ARTSY_CLIENT_SECRET: Artsy API client secret

πŸ§ͺ Testing

Manual Testing

  1. Search Functionality:

    • Enter artist names in the search box
    • Verify results are displayed correctly
    • Test with various artist names
  2. Error Handling:

    • Test with empty search queries
    • Verify error messages are user-friendly
  3. Responsive Design:

    • Test on different screen sizes
    • Verify mobile compatibility

πŸ“ Project Structure

app/
β”œβ”€β”€ main.py              # Main Flask application
β”œβ”€β”€ requirements.txt     # Python dependencies
β”œβ”€β”€ app.yaml            # Google App Engine configuration
β”œβ”€β”€ README.md           # Project documentation
β”œβ”€β”€ static/             # Static assets
β”‚   β”œβ”€β”€ style.css       # Application styles
β”‚   β”œβ”€β”€ script.js       # Frontend JavaScript
β”‚   └── images/         # Image assets
β”‚       β”œβ”€β”€ artsy_logo.svg
β”‚       β”œβ”€β”€ clear_icon.png
β”‚       β”œβ”€β”€ loading.gif
β”‚       └── search_icon.png
└── templates/          # HTML templates
    └── index.html      # Main application template

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow PEP 8 style guidelines
  • Add comments for complex logic
  • Test your changes thoroughly
  • Update documentation as needed

πŸ“„ License

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


Made with ❀️ for art lovers

🌐 Live Demo β€’ πŸ“§ Contact β€’ πŸ› Report Bug