• Stars
    star
    2,533
  • Rank 18,118 (Top 0.4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Spotify client built with Angular 15, Nx Workspace, ngrx, TailwindCSS and ng-zorro

Angular Spotify

A simple Spotify client built with Angular 15, Nx workspace, ngrx, TailwindCSS and ng-zorro.

I have recently shared about #angularspotify at AngularAir, you can watch the session here ๐Ÿ‘‰ youtu.be/uPB0KHKlrU8

Working application

Check out the live application -> https://spotify.trungk18.com

Spotify premium is required for the Web Playback SDK to play music. If you are using a free account, you can still browse the app, but it couldn't play the music. Sorry about that ๐Ÿคฃ

Angular Spotify Demo

Angular Spotify Visualizer

Angular Spotify Browse

Angular Spotify Blurry Background

Angular Spotify PWA

Angular Spotify Web Player

Support

If you like my work, feel free to:

  • โญ this repository. And we will be happy together :)
  • Tweet about Angular Spotify
  • Buy Me A Coffee

Thanks a bunch for stopping by and supporting me!

Who is it for ๐Ÿคทโ€โ™€๏ธ

I still remember Window Media Player on windows has the visualization when you start to play the music, and I wanted to have the same experience when listening to Spotify. That is the reason I started this project.

I found that there weren't many resources on building a proper real-world scale application, and that's my focus for sharing. I made a Jira clone application as the first one for that purpose. Nx workspace is getting more and more attention from the Angular community, but people are always confused about how to architect and set up an Nx project. I hope Angular Spotify will give you more insight on that even though it is my first project using Nx ๐Ÿคฃ


You know I am one of the moderators of Angular Vietnam. Recently, I also started Angular Singapore. This piece of work is my other long-term plan to bring Angular knowledge to more people. I desire to advocate and grow the Angular developer community in Singapore and Vietnam :)

Tech stack

Tech logos

I experimented with the ngrx/component store for AuthStore and UIStore. It might not be a best practice, and I will refactor it very soon. Just FYI ๐Ÿคฃ

High-level design

See my original notes on Nx workspace structure for NestJS and Angular

Principles

All components are following:

  • OnPush Change Detection and async pipes: all components use observable and async pipe for rendering data without any single manual subscribe. Only some places are calling subscribe for dispatching an action, which I will have a refactor live stream session with my friend @nartc to use the component store for a fully subscribe-less application.
  • SCAMs (single component Angular modules) for tree-shakable components, meaning each component will have a respective module. For example, a RegisterComponent will have a corresponding RegisterModule. We won't declare RegisterComponent as part of AuthModule, for instance.
  • Mostly, everything will stay in the libs folder. New modules, new models, new configurations, new components etc... are in libs. libs should be separated into different directories based on existing apps. We won't put them inside the apps folder. For example in an Angular, contains the main.ts, app.component.ts and app.module.ts

Structure

I followed the structure recommended by my friend @nartc. Below is the simplified version of the application structure.

.
โ””โ”€โ”€ root
    โ”œโ”€โ”€ apps
    โ”‚   โ””โ”€โ”€ angular-spotify
    โ””โ”€โ”€ libs
        โ””โ”€โ”€ web (dir)
            โ”œโ”€โ”€ shell (dir)
            โ”‚   โ”œโ”€โ”€ feature (angular:lib) - for configure any forRoot modules
            โ”‚   โ””โ”€โ”€ ui
            โ”‚       โ””โ”€โ”€ layout (angular:lib)
            โ”œโ”€โ”€ settings (dir)
            โ”‚   โ”œโ”€โ”€ feature (angular:lib) - for configure and persist all settings
            โ”‚   โ””โ”€โ”€ data-access (workspace:lib) - store and services for settings module
            โ”œโ”€โ”€ playlist (dir)
            โ”‚   โ”œโ”€โ”€ data-access (angular:lib, service, state management)
            โ”‚   โ”œโ”€โ”€ features
            โ”‚   โ”‚   โ”œโ”€โ”€ list (angular:lib PlaylistsComponent)
            โ”‚   โ”‚   โ””โ”€โ”€ detail (angular:lib PlaylistDetailComopnent)
            โ”‚   โ””โ”€โ”€ ui (dir)
            โ”‚       โ””โ”€โ”€ playlist-track (angular:lib, SCAM for Component)
            โ”œโ”€โ”€ visualizer (dir)
            โ”‚   โ”œโ”€โ”€ data-access (angular:lib)
            โ”‚   โ”œโ”€โ”€ feature
            โ”‚   โ””โ”€โ”€ ui (angular:lib)
            โ”œโ”€โ”€ home (dir)
            โ”‚   โ”œโ”€โ”€ data-access (angular:lib)
            โ”‚   โ”œโ”€โ”€ feature (angular:lib)
            โ”‚   โ””โ”€โ”€ ui (dir)
            โ”‚       โ”œโ”€โ”€ featured-playlists (angular:lib, SCAM for Component)
            โ”‚       โ”œโ”€โ”€ greeting (angular:lib, SCAM for Component)
            โ”‚       โ””โ”€โ”€ recent-played (angular:lib, SCAM for Component)
            โ””โ”€โ”€ shared (dir)
                โ”œโ”€โ”€ app-config (injection token for environment)
                โ”œโ”€โ”€ data-access (angular:lib, API call, Service or State management to share across the Client app)
                โ”œโ”€โ”€ ui (dir)
                โ”œโ”€โ”€ pipes (dir)
                โ”œโ”€โ”€ directives (dir)
                โ””โ”€โ”€ utils (angular:lib, usually shared Guards, Interceptors, Validators...)

Authentication Flow

I follow Implicit Grant Flow that Spotify recommended for client-side only applications and did not involve secret keys. The issued access tokens are short-lived, and there are no refresh tokens to extend them when they expire.

View the Spotify Authorization Guide

  • Upon opening Angular Spotify, It will redirect you to Spotify to get access to your data. Angular Spotify only uses the data purely for displaying on the UI. We won't store your information anywhere else.
  • Angular Spotify only keeps the access token in the browser memory without even storing it into browser local storage. If you do a hard refresh on the browser, It will ask for a new access token from Spotify. One access token is only valid for one hour.
  • After having the token, I'll try to connect to the Web Playback SDK with a new player - Angular Spotify Web Player

Angular Spotify Web Playback SDK flow

Dependency Graph

Nx provides an dependency graph out of the box. To view it on your browser, clone my repository and run:

npm run dep-graph

A simplified graph looks like the following. It gives you insightful information for your mono repo and is especially helpful when multiple projects depend on each other.

Angular Spotify Dependency Graph

Nx Computation Cache

Having Nx Cloud configured shortens the deployment time quite a lot.

Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly. Visit Nx Cloud to learn more.

Nx cloud

Features and Roadmap

I set a tentative deadline for motivating myself to finish the work on time. Otherwise, It will take forever to complete :)

1.0 - Simple Spotify client

March 01 - 28, 2021

  • Proven, scalable, and easy to understand the structure with Nx workspace
  • Play music using Spotify SDK
  • Load a maximum of 50 save playlists and top 100 songs per playlist.
  • Cool visualization

Live stream

Let work on it together!

I scheduled a few live stream sessions to show you how I continue developing Angular Spotify. Follow my twitter for the latest updates. See the scheduled events.

# Time Description/Link
1 Sat, 3rd April 2021, 10AM Structure your Angular application with Nx workspace
2 Sat, 10th April 2021, 10AM Build the album list page
3 Sat, 17th April 2021, 10AM Build the album detail page - part 1
4 Sat, 24th April 2021, 10AM Build the album detail page - part 2
5 Sat, 8th May 2021, 10AM Build the artist detail page - part 1
6 Sat, 15th May 2021, 10AM Build the artist detail page - part 2
7 Sat, 12th Jun 2021, 10AM Build the track list page - part 1
8 Sat, 19th Jun 2021, 10AM Build the track list page - part 2
9 Sun, 11th July 2021, 10AM NgRx Component Store Unit Testing
10 TBD Config Nx build:affected with Github action

I will also do some refactoring with @nartc for Angular Vietnam Office Hours. More detail is coming soon.

Community

I have received some invitations to talk about Angular Spotify from the community. You can watch my talks below ๐Ÿ™‚

BLS033

AngularAir

# Time Description/Link
1 Wed, 21st April 2021 BLS SHOW & TELL - Angular Spotify
2 Fri, 08th May 2021 AngularAir - Another 1k stars repository

Time spending

It is a side project that I only spent time outside of the office hours to work on. I initially planned to complete the project within two weeks, but the first two weekends were not very productive, maybe because of the holiday mood from Lunar New Year :) But once the lego blocks are getting together, I feel the rhythm, and I know it has to be finished by the end of March.

I couldn't get the full-time report from waka time because it only shows me the latest two weeks. ๐Ÿคฃ

I have spent approximately 50 hours working on this project, which is almost the same amount as the first version of jira.trungk18.com.

The visualizer was the most exciting feature, and I decided to start this project because of that single component.

Angular Spotify - Time spending

Accessibility โ™ฟ

Not all components have properly defined aria attributes, visual focus indicators, etc.

Setting up the development environment ๐Ÿ› 

  • git clone https://github.com/trungk18/angular-spotify.git
  • cd angular-spotify
  • npm start for starting Angular web application
  • The app should run on http://localhost:4200/

Unit/Integration tests ๐Ÿงช

I skipped writing test for this project.

Compatibility

Web Playback SDK supports Chrome, Firefox, Edge, IE 11, or above running on Mac/Windows/Linux.

It doesn't support Safari or any mobile browser on Android or iOS

View completed list of supported browsers

Author: Trung Vo โœ๏ธ

  • A seasoned front-end engineer with seven years of passion in creating experience-driven products. I am proficient in Angular, React and TypeScript development.
  • Personal blog: https://trungk18.com/
  • Say hello: trungk18 [et] gmail [dot] com

Contributing

If you have any ideas, just open an issue and tell me what you think.

If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are warmly welcome.

Credits and reference

Special thanks to my friend @nartc, who helped me review the code early.

Resource Description
@koel/koel A cool player made by @phanan, I reused the visualizer code from this repo with my additional customization
beeman/component-store-playground A nice example of using Nx with ngrx/component-store, I refer to the project structure from this repo
Start using ngrx/effects for this An excellent write up by Tim Deschryver

License

Feel free to use my code on your project. Please put a reference to this repository.

MIT

More Repositories

1

jira-clone-angular

A simplified Jira clone built with Angular, ng-zorro and Akita
TypeScript
2,170
star
2

angular-tetris

Tetris game built with Angular and Akita ๐ŸŽฎ
TypeScript
527
star
3

front-end-editorial-style-guide

A style guide on the standard format, spelling, and construction of commonly used words and phrases. For clarity and consistency of our internal and external communications โ€“ from our user interface to our sales, marketing, and commercial docs.
51
star
4

typescript-data-structures

Fundamental data structures and algorithms a front end engineer should know, written all in TypeScript
TypeScript
41
star
5

space-invaders-phaser-3

Space Invaders game using Phase 3 and TypeScript ๐Ÿ•น
TypeScript
37
star
6

mvc5-angular-webpack

To integrate Angular and Webpack into ASP.NET MVC application for both development and production deployment
JavaScript
30
star
7

slack-realtime-angularfire

Clone Slack app using AngularJS, Firebase and Angular Fire
JavaScript
22
star
8

algorithm-training

Self training and practicing everyday.
TypeScript
21
star
9

resizing-header-on-scroll

When you scroll down the page a bit, the header resizes smaller with CSS3 animations, and gets back bigger when you scroll back to the top
HTML
20
star
10

Change-Navigation-Active-Class-on-Page-Scroll

How to add active class to menu link items based on window scroll using CSS and jQuery.
HTML
12
star
11

angular-tailwind-css-configuration

A simple Angular application with TailwindCSS configuration
TypeScript
7
star
12

trungk18

7
star
13

angular-typescript-visitor-design-pattern-with-google-maps-api

Angular - Using Visitor design pattern with Typescript
TypeScript
7
star
14

jquery-loading

A lightweight library to show a "loading" indicator while element is retrieving from server
CSS
7
star
15

mvc5-crud-on-single-page-with-razor-mvvm

ASP.NET MVC 5 Project with CRUD on a single page using Razor and MVVM technique
C#
6
star
16

angular-authentication-demo-with-lazy-loading

Created with StackBlitz โšก๏ธ
TypeScript
6
star
17

reactjs-getting-started-with-example

To get my head around ReactJS with simple example
JavaScript
4
star
18

Centering-in-CSS-Horizontal-and-Vertical

In CSS, several properties can be used to align elements horizontally and vertically. Let see.
HTML
3
star
19

mindx-global-dev

Code example for MindX Global Dev course
TypeScript
2
star
20

react-table-angular

playaround
2
star
21

canvas-drawing-test-2020

A part of new horizon 2020
TypeScript
2
star
22

zyllem-front-end-test

TypeScript
2
star
23

angular-directives-use-case

Created with StackBlitz โšก๏ธ
TypeScript
2
star
24

test-playground

HTML
2
star
25

effective-typescript-summary

Summary of "Effective TypeScript: 62 Specific Ways to Improve Your TypeScript" by Dan Vanderkam
2
star
26

multiple-projects

Repo for stackoverflow question https://stackoverflow.com/q/58604848/3375906
TypeScript
1
star
27

Animated-Button-with-CSS3

Button is a must have element for any kind of website. By using CSS3 technology you can create unique effect beautiful buttons.
SCSS
1
star
28

what3words-api-v2-google-map-marker

Draw and move marker on google maps and getting the corresponding location on what3words with their new API v2
JavaScript
1
star
29

blog-comments

Comments for trungk18.com using utterances
1
star
30

react-smart-search

TypeScript
1
star
31

Animated-Navigation-Menu-Icons-with-CSS3

How to use CSS3 Transition and Transforms for animating menu "hamburger" icon
CSS
1
star
32

view-transitions-api

Playground for View Transitions API
HTML
1
star