# cloneot/pl-maker-api architecture

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

- Interactive diagram: https://gitdiagram.com/cloneot/pl-maker-api
- Repository: https://github.com/cloneot/pl-maker-api

## Overview

##### Main Components

a. Core Application Layer:
- NestJS Application Core
- Authentication Module (Google OAuth)
- YouTube Integration Service
- Configuration Module

b. Resource Modules:
- Users Module
- Music Module
- Playlists Module
- PlaylistItems Module
- Tags Module

c. External Services:
- Google OAuth Service
- YouTube API
- Database (likely TypeORM-based)

**┌─ External Services Layer ─┐**
- Google OAuth          │
- YouTube API           │
- ┘
- ↕
**┌─ Application Layer ──────┐**
- ┌─ Auth Module ───────┐ │
- Google Strategy  │ │
- Auth Guards     │ │
- ┘ │
- ┌─ Core Services ────┐   │
- YouTube Service │   │
- Config Service │   │
- ┘ │
- ┌─ Resource Modules ──┐  │
- Users           │  │
- Music          │  │
- Playlists      │  │
- PlaylistItems  │  │
- Tags           │  │
- ┘ │
- ┘
- ↕
**┌─ Data Layer ────────────┐**
- TypeORM Entities     │
- Database            │
- ┘

##### Important Details to Highlight

a. Module Relationships:
- How the Auth module protects other resources
- YouTube service integration with playlist-related modules
- Relationship between entities (User → Playlist → PlaylistItem → Music)

b. Cross-Cutting Concerns:
- Exception filter flow
- Where decorators are applied
- Configuration system's influence

##### Technical Stack Indicators

- NestJS as the primary framework
- TypeScript as the programming language
- TypeORM for database operations
- Google OAuth for authentication
- YouTube API integration
- Docker for containerization
- Jest for testing

Remember to emphasize the modular nature of the NestJS application and how the different components interact through dependency injection and the module system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External["External Services Layer"]
        GoogleOAuth["Google OAuth Service"]:::external
        YouTubeAPI["YouTube API"]:::external
    end

    subgraph App["Application Layer"]
        subgraph Core["Core Components"]
            NestCore["NestJS Core"]:::core
            click NestCore "https://github.com/cloneot/pl-maker-api/blob/main/src/app.module.ts"
            Config["Configuration Module"]:::core
            click Config "https://github.com/cloneot/pl-maker-api/blob/main/src/common/config/configuration.ts"
            ExceptionFilter["Exception Filter"]:::core
            click ExceptionFilter "https://github.com/cloneot/pl-maker-api/blob/main/src/common/exception/service-exception.to.http-exception.filter.ts"
        end

        subgraph Auth["Authentication Module"]
            AuthService["Auth Service"]:::auth
            click AuthService "https://github.com/cloneot/pl-maker-api/blob/main/src/auth/auth.service.ts"
            AuthController["Auth Controller"]:::auth
            click AuthController "https://github.com/cloneot/pl-maker-api/blob/main/src/auth/auth.controller.ts"
            GoogleStrategy["Google Strategy"]:::auth
            click GoogleStrategy "https://github.com/cloneot/pl-maker-api/blob/main/src/auth/google.strategy.ts"
            AuthGuards["Auth Guards"]:::auth
            click AuthGuards "https://github.com/cloneot/pl-maker-api/blob/main/src/auth/google-auth.guard.ts"
        end

        subgraph Integration["Integration Services"]
            YouTubeService["YouTube Service"]:::integration
            click YouTubeService "https://github.com/cloneot/pl-maker-api/blob/main/src/common/youtube/youtube.service.ts"
            YouTubeGuard["YouTube Guard"]:::integration
            click YouTubeGuard "https://github.com/cloneot/pl-maker-api/blob/main/src/common/youtube/youtube.guard.ts"
        end

        subgraph Resources["Resource Modules"]
            Users["Users Module"]:::resource
            click Users "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/users/users.module.ts"
            Music["Music Module"]:::resource
            click Music "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/music/music.module.ts"
            Playlists["Playlists Module"]:::resource
            click Playlists "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/playlists/playlists.module.ts"
            PlaylistItems["PlaylistItems Module"]:::resource
            click PlaylistItems "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/playlistitems/playlistitems.module.ts"
            Tags["Tags Module"]:::resource
            click Tags "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/tags/tags.module.ts"
        end

        subgraph Decorators["Common Decorators"]
            PublicDecorator["Public Decorator"]:::decorator
            click PublicDecorator "https://github.com/cloneot/pl-maker-api/blob/main/src/common/decorator/public.decorator.ts"
            UserDecorator["User Decorator"]:::decorator
            click UserDecorator "https://github.com/cloneot/pl-maker-api/blob/main/src/common/decorator/user.decorator.ts"
            YouTubeDecorator["YouTube Decorator"]:::decorator
            click YouTubeDecorator "https://github.com/cloneot/pl-maker-api/blob/main/src/common/decorator/youtube.decorator.ts"
        end
    end

    subgraph Data["Data Layer"]
        Database[(Database)]:::database
        UserEntity["User Entity"]:::entity
        click UserEntity "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/users/user.entity.ts"
        MusicEntity["Music Entity"]:::entity
        click MusicEntity "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/music/music.entity.ts"
        PlaylistEntity["Playlist Entity"]:::entity
        click PlaylistEntity "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/playlists/playlist.entity.ts"
        PlaylistItemEntity["PlaylistItem Entity"]:::entity
        click PlaylistItemEntity "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/playlistitems/playlistitem.entity.ts"
        TagEntity["Tag Entity"]:::entity
        click TagEntity "https://github.com/cloneot/pl-maker-api/blob/main/src/resources/tags/tag.entity.ts"
    end

    %% Relationships
    GoogleOAuth --> AuthService
    YouTubeAPI --> YouTubeService
    AuthService --> AuthController
    GoogleStrategy --> AuthService
    AuthGuards --> Resources
    YouTubeService --> Resources
    YouTubeGuard --> Resources
    Resources --> Database
    UserEntity --> Database
    MusicEntity --> Database
    PlaylistEntity --> Database
    PlaylistItemEntity --> Database
    TagEntity --> Database
    Decorators --> Resources
    ExceptionFilter --> App

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef auth fill:#e67e22,stroke:#d35400,color:white
    classDef integration fill:#9b59b6,stroke:#8e44ad,color:white
    classDef resource fill:#2ecc71,stroke:#27ae60,color:white
    classDef database fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef entity fill:#bdc3c7,stroke:#95a5a6,color:white
    classDef external fill:#e74c3c,stroke:#c0392b,color:white
    classDef decorator fill:#f1c40f,stroke:#f39c12,color:black
```
