Skip to content

Commit c63c762

Browse files
committed
Music
Made the music integration work, removed unused files, updated readme & .env.example
1 parent 82388a2 commit c63c762

29 files changed

+1127
-1098
lines changed

.env.example

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# Spotify Configuration
2-
VITE_SPOTIFY_CLIENT_ID=your_client_id_here
3-
VITE_SPOTIFY_CLIENT_SECRET=your_client_secret_here
4-
VITE_SPOTIFY_REDIRECT_URI=http://localhost:3000/callback
1+
# Last.fm Configuration
2+
# Get your API key at: https://www.last.fm/api/account/create
3+
VITE_LASTFM_API_KEY=your_api_key_here
4+
VITE_LASTFM_USERNAME=your_lastfm_username
55

6-
# API Configuration
7-
VITE_WORKER_URL=http://localhost:8787
6+
# CloudFlare Configuration
7+
# Get these from your Cloudflare dashboard: https://dash.cloudflare.com/
8+
CLOUDFLARE_API_TOKEN=your_cloudflare_api_token
9+
CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id

README.md

Lines changed: 41 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
## 🏗️ Architecture Overview
44

5-
This project implements a modern web application architecture leveraging Cloudflare's edge computing capabilities. The architecture consists of three primary components:
5+
This project implements a modern web application architecture leveraging Cloudflare's edge computing capabilities. The architecture consists of two primary components:
66

7-
1. **React Frontend**: A Single Page Application (SPA) built with Create React App
8-
2. **Cloudflare Workers**: Serverless functions handling API integrations
9-
3. **Cloudflare Pages**: Static site hosting with global CDN distribution
7+
1. **React Frontend**: A Single Page Application (SPA) built with React and TypeScript
8+
2. **Cloudflare Pages**: Static site hosting with global CDN distribution
109

1110
## 🚀 Getting Started
1211

@@ -15,22 +14,37 @@ This project implements a modern web application architecture leveraging Cloudfl
1514
- Node.js (v16.0.0 or higher)
1615
- npm (v7.0.0 or higher)
1716
- Cloudflare account
18-
- Spotify Developer account
17+
- Last.fm account and API key
1918
- Git
2019

20+
### API Keys Setup
21+
22+
1. **Last.fm API Key**:
23+
- Visit [Last.fm API Account Creation](https://www.last.fm/api/account/create)
24+
- Sign in with your Last.fm account
25+
- Fill in the application details
26+
- Save your API key
27+
- Your username can be found in your profile URL: last.fm/user/YOUR_USERNAME
28+
29+
2. **Cloudflare Setup**:
30+
- Create an account at [Cloudflare](https://dash.cloudflare.com/sign-up)
31+
- Get your Account ID from the dashboard
32+
- Create an API token with Pages deployment permissions
33+
2134
### Environment Setup
2235

2336
1. Clone the repository:
2437
```bash
25-
git clone https://github.com/EndofTimee/My-website
26-
cd personal-website
38+
git clone https://github.com/EndofTimee/personal-site
39+
cd personal-site
2740
```
2841

2942
2. Create a `.env` file in the root directory:
3043
```env
31-
SPOTIFY_CLIENT_ID=your_spotify_client_id
32-
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
33-
SPOTIFY_REDIRECT_URI=your_redirect_uri
44+
VITE_LASTFM_API_KEY=your_lastfm_api_key
45+
VITE_LASTFM_USERNAME=your_lastfm_username
46+
CLOUDFLARE_API_TOKEN=your_cloudflare_api_token
47+
CLOUDFLARE_ACCOUNT_ID=your_cloudflare_account_id
3448
```
3549

3650
3. Install dependencies:
@@ -40,19 +54,12 @@ npm install
4054

4155
## 💻 Local Development
4256

43-
### Starting the Development Server
44-
57+
Start the development server:
4558
```bash
46-
# Start React development server
4759
npm start
48-
49-
# In a separate terminal, start the Cloudflare Worker
50-
npx wrangler dev spotify-worker.js
5160
```
5261

53-
The application will be available at:
54-
- Frontend: http://localhost:3000
55-
- Worker: http://localhost:8787
62+
The application will be available at http://localhost:3000
5663

5764
### Component Structure
5865

@@ -61,19 +68,19 @@ The project follows a modular component structure:
6168
```
6269
src/
6370
├── components/
64-
│ ├── SpotifyList/ # Spotify integration
65-
│ ├── GithubRepos/ # GitHub repository display
66-
│ ├── LoadingAnimation/ # Loading states
67-
│ └── ParallaxEffect/ # Visual effects
68-
├── App.js # Main application component
69-
└── index.js # Application entry point
71+
│ ├── LastFMTrack/ # Music integration
72+
│ ├── GithubRepos/ # GitHub repository display
73+
│ ├── LoadingFox/ # Loading states
74+
│ └── ParallaxEffect/ # Visual effects
75+
├── App.tsx # Main application component
76+
└── index.tsx # Application entry point
7077
```
7178

7279
## 🌐 Deployment
7380

7481
### Automated Deployment
7582

76-
The project includes a PowerShell deployment script that handles both frontend and worker deployment:
83+
The project includes a PowerShell deployment script:
7784

7885
```bash
7986
npm run deploy
@@ -84,22 +91,15 @@ This script:
8491
2. Installs dependencies
8592
3. Builds the React application
8693
4. Deploys to Cloudflare Pages
87-
5. Deploys the Spotify Worker
88-
6. Sets up environment secrets
94+
5. Sets up environment secrets
8995

9096
### Manual Deployment Steps
9197

92-
If you need to deploy components individually:
98+
If you need to deploy manually:
9399

94-
1. Frontend Deployment:
95100
```bash
96101
npm run build
97-
npx wrangler pages deploy ./build
98-
```
99-
100-
2. Worker Deployment:
101-
```bash
102-
npx wrangler deploy spotify-worker.js
102+
npx wrangler pages deploy ./dist
103103
```
104104

105105
### Environment Configuration
@@ -108,52 +108,35 @@ npx wrangler deploy spotify-worker.js
108108

109109
1. Build settings:
110110
- Build command: `npm run build`
111-
- Build output directory: `build`
111+
- Build output directory: `dist`
112112
- Node.js version: 16 (or higher)
113113

114114
2. Environment variables:
115115
- Production branch: `main`
116116
- Preview branches: `dev/*`
117117

118-
#### Worker Configuration:
119-
120-
Required environment secrets:
121-
- `SPOTIFY_CLIENT_ID`
122-
- `SPOTIFY_CLIENT_SECRET`
123-
- `SPOTIFY_REDIRECT_URI`
124-
125118
## 🐛 Troubleshooting
126119

127120
### Common Issues
128121

129-
1. Worker Deployment Failures:
130-
```bash
131-
# Verify wrangler.toml configuration
132-
npx wrangler config
133-
134-
# Check worker status
135-
npx wrangler tail
136-
```
137-
138-
2. Build Issues:
122+
1. Build Issues:
139123
```bash
140124
# Clear dependency cache
141125
rm -rf node_modules
142126
npm clean-cache --force
143127
npm install
144128
```
145129

146-
3. Environment Variables:
130+
2. Environment Variables:
147131
```bash
148132
# Verify environment variables
149133
npx wrangler secret list
150134
```
151135

152136
## 📚 Additional Resources
153137

154-
- [Cloudflare Workers Documentation](https://developers.cloudflare.com/workers/)
155138
- [Cloudflare Pages Documentation](https://developers.cloudflare.com/pages/)
156-
- [Spotify Web API Documentation](https://developer.spotify.com/documentation/web-api/)
139+
- [Last.fm API Documentation](https://www.last.fm/api)
157140
- [React Documentation](https://reactjs.org/docs/getting-started.html)
158141

159142
## 🤝 Contributing
@@ -166,4 +149,4 @@ Required environment secrets:
166149

167150
## 📄 License
168151

169-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
152+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details

cloudflare-worker.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

deploy-master.ps1

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# deploy-master.ps1
2-
#Requires -Version 5.1
1+
# deploy.ps1
32
Set-StrictMode -Version Latest
43
$ErrorActionPreference = 'Stop'
54

@@ -28,9 +27,6 @@ function Write-Status {
2827

2928
function Test-Environment {
3029
$requiredVars = @{
31-
"SPOTIFY_CLIENT_ID" = ""
32-
"SPOTIFY_CLIENT_SECRET" = ""
33-
"SPOTIFY_REDIRECT_URI" = ""
3430
"CLOUDFLARE_API_TOKEN" = "For Cloudflare API access"
3531
"CLOUDFLARE_ACCOUNT_ID" = "For Cloudflare account identification"
3632
}
@@ -47,21 +43,13 @@ function Test-Environment {
4743
}
4844
}
4945

50-
# Check for deprecated variables
51-
if (Get-Item env:CF_API_TOKEN -ErrorAction SilentlyContinue) {
52-
Write-Status "CF_API_TOKEN is deprecated. Please use CLOUDFLARE_API_TOKEN instead" "Warning"
53-
# Automatically migrate the value
54-
$env:CLOUDFLARE_API_TOKEN = $env:CF_API_TOKEN
55-
Remove-Item env:CF_API_TOKEN
56-
}
57-
5846
if ($missingVars.Count -gt 0) {
5947
throw "Missing required environment variables: $($missingVars -join ', ')"
6048
}
6149
}
6250

6351
function Clear-BuildArtifacts {
64-
$paths = @("dist", ".wrangler", "node_modules/.cache")
52+
$paths = @("dist", "node_modules/.cache")
6553
foreach ($path in $paths) {
6654
if (Test-Path $path) {
6755
Remove-Item -Recurse -Force $path
@@ -82,33 +70,13 @@ function Install-Dependencies {
8270

8371
function Start-Build {
8472
Write-Status "Building project..." "Info"
85-
86-
Write-Status "Building worker..." "Info"
87-
npm run build:worker
88-
if ($LASTEXITCODE -ne 0) { throw "Worker build failed" }
89-
90-
Write-Status "Building frontend..." "Info"
9173
npm run build
9274
if ($LASTEXITCODE -ne 0) { throw "Frontend build failed" }
9375

9476
if (-not (Test-Path "dist")) { throw "Build failed - dist directory not created" }
9577
Write-Status "Build completed successfully" "Success"
9678
}
9779

98-
function Deploy-Worker {
99-
Write-Status "Deploying Cloudflare Worker..." "Info"
100-
101-
# Set wrangler environment variables
102-
$env:WRANGLER_AUTH_TOKEN = $env:CLOUDFLARE_API_TOKEN
103-
104-
$deployEnv = if ($env:CI) { "production" } else { "development" }
105-
106-
npx wrangler deploy src/worker/index.ts --env $deployEnv
107-
if ($LASTEXITCODE -ne 0) { throw "Worker deployment failed" }
108-
109-
Write-Status "Worker deployed successfully" "Success"
110-
}
111-
11280
function Deploy-Frontend {
11381
Write-Status "Deploying to Cloudflare Pages..." "Info"
11482

@@ -132,7 +100,6 @@ function Start-Deployment {
132100
Clear-BuildArtifacts
133101
Install-Dependencies
134102
Start-Build
135-
Deploy-Worker
136103
Deploy-Frontend
137104

138105
Write-Status "Deployment completed successfully!" "Success"

dev.ps1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,9 @@ function Start-Development {
5858
# Start Vite
5959
$viteWindow = Start-Process powershell -ArgumentList "-NoExit", "-Command", "npm run dev" -PassThru
6060

61-
# Start Wrangler
62-
$wranglerWindow = Start-Process powershell -ArgumentList "-NoExit", "-Command", "npx wrangler dev spotify-worker.ts" -PassThru
63-
61+
6462
Write-Status "Development servers started successfully!" "Success"
6563
Write-Status "Vite running on: http://localhost:3000" "Info"
66-
Write-Status "Worker running on: http://localhost:8787" "Info"
6764
Write-Status "Log file: $logFile" "Info"
6865

6966
# Wait for user input to stop servers
@@ -72,14 +69,12 @@ function Start-Development {
7269

7370
# Stop the servers
7471
if ($viteWindow) { Stop-Process -Id $viteWindow.Id -Force }
75-
if ($wranglerWindow) { Stop-Process -Id $wranglerWindow.Id -Force }
7672

7773
Write-Status "Development servers stopped" "Success"
7874
}
7975
catch {
8076
Write-Status "Error during development: $_" "Error"
8177
if ($viteWindow) { Stop-Process -Id $viteWindow.Id -Force }
82-
if ($wranglerWindow) { Stop-Process -Id $wranglerWindow.Id -Force }
8378
exit 1
8479
}
8580
finally {

0 commit comments

Comments
 (0)