# se-tinf22b6/statify architecture

> Architecture diagram of the GitHub repository se-tinf22b6/statify, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/se-tinf22b6/statify
- Repository: https://github.com/se-tinf22b6/statify

## Overview

##### Project Type and Purpose
- Statify is a full-stack web application that integrates with the Spotify Web API. Its purpose is to connect to a user’s Spotify account to analyze and provide statistics on listening habits (e.g., most-played genres, popular artists, time-of-day usage).
- The project is decomposed into a frontend client and a backend service, with a database component, and it communicates with an external service (the Spotify Web API).

##### Analyzing the File Structure
- Directories:
- “backend_service”: Contains a Java/Spring Boot application powered by Maven (look for pom.xml, src/main/java, etc.).
- “web_app”: Contains a Node.js/React front-end (package.json, package-lock.json, src folder).
- “Database”: Contains an SQL script to create or set up statify_db.
- “.github”: Contains CI/CD workflows for Maven and Node.js, which indicate use of automated builds/tests.
- Notice the separation between backend and frontend components, which suggests a clear division of concerns and an API interface between the layers.

##### Components and Interactions

a. Main Components:
- Frontend (web_app): A React-based client providing user interface. It communicates with the backend to retrieve data and display statistics.
- Backend Service (backend_service): A Spring Boot application handling business logic, API endpoints, and integration with the database. It will likely provide REST endpoints for the frontend.
- Database: A MySQL database (as indicated in the tech stack) that stores user data and listening statistics.
- External API (Spotify Web API): Acts as a third-party integration allowing the application to retrieve user-specific music data from Spotify.
- CI/CD Processes: You may optionally include the CI/CD pipelines (as per the GitHub workflows) to represent continuous integration aspects.

b. Relationships and Interactions:
- The Frontend sends HTTP requests to the Backend, which processes the request and interacts with the Database.
- The Backend communicates with the Spotify Web API to fetch or update information about user listening habits as required.
- From the Frontend to the Backend for data exchange.
- From the Backend to the Database for CRUD operations.
- From the Backend to the Spotify Web API for external interactions.
- Optionally, illustrate the CI/CD process interacting with the repository during builds and deployments.

c. Architectural Patterns and Design Principles:
- The separation between the frontend (React) and backend (Spring Boot) demonstrates a classic full-stack separation.
- Usage of REST APIs (implied by the Spring Boot setup) and possible MVC patterns in the backend for handling requests.
- Clean separation of concerns and secure integration with external services (Spotify).
- Use of Maven for build automation in the backend and Node.js package management in the frontend.

d. Relevant Technologies:
- Frontend: React, JavaScript, Node.js.
- Backend: Java, Spring Boot, Maven.
- Database: MySQL (supported by the provided SQL script).
- External: Spotify Web API.
- DevOps: GitHub workflows for CI/CD processes.

##### Elements
- Use clear labels for each component:
- “React Frontend” or “Web Client”
- “Spring Boot Backend”
- “MySQL Database”
- “Spotify Web API”
- Optionally, “CI/CD Pipeline”
- Data flow from the frontend to the backend (e.g., HTTP/REST).
- Backend’s interactions with both the database (data persistence/retrieval) and the Spotify API (external data services).
- Differentiate between presentation layer (frontend), application logic (backend), and data storage (database).
- Optional annotations:
- Mention key technologies (React, Spring Boot, MySQL) near their components.
- You may also include brief notes about CI/CD workflows for clarity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CI/CD Process"
        CI["CI/CD Pipeline"]:::ci
    end

    subgraph "Presentation Layer"
        FE["React Frontend"]:::frontend
    end

    subgraph "Application Layer"
        BE["Spring Boot Backend"]:::backend
    end

    subgraph "Data Layer"
        DB["MySQL Database"]:::database
    end

    subgraph "External Services"
        SP["Spotify Web API"]:::external
    end

    CI -->|"trigger"| FE
    CI -->|"trigger"| BE
    FE -->|"HTTP/REST"| BE
    BE -->|"CRUD"| DB
    BE -.->|"API_Calls"| SP

    click FE "https://github.com/se-tinf22b6/statify/tree/main/web_app"
    click BE "https://github.com/se-tinf22b6/statify/tree/main/backend_service"
    click DB "https://github.com/se-tinf22b6/statify/blob/main/Database/statify_db.sql"
    click CI "https://github.com/se-tinf22b6/statify/tree/main/.github/workflows"

    classDef frontend fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef backend fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef database fill:#f94144,stroke:#333,stroke-width:2px;
    classDef external fill:#577590,stroke:#333,stroke-width:2px;
    classDef ci fill:#277da1,stroke:#333,stroke-width:2px;
```
