Thank you for your interest in contributing! This guide will help you set up your environment and follow best practices.
- Getting Started
- Branching Strategy
- Coding Standards
- Testing
- Pull Request Guidelines
- Environment Setup
- Database Setup
- Frontend Guidelines
- Fork the repository.
- Clone your fork:
git clone https://github.com/<your-username>/E-commerce.git
cd E-commerce
- Install backend dependencies:
cd backend
npm install
- Install frontend dependencies:
cd ../frontend
npm install
main→ production-readydevelop→ latest development- Feature branches →
feature/<feature-name> - Fix branches →
fix/<issue-number>
- Use ES6+ syntax for JS.
- All API responses must have this structure:
{
"success": true,
"message": "Descriptive message",
"data": {}
}
- Always handle null/undefined values in frontend.
- Use utils.js helpers for notifications, API calls, and localStorage.
- Backend: test endpoints using Postman.
- Frontend: test forms, cart, checkout, orders, wishlist, and profile.
- Ensure all features work both logged-in and logged-out.
- PR must be from a feature/fix branch to develop.
- Include screenshots if UI changes.
- Reference the related issue in PR description.
- Ensure no console errors or warnings in browser.
- Code must pass linter checks.
- Copy
.env.exampleto.env:cp backend/.env.example backend/.env - Fill in the required values:
- DB_HOST
- DB_USER
- DB_PASSWORD
- DB_NAME
- JWT_SECRET
- PORT (default: 5000)
- FRONTEND_URL (default: http://localhost:3000)
- Create a MySQL database.
- Run the schema script:
cd backend
mysql -u <DB_USER> -p < DB_NAME < schema.sql
- Ensure tables: users, products, orders, order_items exist.
- Use
utils.jsfor: - Notifications:
notify(message, type) - Safe localStorage:
getJSON(key)/setJSON(key, value) - API calls:
apiRequest(url, options) - Price formatting:
formatPrice(price) - Always check for element existence before updating the DOM.
- Use fallback values for product info (name, image, price) to prevent crashes.