Skip to content

LTPPPP/Brainify

Repository files navigation

Brainify

Brainify Logo

Introduction

Brainify is a modern music management and streaming platform delivering personalized, intelligent, and secure listening experiences for both enterprises and individual users.

Tech Stack

Next.js React TypeScript Tailwind CSS ESLint .NET 8 C# SQL Server Entity Framework Core Redis Docker Git

  • Frontend: Next.js (App Router), TypeScript, React, Tailwind CSS, ESLint
  • State & Data: Custom React hooks, Axios client with interceptors, pagination/infinite loading
  • Backend: ASP.NET Core (.NET 8), C#, RESTful APIs, FluentValidation
  • Microservices: User, Music Catalog, Playlist, Streaming, Notification (separate services)
  • Database: SQL Server (schemas per service), SQL scripts for migration/seed
  • ORM: Entity Framework Core
  • Cache & Realtime: Redis (redis.conf), user notifications (realtime-capable)
  • Auth & Security: JWT (Access/Refresh), role-based authorization, password reset/change
  • DevOps: Docker, Docker Compose, multi-stage Dockerfile (frontend), Git
  • Extras: Python SoundCloud crawler for song metadata (soundcloud_crawler/)

Architecture & Capabilities

  • Overview: Domain-aligned microservices communicating primarily via REST. Next.js frontend talks to each service through configured base URLs or an API gateway if present.
  • Core services:
    • User.Api: Sign up/in, profile, forgot/change password, roles & permissions, token issuance/refresh.
    • MusicCatalog.Api: Artists, albums, songs, genres, search.
    • Playlist.Api: Create/update/delete playlists, manage playlist songs, like/save.
    • Streaming.Api: Playback endpoints/URLs, listen tracking.
    • Notification.Api: Send/receive user notifications, read status, potential realtime integration.
  • Frontend:
    • App Router routes like auth, profile, library, search, artist, album, playlist, liked-songs, upload, admin, etc.
    • Music player store (music-player, music-player-streaming), AuthProvider, HTTP interceptors, modular UI components (artist/album/playlist/music).
    • File upload (songs/covers), player demo page, tutorial wrapper.
  • Security:
    • JWT auth with access/refresh tokens, protected routes by role, robust refresh flow.
    • HTTP interceptors handle token attach/refresh/redirect on 401.
  • Performance & UX:
    • Client-side caching, pagination/prefetching; Next.js bundle optimization and lazy loading.
    • Redis caching for hot data and notification support.
  • Data & Storage:
    • SQL Server per bounded context (schemas under microservices/database).
    • Media/asset storage managed via streaming/hosting layer per deployment setup.
  • Deployment:
    • Docker Compose bootstraps DB, Redis, APIs, and frontend for local/dev.
    • Each .NET service can have its own Dockerfile; frontend uses multi-stage Dockerfile.

Microservices

There are 5 microservices under microservices/backends/:

  • User.Api: Authentication (login/register), JWT issuance/refresh, user profile management, forgot/change password, roles and permissions.
  • MusicCatalog.Api: Artists, albums, songs, genres management; search and metadata queries.
  • Playlist.Api: Create/update/delete playlists, add/remove songs to playlists, like/save playlists.
  • Streaming.Api: Playback endpoints/URLs and listen tracking.
  • Notification.Api: Send/receive user notifications, read/unread status, realtime-capable integration.

Diagrams

System Architecture (High-level)

flowchart LR
  subgraph Client
    FE[Next.js Frontend]
  end

  subgraph Infra
    REDIS[(Redis Cache)]
    DB[(SQL Server)]
  end

  %% Optional gateway layer (can be bypassed by FE calling services directly)
  %% (optional)
  GW[API Gateway]

  subgraph Services
    U[User.Api]
    MC[MusicCatalog.Api]
    PL[Playlist.Api]
    ST[Streaming.Api]
    NT[Notification.Api]
    NTM[NotificationMicroservice.Api]
  end

  FE --> GW
  FE -.-> U
  FE -.-> MC
  FE -.-> PL
  FE -.-> ST
  FE -.-> NT

  GW --> U
  GW --> MC
  GW --> PL
  GW --> ST
  GW --> NT

  U <--> DB
  MC <--> DB
  PL <--> DB
  ST <--> DB
  NT <--> DB

  U <--> REDIS
  MC <--> REDIS
  PL <--> REDIS
  ST <--> REDIS
  NT <--> REDIS

  NTM --> NT
  NTM <--> REDIS
  NTM <--> DB
Loading

Auth & Token Refresh (Sequence)

sequenceDiagram
  autonumber
  participant FE as Frontend (Next.js)
  participant UA as User.Api
  participant RED as Redis
  participant DB as SQL Server

  FE->>UA: POST /auth/login (email, password)
  UA->>DB: Validate credentials
  DB-->>UA: User record ok
  UA->>RED: Store session/refresh token (optional)
  UA-->>FE: 200 { accessToken, refreshToken }

  Note over FE: Access token expires after short TTL
  FE->>UA: POST /auth/refresh (refreshToken)
  UA->>RED: Validate refresh token
  RED-->>UA: OK
  UA-->>FE: 200 { new accessToken, new refreshToken }
Loading

Playlist Data Flow

flowchart TB
  FE[Frontend] -->|Create Playlist| PL[Playlist.Api]
  PL --> DB[(SQL Server)]
  FE -->|Add Song to Playlist| PL
  PL --> MC[MusicCatalog.Api]
  MC --> DB
  FE -->|Like Playlist| PL
  PL --> REDIS[(Redis)]
  PL --> NT[Notification.Api]
  NT --> NTM[NotificationMicroservice.Api]
  NTM --> REDIS
  NT --> FE
Loading

Docker Compose (Local Dev Topology)

flowchart LR
  subgraph Docker Compose
    MSSQL[(mssql)]
    RDS[(redis)]
    USER[User.Api]
    MCAT[MusicCatalog.Api]
    PLS[Playlist.Api]
    STR[Streaming.Api]
    NOTI[Notification.Api]
    NOTI_W[NotificationMicroservice.Api]
    WEB[frontend]
  end

  WEB <--> USER
  WEB <--> MCAT
  WEB <--> PLS
  WEB <--> STR
  WEB <--> NOTI

  USER --> MSSQL
  MCAT --> MSSQL
  PLS --> MSSQL
  STR --> MSSQL
  NOTI --> MSSQL
  NOTI_W --> MSSQL

  USER <--> RDS
  MCAT <--> RDS
  PLS <--> RDS
  STR <--> RDS
  NOTI <--> RDS
  NOTI_W <--> RDS
Loading

Main Features

  • Manage users, artists, albums, playlists, and songs
  • Listening history and personalized recommendations
  • Smart search with search history
  • Notification management and personal settings
  • Social login (extensible)
  • Song interactions (like, download) and artist following
  • System administration, configuration, and recommendation cache

Folder Structure (short)

  • frontend/: Next.js app (App Router), components, hooks, services, store
  • microservices/backends/: .NET 8 APIs (User, MusicCatalog, Playlist, Streaming, Notification)
  • microservices/database/: SQL schemas per service
  • microservices/docs/: API docs and microservices overview
  • soundcloud_crawler/: Python crawler for SoundCloud data
  • docker-compose.yml: Root compose for the full stack
  • redis.conf: Redis configuration

Note: The default Docker Compose uses the Redis image defaults. You can mount redis.conf and adjust the command in docker-compose.yml if you need custom tuning.

Run Locally (Quickstart)

Option 1: Docker Compose (Recommended)

  1. Clone the repository and navigate to project root
git clone <repository-url>
cd Brainify
  1. Copy the environment template and configure variables
cp .env.example .env
# Edit values in .env for your environment
  1. Start all services
docker-compose up -d

Services started by default:

  • SQL Server: host localhost:1533 (container 1433)
  • Redis: localhost:6379
  • User API: http://localhost:5003
  • Music Catalog API: http://localhost:5001
  • Playlist API: http://localhost:5002
  • Streaming API: http://localhost:5004
  • Notification API: http://localhost:5005
  • Frontend: http://localhost:3000
  1. Check service health
docker-compose ps
docker-compose logs -f
  1. Stop all services
docker-compose down

Option 2: Manual Setup

  1. Start the database
cd microservices
sudo docker-compose up -d
  1. Start backend APIs (example: User.Api)
cd microservices/backends/User.Api
dotnet restore
dotnet run
  1. Start the frontend
cd frontend
npm install
npm run dev

By default, the frontend runs at http://localhost:3000. Backend base URLs are configured via environment variables:

NEXT_PUBLIC_USER_API_URL=http://localhost:5003
NEXT_PUBLIC_MUSIC_CATALOG_API_URL=http://localhost:5001
NEXT_PUBLIC_PLAYLIST_API_URL=http://localhost:5002
NEXT_PUBLIC_STREAMING_API_URL=http://localhost:5004
NEXT_PUBLIC_NOTIFICATION_API_URL=http://localhost:5005

For Docker builds, these are passed as build args and environment variables (see docker-compose.yml).

Contribution

Please review CONTRIBUTING.md for code style, branch naming, pull request process, and testing expectations.

License

This project is licensed under MIT — see LICENSE in the repository root.


Brainify Icon

About

A modern music management and streaming platform delivering personalized, intelligent, and secure listening experiences for both enterprises and individual users.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors