Spotified is a full-stack application built with Node.js and React. The main purpose of the Node.js backend is to obtain a Spotify Web API access token. Here's how the app functions:
- The backend server, implemented in Node.js, is responsible for requesting an authentication token from the Spotify Web API.
- The frontend, built with React, uses React Toolkit for state management and React Query for data fetching.
The backend is located in the backend
folder. When a user loads the React app, the frontend sends a request to the backend with a secret key stored in the frontend environment. The backend verifies the secret key and sends an authorization request to Spotify with the client ID and token stored in the backend environment.
If the access token is received successfully, the backend sets a cookie and sends the response to the frontend. The frontend then stores the token in local storage for subsequent requests made from the frontend app. The Node.js backend uses cookies to verify that the token is valid every time the frontend app reloads.
The frontend is located in the frontend
folder. It is built with React and interacts with the backend to obtain the Spotify access token. The frontend app sends a request to the backend with the secret key, and upon receiving the token, it stores it in local storage for future use.
To get started with Spotified, follow these steps:
- Clone the repository.
- Navigate to the
backend
folder and install the dependencies by runningnpm install
. - Set up the necessary environment variables in the
.env
file. - Start the backend server by running
npm start
. - Navigate to the
frontend
folder and install the dependencies by runningnpm install
. - Set up the necessary environment variables in the
.env
file. - Start the frontend development server by running
npm run dev
.
Contributions are welcome! If you'd like to contribute to Spotified, please follow these guidelines:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push your changes to your forked repository.
- Submit a pull request to the main repository.