Skip to content

Commit 9c66c93

Browse files
committed
Big redo. should work. i hope
1 parent 3fb3e9e commit 9c66c93

22 files changed

+875
-394
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@
2222
npm-debug.log*
2323
yarn-debug.log*
2424
yarn-error.log*
25+
.dev.vars
26+
.prod.env
27+
.prod.vars

README.md

Lines changed: 137 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,169 @@
1-
# Getting Started with Create React App
1+
# Personal Website with Cloudflare Integration
22

3-
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
3+
## 🏗️ Architecture Overview
44

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

7-
In the project directory, you can run:
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
810

9-
### `npm start`
11+
## 🚀 Getting Started
1012

11-
Runs the app in the development mode.\
12-
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
13+
### Prerequisites
1314

14-
The page will reload when you make changes.\
15-
You may also see any lint errors in the console.
15+
- Node.js (v16.0.0 or higher)
16+
- npm (v7.0.0 or higher)
17+
- Cloudflare account
18+
- Spotify Developer account
19+
- Git
1620

17-
### `npm test`
21+
### Environment Setup
1822

19-
Launches the test runner in the interactive watch mode.\
20-
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
23+
1. Clone the repository:
24+
```bash
25+
git clone https://github.com/EndofTimee/My-website
26+
cd personal-website
27+
```
2128

22-
### `npm run build`
29+
2. Create a `.env` file in the root directory:
30+
```env
31+
SPOTIFY_CLIENT_ID=your_spotify_client_id
32+
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
33+
SPOTIFY_REDIRECT_URI=your_redirect_uri
34+
```
2335

24-
Builds the app for production to the `build` folder.\
25-
It correctly bundles React in production mode and optimizes the build for the best performance.
36+
3. Install dependencies:
37+
```bash
38+
npm install
39+
```
2640

27-
The build is minified and the filenames include the hashes.\
28-
Your app is ready to be deployed!
41+
## 💻 Local Development
2942

30-
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
43+
### Starting the Development Server
3144

32-
### `npm run eject`
45+
```bash
46+
# Start React development server
47+
npm start
3348

34-
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
49+
# In a separate terminal, start the Cloudflare Worker
50+
npx wrangler dev spotify-worker.js
51+
```
3552

36-
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
53+
The application will be available at:
54+
- Frontend: http://localhost:3000
55+
- Worker: http://localhost:8787
3756

38-
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
57+
### Component Structure
3958

40-
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
59+
The project follows a modular component structure:
4160

42-
## Learn More
61+
```
62+
src/
63+
├── 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
70+
```
4371

44-
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
72+
## 🌐 Deployment
4573

46-
To learn React, check out the [React documentation](https://reactjs.org/).
74+
### Automated Deployment
4775

48-
### Code Splitting
76+
The project includes a PowerShell deployment script that handles both frontend and worker deployment:
4977

50-
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
78+
```bash
79+
npm run deploy
80+
```
5181

52-
### Analyzing the Bundle Size
82+
This script:
83+
1. Loads environment variables
84+
2. Installs dependencies
85+
3. Builds the React application
86+
4. Deploys to Cloudflare Pages
87+
5. Deploys the Spotify Worker
88+
6. Sets up environment secrets
5389

54-
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
90+
### Manual Deployment Steps
5591

56-
### Making a Progressive Web App
92+
If you need to deploy components individually:
5793

58-
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
94+
1. Frontend Deployment:
95+
```bash
96+
npm run build
97+
npx wrangler pages deploy ./build
98+
```
5999

60-
### Advanced Configuration
100+
2. Worker Deployment:
101+
```bash
102+
npx wrangler deploy spotify-worker.js
103+
```
61104

62-
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
105+
### Environment Configuration
63106

64-
### Deployment
107+
#### Cloudflare Pages Configuration:
65108

66-
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
109+
1. Build settings:
110+
- Build command: `npm run build`
111+
- Build output directory: `build`
112+
- Node.js version: 16 (or higher)
67113

68-
### `npm run build` fails to minify
114+
2. Environment variables:
115+
- Production branch: `main`
116+
- Preview branches: `dev/*`
69117

70-
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
118+
#### Worker Configuration:
119+
120+
Required environment secrets:
121+
- `SPOTIFY_CLIENT_ID`
122+
- `SPOTIFY_CLIENT_SECRET`
123+
- `SPOTIFY_REDIRECT_URI`
124+
125+
## 🐛 Troubleshooting
126+
127+
### Common Issues
128+
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:
139+
```bash
140+
# Clear dependency cache
141+
rm -rf node_modules
142+
npm clean-cache --force
143+
npm install
144+
```
145+
146+
3. Environment Variables:
147+
```bash
148+
# Verify environment variables
149+
npx wrangler secret list
150+
```
151+
152+
## 📚 Additional Resources
153+
154+
- [Cloudflare Workers Documentation](https://developers.cloudflare.com/workers/)
155+
- [Cloudflare Pages Documentation](https://developers.cloudflare.com/pages/)
156+
- [Spotify Web API Documentation](https://developer.spotify.com/documentation/web-api/)
157+
- [React Documentation](https://reactjs.org/docs/getting-started.html)
158+
159+
## 🤝 Contributing
160+
161+
1. Fork the repository
162+
2. Create a feature branch
163+
3. Commit changes
164+
4. Push to the branch
165+
5. Open a Pull Request
166+
167+
## 📄 License
168+
169+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

cloudflare-worker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Router } from 'itty-router';
33

44
const router = Router();
55

6-
const CLIENT_ID = 'YOUR_SPOTIFY_CLIENT_ID';
7-
const CLIENT_SECRET = 'YOUR_SPOTIFY_CLIENT_SECRET';
8-
const REDIRECT_URI = 'YOUR_REDIRECT_URI';
6+
const CLIENT_ID = process.env.CLIENT_ID;
7+
const CLIENT_SECRET = proccess.env.CLIENT_SECRET;
8+
const REDIRECT_URI = proces.env.REDIRECT_URI
99
let accessToken = null;
1010

1111
// Function to refresh Spotify Access Token

0 commit comments

Comments
 (0)