A modern React-based Apple replica website with Node.js backend and MySQL database.
- Frontend: React 19 + Vite with Apple-inspired UI
- Backend: Node.js + Express with RESTful API
- Database: MySQL with product management system
- Routing: React Router for single-page application
- Styling: Bootstrap 4 with custom CSS
- Images: Real Apple product images from official sources
- Node.js (v18 or higher)
- MySQL Server
- npm or yarn
- Clone the repository:
git clone <repository-url>
cd React-Apple-Routing- Install backend dependencies:
cd backend
npm install- Set up environment variables:
cp .env.example .env
# Edit .env with your database credentials- Create and configure MySQL database:
CREATE DATABASE myDB;
CREATE USER 'myDBuser'@'localhost' IDENTIFIED BY '1';
GRANT ALL PRIVILEGES ON myDB.* TO 'myDBuser'@'localhost';
FLUSH PRIVILEGES;- Initialize database tables:
npm run install- Start the backend server:
npm start- Install frontend dependencies:
cd frontend
npm install- Set up environment variables:
cp .env.example .env
# Edit .env with your API URL- Start the development server:
npm run dev- Frontend: http://localhost:5173
- Backend API: http://localhost:1234
- API Documentation: http://localhost:1234
- Product Form: http://localhost:1234/form
- products - Product information
- users - User accounts
- product_description - Detailed product descriptions
- product_price - Pricing information
- orders - Order management
| Method | Endpoint | Description |
|---|---|---|
| GET | /install |
Initialize database tables |
| GET | /iphone |
Get all products |
| GET | /iphone/:id |
Get single product |
| POST | /add-product |
Add new product |
| GET | /admin/clearTables |
Clear all tables (admin) |
React-Apple-Routing/
├── backend/
│ ├── utilities/
│ │ ├── db.js # Database connection
│ │ └── query.js # SQL queries
│ ├── public/
│ │ ├── index.html # API documentation
│ │ └── form.html # Product submission form
│ ├── app.js # Main server file
│ ├── package.json
│ └── .env
├── frontend/
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Page components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── assets/ # Static assets
│ │ └── App.jsx # Main App component
│ ├── public/
│ ├── package.json
│ └── .env
└── README.md
DB_HOST=localhost
DB_USER=myDBuser
DB_PASSWORD=1
DB_NAME=myDB
PORT=1234VITE_API_URL=http://localhost:1234
VITE_APP_NAME=Apple Replica- Home (/) - Landing page with Apple-style sections
- iPhone (/iphone) - Product listing with real Apple images
- Mac (/mac) - Mac products (placeholder)
- iPad (/ipad) - iPad products (placeholder)
- Watch (/watch) - Apple Watch products (placeholder)
- TV (/tv) - Apple TV products (placeholder)
- Music (/music) - Apple Music services (placeholder)
- Support (/support) - Support page (placeholder)
- Search (/search) - Search functionality (placeholder)
- Cart (/cart) - Shopping cart (placeholder)
- Set production environment variables
- Build and start the server:
npm start- Build for production:
npm run build- Deploy the
distfolder to your hosting provider
- Fork the repository
- Create a feature branch
- Make your changes
- Commit and push the changes
- Create a Pull Request
This project is for educational purposes only. All product images and trademarks belong to Apple Inc.
-
Database Connection Error
- Ensure MySQL server is running
- Check database credentials in .env
- Verify database and user exist
-
Frontend API Connection Error
- Ensure backend server is running on correct port
- Check API URL in frontend .env
- Verify CORS configuration
-
Images Not Loading
- Check internet connection for external images
- Verify image URLs in database
- Check console for CORS errors
To clear all data and start fresh:
curl http://localhost:1234/admin/clearTablesFor issues and questions, please open an issue in the GitHub repository.