We were inspired by how Receiptify(https://receiptify.herokuapp.com/about.html) brought people together through their shared love of music. Building on that idea, we set out to create an experience that feels more immersive and emotionally resonant. With Moodscape, we transform listening habits into personalized landscapes that visually reflect a user’s musical mood. Our goal is to foster new relationships and build upon old ones through shared musical connection.
hackmood/
├── frontend/ # Next.js frontend application
│ ├── app/ # Next.js app directory
│ ├── components/ # React components
│ └── public/ # Static assets
├── backend/ # Express.js backend server
│ ├── server.js # Main server file
│ └── public/ # Static files (if needed)
└── README.md
We were inspired by how Receiptify(https://receiptify.herokuapp.com/about.html) brought people together through their shared love of music. Building on that idea, we set out to create an experience that feels more immersive and emotionally resonant. With Moodscape, we transform listening habits into personalized landscapes that visually reflect a user’s musical mood. Our goal is to foster new relationships and build upon old ones through shared musical connection.
- Spotify OAuth authentication
- 3D world generation based on music mood
- Dynamic mood analysis using Last.fm tags
- Interactive 3D environments with Three.js/React Three Fiber
Before you begin, ensure you have the following installed:
- Node.js (v16 or higher)
- npm or pnpm
- A Spotify Developer account
- (Optional) A Last.fm API account for mood analysis
- Go to Spotify Developer Dashboard
- Log in with your Spotify account
- Click "Create an App"
- Fill in the app details:
- App name: HackMood (or your preferred name)
- App description: Music mood-based world generator
- After creating the app, click "Edit Settings"
- Add the following to "Redirect URIs":
http://localhost:8888/callback- Click "Add" then "Save"
- Copy your Client ID and Client Secret (you'll need these for the backend)
- Go to Last.fm API Account
- Fill in the form to create an API account
- Copy your API Key
# Navigate to backend directory
cd backend
# Install dependencies
npm install
# Create environment file
cp .env.example .env
# Edit .env file and add your credentials
# SPOTIFY_CLIENT_ID=your_client_id_here
# SPOTIFY_CLIENT_SECRET=your_client_secret_here
# LASTFM_API_KEY=your_lastfm_api_key_here (optional)Edit the backend/.env file with your actual credentials:
SPOTIFY_CLIENT_ID=your_spotify_client_id_here
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret_here
PORT=8888
REDIRECT_URI=http://localhost:8888/callback
FRONTEND_URI=http://localhost:3000
LASTFM_API_KEY=your_lastfm_api_key_here# Navigate to frontend directory
cd ../frontend
# Install dependencies
npm install
# or
pnpm install
if it does not work, try doing:
npm install --legacy-peer-deps
# Create environment file
cp .env.example .env.local
# The default backend URL is already set to http://localhost:8888Edit the frontend/.env.local file if needed:
NEXT_PUBLIC_BACKEND_URL=http://localhost:8888You need to run both the backend and frontend servers.
cd backend
npm start
# Or for development with auto-reload:
npm run devThe backend server will start on http://localhost:8888
You should see:
==================================================
🎵 HackMood Spotify Auth Server
==================================================
Server running on: http://localhost:8888
Frontend URL: http://localhost:3000
Redirect URI: http://localhost:8888/callback
==================================================
cd frontend
npm run dev
# or
pnpm devThe frontend will start on http://localhost:3000
- Open your browser and navigate to
http://localhost:3000 - Click the "Sign In" or "Create World" button
- In the authentication modal, click "Continue with Spotify"
- You'll be redirected to Spotify's authorization page
- After authorizing, you'll be redirected back to the app
- Your Spotify access token will be stored in localStorage
- You can now use the mood analysis features!
Backend (http://localhost:8888)
GET /login- Initiates Spotify OAuth flowGET /callback- Spotify OAuth callback endpointGET /refresh_token?refresh_token=TOKEN- Refreshes an expired access tokenGET /lastfm/proxy?method=METHOD&artist=ARTIST&track=TRACK- Proxy for Last.fm APIGET /health- Health check endpoint
Error: Missing required environment variables
- Make sure you've created the
.envfile in the backend directory - Verify all required variables are set (SPOTIFY_CLIENT_ID, SPOTIFY_CLIENT_SECRET)
Error: Redirect URI mismatch
- Check that the redirect URI in your Spotify Developer Dashboard matches exactly:
http://localhost:8888/callback - Ensure the REDIRECT_URI in your
.envfile matches
Authentication not working
- Make sure the backend server is running
- Check that NEXT_PUBLIC_BACKEND_URL in
.env.localpoints to the correct backend URL - Check browser console for errors
CORS errors
- Verify the FRONTEND_URI in backend
.envmatches your frontend URL - The backend is configured to accept requests from the frontend origin
Error: Last.fm API key not configured
- Add your Last.fm API key to the backend
.envfile - This is optional - the app will work without it, but mood analysis won't function
The backend uses:
- Express.js for the web server
- Native fetch API for HTTP requests (Node 18+)
- Cookie-parser for session management
- CORS for cross-origin requests
The frontend uses:
- Next.js 14+ (App Router)
- React 18+
- Three.js / React Three Fiber for 3D rendering
- Tailwind CSS for styling
| Variable | Required | Description |
|---|---|---|
| SPOTIFY_CLIENT_ID | Yes | Your Spotify app client ID |
| SPOTIFY_CLIENT_SECRET | Yes | Your Spotify app client secret |
| PORT | No | Server port (default: 8888) |
| REDIRECT_URI | No | OAuth callback URL (default: http://localhost:8888/callback) |
| FRONTEND_URI | No | Frontend URL (default: http://localhost:3000) |
| LASTFM_API_KEY | No | Last.fm API key for mood analysis |
| Variable | Required | Description |
|---|---|---|
| NEXT_PUBLIC_BACKEND_URL | No | Backend API URL (default: http://localhost:8888) |
- Never commit
.envfiles to version control - Keep your Spotify Client Secret secure
- Tokens are stored in browser localStorage (consider using httpOnly cookies for production)
- The state parameter is used to prevent CSRF attacks
MIT
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
If you encounter any issues, please check:
- All environment variables are correctly set
- Both backend and frontend servers are running
- Spotify Developer Dashboard settings match your configuration
- Browser console for any error messages
For more help, create an issue in the repository.
