Skip to content

Playlist Search Server allows clients to search for songs in a collection of playlists.

Notifications You must be signed in to change notification settings

tjnorred/Playlist-Search-Microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Playlist Search

Contents

Summary

Using Playlist Search

Communication contract

UML Sequence Diagram

Logging

Testing

Summary

The Playlist Search Server allows clients to search for songs in a collection of playlists. Clients send a JSON payload containing the playlists, playlist name, search category (e.g., "title", "artist", "genre"), and search term. The server searches the specified playlist and returns a string response indicating whether a match was found or not.

Using Playlist Search

  • Installation

    • Prerequisites:

      • Python 3.7+
      • ZeroMQ library (pyzmq)
    • Installation Steps:

      1. Clone the Repository: git clone https://github.com/tjnorred/CS361-A.git
      2. Change directory: cd CS361-A
      3. (Optional) Create virtual environment: python -m venv venv
      4. (Optional) Activate virtual environment:
      • Linux/Mac: source venv/bin/activate
      • Windows: venv\Scripts\activate
      1. Install requirements: pip install -r requirements.txt or pip install pyzmq
  • Running Server

    You can start the server with the default port (5555) or specify a custom port using the -p or --port argument.

    • Using the default port:

      python server.py
    • Specifying a custom port:

      python server.py -p 8080

      or

      python server.py --port 8080

Communication contract

  • Connect a Client to Server:

    context = zmq.Context()
    socket = context.socket(zmq.REQ)
    socket.connect("tcp://localhost:5555") # change the port number to match the server
    
  • Request Data:

    # Example payload
    data = {
        "playlists": {"Running Mood": [
            {"title": "Where You Are", "artist": "John Summit", "genre": "Electronic"},
            {"title": "Summer", "artist": "Calvin Harris", "genre": "Electronic"},
            {"title": "Running Up That Hill (A Deal With God)", "artist": "Kate Bush", "genre": "Synth-Pop"}
        ]},
        "playlist_name": "Running Mood",
        "search_category": "artist",
        "search_term": "John Summit"
    }
    
    socket.send_json(data)
    
  • Receive Data:

    socket.recv_string()
    

UML Sequence Diagram

UML Diagram

Logging

  • Logs all activities to server.log.
  • File contains timestamps, client IPs, received requests, sent responses, and any errors that occurred.

Testing

  • Tests are under the /tests directory

  • Run the unit tests: python -m unittest tests/testPlaylistSearch.py

About

Playlist Search Server allows clients to search for songs in a collection of playlists.

Resources

Stars

Watchers

Forks

Languages