|
1 | | -# Getting Started with Create React App |
| 1 | +# Personal Website with Cloudflare Integration |
2 | 2 |
|
3 | | -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). |
| 3 | +## 🏗️ Architecture Overview |
4 | 4 |
|
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: |
6 | 6 |
|
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 |
8 | 10 |
|
9 | | -### `npm start` |
| 11 | +## 🚀 Getting Started |
10 | 12 |
|
11 | | -Runs the app in the development mode.\ |
12 | | -Open [http://localhost:3000](http://localhost:3000) to view it in your browser. |
| 13 | +### Prerequisites |
13 | 14 |
|
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 |
16 | 20 |
|
17 | | -### `npm test` |
| 21 | +### Environment Setup |
18 | 22 |
|
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 | +``` |
21 | 28 |
|
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 | +``` |
23 | 35 |
|
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 | +``` |
26 | 40 |
|
27 | | -The build is minified and the filenames include the hashes.\ |
28 | | -Your app is ready to be deployed! |
| 41 | +## 💻 Local Development |
29 | 42 |
|
30 | | -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. |
| 43 | +### Starting the Development Server |
31 | 44 |
|
32 | | -### `npm run eject` |
| 45 | +```bash |
| 46 | +# Start React development server |
| 47 | +npm start |
33 | 48 |
|
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 | +``` |
35 | 52 |
|
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 |
37 | 56 |
|
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 |
39 | 58 |
|
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: |
41 | 60 |
|
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 | +``` |
43 | 71 |
|
44 | | -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). |
| 72 | +## 🌐 Deployment |
45 | 73 |
|
46 | | -To learn React, check out the [React documentation](https://reactjs.org/). |
| 74 | +### Automated Deployment |
47 | 75 |
|
48 | | -### Code Splitting |
| 76 | +The project includes a PowerShell deployment script that handles both frontend and worker deployment: |
49 | 77 |
|
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 | +``` |
51 | 81 |
|
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 |
53 | 89 |
|
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 |
55 | 91 |
|
56 | | -### Making a Progressive Web App |
| 92 | +If you need to deploy components individually: |
57 | 93 |
|
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 | +``` |
59 | 99 |
|
60 | | -### Advanced Configuration |
| 100 | +2. Worker Deployment: |
| 101 | +```bash |
| 102 | +npx wrangler deploy spotify-worker.js |
| 103 | +``` |
61 | 104 |
|
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 |
63 | 106 |
|
64 | | -### Deployment |
| 107 | +#### Cloudflare Pages Configuration: |
65 | 108 |
|
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) |
67 | 113 |
|
68 | | -### `npm run build` fails to minify |
| 114 | +2. Environment variables: |
| 115 | + - Production branch: `main` |
| 116 | + - Preview branches: `dev/*` |
69 | 117 |
|
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. |
0 commit comments