Website demo fullstack gồm:
- Backend: Node.js + Express + MySQL
- Frontend: React + Vite
- Cài dependencies + import database (chạy 1 lần):
npm run setup- Chạy cả backend + frontend:
npm startĐịa chỉ mặc định:
- Backend:
http://localhost:5000 - Frontend (Vite):
http://localhost:3000
- Node.js (khuyến nghị LTS)
- MySQL 8.x
- Git
git clone <YOUR_REPO_URL>
cd ptiteduTạo file backend/.env từ mẫu:
cd backend
copy .env.example .envSau đó chỉnh các biến (tối thiểu là MySQL):
PORT=5000
DB_HOST=127.0.0.1
DB_USER=root
DB_PASSWORD=
DB_NAME=ptit_eduCác biến tuỳ chọn:
GEMINI_API_KEY=
EMAIL_USER=
EMAIL_PASS=Tạo file frontend/.env từ mẫu:
cd ..\frontend
copy .env.example .envMặc định frontend gọi backend local:
VITE_API_BASE_URL=http://localhost:5000Dùng script có sẵn (đọc file csdl/ptit.sql):
npm run db:importNếu muốn reset sạch (xoá DB hiện tại rồi import lại):
npm run db:import -- --resetnpm startTerminal 1:
cd backend
npm startTerminal 2:
cd frontend
npm run dev- Port 3000 bị chiếm: Vite sẽ tự nhảy sang port khác (ví dụ 3001). Xem log terminal để biết port chính xác.
- MySQL access denied / cannot connect: kiểm tra MySQL đang chạy và các biến
DB_HOST/DB_USER/DB_PASSWORD/DB_NAMEtrongbackend/.env.
Repo đã có .gitignore để tránh push node_modules/, dist/, .env, uploads.
git add .
git commit -m "Initial commit"
git remote add origin <YOUR_REPO_URL>
git push -u origin main