# 23klhuynh/soccer-api architecture

> Architecture diagram of the GitHub repository 23klhuynh/soccer-api, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/23klhuynh/soccer-api
- Repository: https://github.com/23klhuynh/soccer-api

## Overview

##### Project type and purpose
- This is primarily a backend data‐pipeline + REST API service. It ingests raw data via a web scraper, stages/normalizes it in CSV, persists it in PostgreSQL, then exposes it via a Spring Boot–based HTTP API.

##### File structure
- Top level:
- scraping/ (Python scraper using BeautifulSoup)
- stats.csv (scraped, intermediate data)
- soccer-stats/ (Spring Boot service)
- soccer-stats:
- pom.xml / Maven wrapper – build and dependency management
- src/main/java/com/soccerstats – controllers, services, repositories (MVC pattern)
- src/main/resources/application.properties – DB connection config
- src/test – unit/integration tests

##### Key insights from README
- Scraping → CSV → PostgreSQL → API
- Endpoints: GET /api/v1/player (all players or filtered by name)

##### Main components and interactions
a. External Websites
- Source of raw HTML (Europe’s top competitions).
b. Scraping Service (Python)
- Uses BeautifulSoup to parse HTML → produces stats.csv.
c. Data Store
- stats.csv staging, then a PostgreSQL database (configured in application.properties).
d. API Service (Java Spring Boot)
- Controller layer (PlayerController)
- Service layer (PlayerService)
- Repository layer (PlayerRepository → JPA/Hibernate to PostgreSQL)
e. Clients
- Web/mobile/CLI clients invoking HTTP endpoints

##### Architectural patterns & principles
- ETL pipeline: Extract (scraper) → Transform (normalize into CSV) → Load (PostgreSQL)
- Layered MVC in Spring Boot: clear separation of concerns
- Configuration‐as‐code: application.properties for environment settings
- Build automation via Maven

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Ingestion Layer
    ExternalSites["External Websites"]:::client
    Scraper["Scraping Service: main.py"]:::ingestion
    ExternalSites -->|"GET HTML"| Scraper
    click Scraper "https://github.com/23klhuynh/soccer-api/blob/main/scraping/main.py"

    %% Staging Storage
    CSV["stats.csv"]:::storage
    Scraper -->|"write CSV"| CSV
    click CSV "https://github.com/23klhuynh/soccer-api/blob/main/stats.csv"

    %% Persistent Storage
    DB["PostgreSQL"]:::storage
    CSV -->|"LOAD CSV→DB"| DB

    %% Build & Run
    Maven["Maven Build: pom.xml"]:::app
    click Maven "https://github.com/23klhuynh/soccer-api/blob/main/soccer-stats/pom.xml"
    Maven -->|"compile & package"| SpringApp

    %% Spring Boot Application
    subgraph "Spring Boot Service" 
        direction TB
        SpringApp["Spring Boot Jar"]:::app
        Entry["SoccerStatsApplication.java"]:::app
        click Entry "https://github.com/23klhuynh/soccer-api/blob/main/soccer-stats/src/main/java/com/soccerstats/soccer_stats/SoccerStatsApplication.java"
        Config["application.properties"]:::app
        click Config "https://github.com/23klhuynh/soccer-api/blob/main/soccer-stats/src/main/resources/application.properties"
        Controller["PlayerController"]:::app
        click Controller "https://github.com/23klhuynh/soccer-api/blob/main/soccer-stats/src/main/java/com/soccerstats/soccer_stats/Player/PlayerController.java"
        Service["PlayerService"]:::app
        click Service "https://github.com/23klhuynh/soccer-api/blob/main/soccer-stats/src/main/java/com/soccerstats/soccer_stats/Player/PlayerService.java"
        Repository["PlayerRepository"]:::app
        click Repository "https://github.com/23klhuynh/soccer-api/blob/main/soccer-stats/src/main/java/com/soccerstats/soccer_stats/Player/PlayerRepository.java"
        Entity["Player.java"]:::app
        click Entity "https://github.com/23klhuynh/soccer-api/blob/main/soccer-stats/src/main/java/com/soccerstats/soccer_stats/Player/Player.java"
        Tests["SoccerStatsApplicationTests.java"]:::app
        click Tests "https://github.com/23klhuynh/soccer-api/blob/main/soccer-stats/src/test/java/com/soccerstats/soccer_stats/SoccerStatsApplicationTests.java"
    end

    %% Application Flow
    SpringApp --> Entry
    Entry -->|"reads config"| Config
    Entry --> Controller
    Controller -->|"calls"| Service
    Service -->|"uses"| Repository
    Repository -->|"SELECT player data"| DB
    Controller -->|"JSON response"| Clients

    %% Clients
    Clients["Clients (Web/Mobile/CLI)"]:::client

    click Clients "https://github.com/23klhuynh/soccer-api/tree/main/Clients"

    classDef ingestion fill:#b2f2bb,stroke:#2f9e44,color:#2f9e44
    classDef storage fill:#ffe8a1,stroke:#f76707,color:#d9480f
    classDef app fill:#bbe1fa,stroke:#2b8a3e,color:#1864ab
    classDef client fill:#d9d9d9,stroke:#868e96,color:#495057
```
