# pierreminiggio/youtube-channel-video-informations-saver architecture

> Architecture diagram of the GitHub repository pierreminiggio/youtube-channel-video-informations-saver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pierreminiggio/youtube-channel-video-informations-saver
- Repository: https://github.com/pierreminiggio/youtube-channel-video-informations-saver

## Overview

##### Project Overview and Type
- This project is a PHP application designed to save information about YouTube channels and videos.
- It is not a full-stack web application (i.e. no frontend directory exists) but rather a back-end or command-line tool that interacts with a MySQL database.
- The application reads configuration (from config.php, copied from config_example.php), initializes core components, sets up a database connection, and performs CRUD operations via repository classes.

##### Main Components
- Entry Point: main.php acts as the application’s starting point.
- Application Core: src/App.php likely contains the business logic or the overall orchestration for the application.
- Configuration: The config.php (created from config_example.php) holds the settings and possibly database credentials.
- Database Connection Layer: src/Connection/DatabaseConnectionFactory.php provides an abstraction to create database connection instances.
- Domain/Entity Layer: Under src/Youtube, for example, src/Youtube/YoutubeVideo.php represents the YouTube video model/entity.
- Data Access Layer (Repositories):
- src/Repository/YoutubeChannelRepository.php handles database operations related to YouTube channels.
- src/Repository/YoutubeVideoRepository.php handles database operations related to YouTube videos.
- Database: The provided SQL script in the README indicates that MySQL is used. The tables “youtube_channel” and “youtube_video” persist the data.

##### Relationships and Interactions
- main.php → App Component: The main entry instantiates the App (from src/App.php).
- App Component → Database Connection Factory: The App uses DatabaseConnectionFactory to establish a persistent connection to the MySQL database.
- Database Connection Factory → Database (MySQL): This layer abstracts the connection details.
- App Component → Repositories: YoutubeChannelRepository and YoutubeVideoRepository are used by the App to perform data operations.
- Repositories → Domain Model: The repository logic will create or retrieve instances of YoutubeVideo (and likely similarly structured objects for channels) that represent the business data.
- Configuration File → All Components: The configuration (config.php) is referenced across these components to supply required parameters such as database credentials.

##### Additional Detailed Elements
- If needed, include notes on the expected lifecycle:
- The application starts with main.php, loads configuration, sets up the DatabaseConnection via the factory, and then uses repositories to interact with the MySQL tables “youtube_channel” and “youtube_video”.
- Showing how configuration changes (copying config_example.php to config.php and updating it) feed into the application.

- Clearly labels each component (entry point, core application, configuration, connection layer, repositories, domain models, and the database).
- Highlights key architectural patterns such as the separation of concerns, layered architecture, and use of factories for dependency management.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry & Configuration Layer
    subgraph "Entry & Configuration"
        A["Main Entry (main.php)"]:::core
        B["Application Core (App.php)"]:::core
        C["Config (config.php)"]:::infra
        A -->|"initiates"| B
        C -->|"provides_config"| B
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        D["DB Connection Factory (DatabaseConnectionFactory.php)"]:::infra
        E["Database (MySQL)"]:::db
        B -->|"creates_connection"| D
        D -->|"connects"| E
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        F["YoutubeChannelRepository"]:::repo
        G["YoutubeVideoRepository"]:::repo
        H["Domain Model: YoutubeVideo"]:::domain
        B -->|"handles_channelCRUD"| F
        B -->|"handles_videoCRUD"| G
        F -->|"executes_query"| E
        G -->|"executes_query"| E
        G -->|"maps_to_entity"| H
    end

    %% Click Events
    click A "https://github.com/pierreminiggio/youtube-channel-video-informations-saver/blob/main/main.php"
    click B "https://github.com/pierreminiggio/youtube-channel-video-informations-saver/blob/main/src/App.php"
    click C "https://github.com/pierreminiggio/youtube-channel-video-informations-saver/blob/main/config_example.php"
    click D "https://github.com/pierreminiggio/youtube-channel-video-informations-saver/blob/main/src/Connection/DatabaseConnectionFactory.php"
    click F "https://github.com/pierreminiggio/youtube-channel-video-informations-saver/blob/main/src/Repository/YoutubeChannelRepository.php"
    click G "https://github.com/pierreminiggio/youtube-channel-video-informations-saver/blob/main/src/Repository/YoutubeVideoRepository.php"
    click H "https://github.com/pierreminiggio/youtube-channel-video-informations-saver/blob/main/src/Youtube/YoutubeVideo.php"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef infra fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef repo fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef domain fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef db fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
