Skip to content

Micg25/Spotify-history-analyzer-Distributed-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 Spotify History Analyzer - Distributed System

Screenshot from 2026-01-16 11-24-36

A distributed application built with Java RMI (Remote Method Invocation) designed to parse and analyze Spotify Extended Streaming History data. This project demonstrates key distributed systems design patterns, focusing on stateless server architecture and secure communication.

⚠️ Note: This project is currently under active development. Features and architecture are subject to change.

πŸš€ Key Features (Implemented)

-Distributed Architecture: Uses Java RMI for communication between Client and Server.

-Token-Based Authentication: login mechanism using signed Tokens (RSA signature).

-Stateless Server: The server does not maintain user session state in memory, ensuring scalability.

-Client Session State: The session history and cache are maintained by the Client and transferred via DTOs.

-Smart Caching (Idempotency): The server detects repeated queries (e.g., searching for the same year twice) and returns cached results instantly without re-processing files.

-Data Analysis: Calculate the total number of songs listened to in a specific year.

πŸ—οΈ Design Patterns & Architecture

This project implements several architectural patterns studied in Distributed Systems engineering:

1. Remote Facade: The SpotifyServiceImpl acts as a facade, hiding the complexity of file parsing (GSON) and data processing from the client.

2. Data Transfer Object (DTO): Uses Java Records (SessionDTO, StreamRecordDTO, Token) to transport data across the network efficiently and immutably.

3. Authenticator & Token: A dedicated TokenGenerator creates signed tokens upon login. A TokenStore validates them before every operation, decoupling security from business logic.

4. Client Session State: To keep the server stateless, the History and Cache are stored in a SessionDTO held by the Client. This object is passed to the server with every request and returned with updates.

πŸ“‚ Project Structure

β”œβ”€β”€ client
β”‚   β”œβ”€β”€ Client.java         # Handles user input and local state (SessionDTO)
β”‚   └── Main.java           # Entry point for the Client
β”œβ”€β”€ server
β”‚   β”œβ”€β”€ Server.java         # Registers the RMI Service
β”‚   β”œβ”€β”€ SpotifyServiceImpl.java # Implementation of business logic (Facade)
β”‚   β”œβ”€β”€ TokenGenerator.java     # Singleton for generating RSA signatures
β”‚   └── TokenStore.java         # Validates tokens and signatures
└── common
    β”œβ”€β”€ SpotifyService.java     # RMI Interface
    β”œβ”€β”€ SessionDTO.java         # "Suitcase" for History and Cache
    β”œβ”€β”€ StreamRecordDTO.java    # Represents a single song record
    └── Token.java              # Security token record

πŸ› οΈ Getting Started Prerequisites

Java Development Kit (JDK) 21.

Maven (for dependency management, e.g., GSON).

Your Spotify data files (JSON format).

Installation

1. Clone the repository:
git clone https://github.com/Micg25/spotify-history-analyzer-distributed-system.git
cd spotify-history-analyzer-distributed-system

2. Add Data: Place your Spotify JSON files (e.g., Streaming_History_Audio_2023_1.json) inside the folder named: Spotify Extended Streaming History/ in the project root.

3. Compile:
mvn clean install

Usage

1. Start the Server: Run the server.Server class. It will bind the service to the RMI registry (default port 1099).
2. Start the Client: Run the client.Main class.

Michele Guglielmino's Project for Ingegneria dei Sistemi Distribuiti - UNICT.

About

Progetto per la materia Ingegneria Dei Sistemi Distribuiti

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages