mirror of
https://github.com/System-End/My-website.git
synced 2026-04-19 18:35:13 +00:00
My website
| .github/workflows | ||
| .vscode | ||
| public | ||
| src | ||
| .editorconfig | ||
| .env.example | ||
| .eslintrc.cjs | ||
| .gitattributes | ||
| .gitignore | ||
| .npmrc | ||
| cloudflare-worker.js | ||
| deploy-master.ps1 | ||
| dev.ps1 | ||
| index.html | ||
| package.json | ||
| postcss.config.js | ||
| README.md | ||
| spotify-worker.js | ||
| spotify-worker.ts | ||
| tailwind.config.js | ||
| tsconfig.json | ||
| tsconfig.node.json | ||
| tsconfig.worker.json | ||
| vite.config.ts | ||
| wrangler.toml | ||
Personal Website with Cloudflare Integration
🏗️ Architecture Overview
This project implements a modern web application architecture leveraging Cloudflare's edge computing capabilities. The architecture consists of three primary components:
- React Frontend: A Single Page Application (SPA) built with Create React App
- Cloudflare Workers: Serverless functions handling API integrations
- Cloudflare Pages: Static site hosting with global CDN distribution
🚀 Getting Started
Prerequisites
- Node.js (v16.0.0 or higher)
- npm (v7.0.0 or higher)
- Cloudflare account
- Spotify Developer account
- Git
Environment Setup
- Clone the repository:
git clone https://github.com/EndofTimee/My-website
cd personal-website
- Create a
.envfile in the root directory:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_REDIRECT_URI=your_redirect_uri
- Install dependencies:
npm install
💻 Local Development
Starting the Development Server
# Start React development server
npm start
# In a separate terminal, start the Cloudflare Worker
npx wrangler dev spotify-worker.js
The application will be available at:
- Frontend: http://localhost:3000
- Worker: http://localhost:8787
Component Structure
The project follows a modular component structure:
src/
├── components/
│ ├── SpotifyList/ # Spotify integration
│ ├── GithubRepos/ # GitHub repository display
│ ├── LoadingAnimation/ # Loading states
│ └── ParallaxEffect/ # Visual effects
├── App.js # Main application component
└── index.js # Application entry point
🌐 Deployment
Automated Deployment
The project includes a PowerShell deployment script that handles both frontend and worker deployment:
npm run deploy
This script:
- Loads environment variables
- Installs dependencies
- Builds the React application
- Deploys to Cloudflare Pages
- Deploys the Spotify Worker
- Sets up environment secrets
Manual Deployment Steps
If you need to deploy components individually:
- Frontend Deployment:
npm run build
npx wrangler pages deploy ./build
- Worker Deployment:
npx wrangler deploy spotify-worker.js
Environment Configuration
Cloudflare Pages Configuration:
-
Build settings:
- Build command:
npm run build - Build output directory:
build - Node.js version: 16 (or higher)
- Build command:
-
Environment variables:
- Production branch:
main - Preview branches:
dev/*
- Production branch:
Worker Configuration:
Required environment secrets:
SPOTIFY_CLIENT_IDSPOTIFY_CLIENT_SECRETSPOTIFY_REDIRECT_URI
🐛 Troubleshooting
Common Issues
-
Worker Deployment Failures:
# Verify wrangler.toml configuration npx wrangler config # Check worker status npx wrangler tail -
Build Issues:
# Clear dependency cache rm -rf node_modules npm clean-cache --force npm install -
Environment Variables:
# Verify environment variables npx wrangler secret list
📚 Additional Resources
- Cloudflare Workers Documentation
- Cloudflare Pages Documentation
- Spotify Web API Documentation
- React Documentation
🤝 Contributing
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.