# monamatv/tadify architecture

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

- Interactive diagram: https://gitdiagram.com/monamatv/tadify
- Repository: https://github.com/monamatv/tadify

## Overview

##### Main Components

a) Client-Side (Frontend):
- Next.js Application Layer
- Component Library
- Theme System (Light/Dark)
- Client-side State Management

b) Server-Side:
- Next.js API Routes
- Authentication Layer
- External Service Integrations:
- Spotify API Integration
- AI Services (ChatGPT/Gemini)

c) Database Layer:
- Prisma ORM
- Database (implied from prisma.js)

**[Client Layer]**
- ↑↓
**[Server Layer]**
- ↑↓
**[External Services & Database]**

##### Detailed Component Breakdown

- Relationship with utility functions (src/utils)

- API routes (/api/*)
- Authentication flow (/api/login)
- Playlist management endpoints
- Music data endpoints

- Spotify API Integration
- AI Services Integration (ChatGPT/Gemini)
- Future Payment Gateway (from Todo list)

##### Key Flows to Highlight

a) Authentication Flow:
**User → Login Request → Spotify OAuth → Token Storage**

b) Playlist Generation Flow:
**User Prompt → AI Service → Spotify API → Playlist Creation**

##### Important Architectural Patterns

- API Route Pattern: Show how the Next.js API routes handle different functionalities
- Component Architecture: Demonstrate the relationship between pages and components
- Service Integration Pattern: Show how external services are integrated

##### Technical Stack Indicators

- Next.js
- React
- Tailwind CSS
- Prisma ORM
- Spotify SDK
- AI Services

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef database fill:#e67e22,stroke:#d35400,color:white
    classDef utility fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        Pages["Pages Container"]
        Components["Component Library"]
        Theme["Theme System"]
        ClientState["Client State"]
    end

    %% Core UI Components
    subgraph CoreUI
        Button["Button Component"]
        Modal["Modal Component"]
        Nav["Navigation"]
        Loading["Loading Component"]
    end

    %% Page Components
    subgraph Pages
        Home["Home Page"]
        Artists["Artists Page"]
        Playlists["Playlists Page"]
        Tracks["Tracks Page"]
        Profile["Profile Page"]
    end

    %% Playlist Generation Components
    subgraph PlaylistGen
        PlaylistForm["Playlist Form"]
        PromptInput["Prompt Input"]
        SelectTracks["Track Selection"]
    end

    %% API Layer
    subgraph APILayer
        Auth["Authentication API"]
        PlaylistAPI["Playlist API"]
        ArtistAPI["Artist API"]
        TrackAPI["Track API"]
        UserAPI["User API"]
        GenerateAPI["Generation API"]
    end

    %% External Services
    subgraph External
        SpotifyAPI["Spotify API"]
        AIServices["AI Services"]
        Future["Future Integrations"]
    end

    %% Database Layer
    Database[(Database)]
    PrismaORM["Prisma ORM"]

    %% Relationships
    Pages --> CoreUI
    Pages --> PlaylistGen
    Auth --> SpotifyAPI
    GenerateAPI --> AIServices
    PlaylistAPI --> SpotifyAPI
    PrismaORM --> Database
    APILayer --> PrismaORM

    %% Click Events
    click Components "https://github.com/MonamaTV/tadify/tree/main/src/components"
    click Auth "https://github.com/MonamaTV/tadify/blob/main/pages/api/login.js"
    click SpotifyAPI "https://github.com/MonamaTV/tadify/blob/main/src/utils/spotify.js"
    click GenerateAPI "https://github.com/MonamaTV/tadify/blob/main/pages/api/generate.js"
    click PrismaORM "https://github.com/MonamaTV/tadify/blob/main/src/utils/prisma.js"
    click Playlists "https://github.com/MonamaTV/tadify/tree/main/pages/playlists"
    click PlaylistAPI "https://github.com/MonamaTV/tadify/tree/main/pages/api/playlist"
    click Artists "https://github.com/MonamaTV/tadify/tree/main/pages/artists"
    click ArtistAPI "https://github.com/MonamaTV/tadify/blob/main/pages/api/artists.js"
    click Tracks "https://github.com/MonamaTV/tadify/tree/main/pages/tracks"
    click TrackAPI "https://github.com/MonamaTV/tadify/blob/main/pages/api/tracks.js"
    click Profile "https://github.com/MonamaTV/tadify/tree/main/pages/profile"
    click UserAPI "https://github.com/MonamaTV/tadify/blob/main/pages/api/users.js"
    click Theme "https://github.com/MonamaTV/tadify/blob/main/styles/globals.css"
    click Button "https://github.com/MonamaTV/tadify/blob/main/src/components/Button.js"
    click Modal "https://github.com/MonamaTV/tadify/blob/main/src/components/Modal.js"
    click Nav "https://github.com/MonamaTV/tadify/blob/main/src/components/Nav.js"
    click Loading "https://github.com/MonamaTV/tadify/blob/main/src/components/Loading.js"
    click PlaylistForm "https://github.com/MonamaTV/tadify/blob/main/src/components/PlaylistForm.js"
    click PromptInput "https://github.com/MonamaTV/tadify/blob/main/src/components/PromptInput.js"
    click SelectTracks "https://github.com/MonamaTV/tadify/blob/main/src/components/SelectRecommendedTracks.js"

    %% Style Applications
    class Pages,Components,Theme,ClientState frontend
    class Auth,PlaylistAPI,ArtistAPI,TrackAPI,UserAPI,GenerateAPI api
    class SpotifyAPI,AIServices,Future external
    class Database,PrismaORM database
    class CoreUI,PlaylistGen frontend
```
