# dubeyshubham108/tunewave-music-streaming-platform architecture

> Architecture diagram of the GitHub repository dubeyshubham108/tunewave-music-streaming-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dubeyshubham108/tunewave-music-streaming-platform
- Repository: https://github.com/dubeyshubham108/tunewave-music-streaming-platform

## Overview

##### Project type and purpose
- This is a full-stack MERN + PostgreSQL microservices music-streaming platform.
- It consists of three Node.js/TypeScript microservices (user service, song service, admin service), a React frontend (user UI + admin dashboard), and a shared PostgreSQL database.

##### Core architectural components
a. Clients (Web UIs)
- Music Streaming Web App (React)
- Admin Dashboard (React)
b. API Layer
- (Optional) API Gateway or reverse-proxy routing incoming UI/REST calls to the proper service
c. Microservices
- User Service (Express/TypeScript)
- Song Service (Express/TypeScript)
- Admin Service (Express/TypeScript)
d. Data Store
- PostgreSQL instance (single cluster or per-service schemas)

##### Relationships & data flow
- All UI traffic (user or admin) flows down through the API Gateway (or directly hits each service).
- Each microservice uses its config/db module to connect to PostgreSQL.
- The Admin Service may also call the User and Song services or directly query shared tables for analytics.

##### Architectural patterns & principles
- Microservices: each service is independently deployable, owns its own routes, controllers, models (see src/model.ts in user service).
- Shared database vs. separate schemas: use one cluster with per-service schemas or logical separation.
- TryCatch wrapper around all controllers for consistent error handling.
- TS → JS build pipeline under dist/ for each service.

##### Technologies & frameworks
- Node.js + Express + TypeScript
- PostgreSQL (pg library configured in src/config/db.ts)
- React for UIs (not in file tree but implied by MERN)
- tsconfig.json, package.json for build/dependencies

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients Layer
    subgraph "Clients"
        MusicWebApp["Music Streaming Web App"]:::ui
        AdminDashboard["Admin Dashboard"]:::ui
    end

    MusicWebApp -->|"HTTP/REST"| APIGateway
    AdminDashboard -->|"HTTP/REST"| APIGateway

    %% API Gateway
    APIGateway["API Gateway (Nginx/Traefik)"]:::infra

    %% User Service
    APIGateway -->|"routes requests"| UserService
    subgraph "User Service" 
        direction TB
        USrc["src"]:::service
        UController["controller.ts"]:::service
        URoute["route.ts"]:::service
        UModel["model.ts"]:::service
        UTryCatch["TryCatch.ts"]:::service
        UMiddleware["middleware.ts"]:::service
        UDist["dist"]:::service
    end

    UserService -->|"uses src/dist"| USrc
    USrc --> UController
    USrc --> URoute
    USrc --> UModel
    USrc --> UTryCatch
    USrc --> UMiddleware
    USrc --> UDist

    %% Song Service
    UserService -->|"HTTP/REST"| SongService
    subgraph "Song Service" 
        direction TB
        SSrc["src"]:::service
        SController["controller.ts"]:::service
        SRoute["route.ts"]:::service
        SDBConfig["config/db.ts"]:::service
        STryCatch["TryCatch.ts"]:::service
        SDist["dist"]:::service
    end

    SongService -->|"uses src/dist"| SSrc
    SSrc --> SController
    SSrc --> SRoute
    SSrc --> SDBConfig
    SSrc --> STryCatch
    SSrc --> SDist

    %% Admin Service
    SongService -->|"HTTP/REST"| AdminService
    subgraph "Admin Service" 
        direction TB
        ASrc["src"]:::service
        AController["controller.ts"]:::service
        ARoute["route.ts"]:::service
        ADBConfig["config/db.ts"]:::service
        ADataUri["config/dataUri.ts"]:::service
        ATryCatch["TryCatch.ts"]:::service
        AMiddleware["middleware.ts"]:::service
        ADist["dist"]:::service
    end

    AdminService -->|"uses src/dist"| ASrc
    ASrc --> AController
    ASrc --> ARoute
    ASrc --> ADBConfig
    ASrc --> ADataUri
    ASrc --> ATryCatch
    ASrc --> AMiddleware
    ASrc --> ADist

    %% Database
    AdminService -->|"SQL queries"| PostgreSQL
    PostgreSQL["PostgreSQL Database"]:::db

    %% Click Events
    click USrc "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/tree/main/user service/src/"
    click UController "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/user service/src/controller.ts"
    click URoute "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/user service/src/route.ts"
    click UModel "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/user service/src/model.ts"
    click UTryCatch "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/user service/src/TryCatch.ts"
    click UMiddleware "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/user service/src/middleware.ts"
    click UDist "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/tree/main/user service/dist/"

    click SSrc "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/tree/main/song service/src/"
    click SController "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/song service/src/controller.ts"
    click SRoute "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/song service/src/route.ts"
    click SDBConfig "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/song service/src/config/db.ts"
    click STryCatch "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/song service/src/TryCatch.ts"
    click SDist "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/tree/main/song service/dist/"

    click ASrc "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/tree/main/admin service/src/"
    click AController "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/admin service/src/controller.ts"
    click ARoute "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/admin service/src/route.ts"
    click ADBConfig "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/admin service/src/config/db.ts"
    click ADataUri "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/admin service/src/config/dataUri.ts"
    click ATryCatch "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/admin service/src/TryCatch.ts"
    click AMiddleware "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/blob/main/admin service/src/middleware.ts"
    click ADist "https://github.com/dubeyshubham108/tunewave-music-streaming-platform/tree/main/admin service/dist/"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,color:#000;
    classDef service fill:#90EE90,stroke:#000,color:#000;
    classDef infra fill:#FFA500,stroke:#000,color:#000;
    classDef db fill:#FFA500,stroke:#000,color:#000;
```
