- Clone Repo
- Setup Backend
- Setup Frontend
- OpenAI API Configuration
- GitHub Secrets Setup
- Database Setup (XAMPP)
- Git Workflow
- Deploy to cPanel
git clone https://github.com/leonthanh/my-project-FIXED.git
cd my-project-FIXEDcd backend
npm installTạo file backend/.env với nội dung:
DB_HOST=localhost
DB_NAME=wsxcblqh_ix
DB_USER=wsxcblqh_thanh
DB_PASS=
NODE_ENV=development
PORT=5000
EMAIL_USER=stareduelt@gmail.com
EMAIL_PASS=
EMAIL_TO=
REACT_APP_API_URL=http://localhost:5000
GEMINI_API_KEY=AIzaSyCNdfCuSNp6pG5281BxfP30ElK8oHDzob0
OPENAI_API_KEY=your_openai_api_key_herenpm start
# Hoặc dùng nodemon (tự reload khi thay đổi code)
npx nodemon server.jsBackend sẽ chạy ở: http://localhost:5000
cd frontend
npm installnpm startFrontend sẽ chạy ở: http://localhost:3000
- Vào: https://platform.openai.com/api-keys
- Click "Create new secret key"
- Copy key vừa tạo
- Lưu ý: Không bao giờ share public key này!
# backend/.env
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxx- Vào frontend:
http://localhost:3000 - Đăng nhập với tài khoản GV
- Click nút "🤖 StarEdu AI gợi ý nhận xét"
- Nếu thành công → AI sẽ trả về nhận xét chi tiết
- Vào repo:
https://github.com/leonthanh/my-project-FIXED - Click Settings → Secrets and variables → Actions
- Click "New repository secret"
- Thêm các secrets sau:
| Name | Value |
|---|---|
OPENAI_API_KEY |
sk-proj-xxxxxxxxxxxx |
GEMINI_API_KEY |
AIzaSyCNdfCuSNp6pG5281BxfP30ElK8oHDzob0 |
EMAIL_USER |
stareduelt@gmail.com |
EMAIL_PASS |
xxxx xxxx xxxx xxxx |
FTP_USERNAME |
wsxcblqh |
FTP_PASSWORD |
xxxxxxxxxxxx |
- KHÔNG bao giờ commit API Keys vào GitHub
- Luôn dùng
.gitignoređể bỏ qua file.env - Secrets được lưu an toàn ở GitHub, chỉ dùng khi deploy
- Download từ: https://www.apachefriends.org/
- Cài đặt, bật Apache + MySQL
- Mở phpMyAdmin:
http://localhost/phpmyadmin - Click "New"
- Tạo database:
wsxcblqh_ix - Character set:
utf8mb4_unicode_ci
- Vào "User accounts"
- Click "Add user account"
- Nhập:
- Username:
wsxcblqh_thanh - Host:
localhost - Password:
@Thanh562184
- Username:
- Click Go
- Chọn user vừa tạo
- Cấp "All privileges" cho database
wsxcblqh_ix
cd d:/web-app/my-project-FIXED
# LUÔN pull trước!
git pull origin main
# Code của bạn...# Xem thay đổi
git status
# Thêm files
git add .
# Commit với message rõ ràng
git commit -m "Thêm feature XYZ"
# Hoặc
git commit -m "Fix lỗi ABC"
# Push lên GitHub
git push origin main# Trước khi code
git pull origin main
# Code...
# Commit & push
git add .
git commit -m "..."
git push origin main- LUÔN
git pulltrước khi bắt đầu code - Tránh xung đột (conflict) khi 2 người code cùng lúc
- Commit message nên rõ ràng, ngắn gọn
- Khi bạn
git push origin main - GitHub Actions tự động chạy
- Deploy code lên cPanel (~5-10 phút)
- Vào:
https://github.com/leonthanh/my-project-FIXED - Click tab "Actions"
- Xem workflow "Deploy to cPanel" chạy
Sau khi deploy xong:
- Đăng nhập cPanel
- Vào Setup Node.js App
- Chọn app → Click "Restart"
- Chờ ~30 giây để server khởi động lại
# Truy cập app live
https://ix.star-siec.edu.vn# Kiểm tra port đã dùng
netstat -ano | findstr :5000
# Cài lại dependencies
rm -r node_modules package-lock.json
npm install- Kiểm tra OPENAI_API_KEY ở
.env - Kiểm tra key còn quota không
- Xem log backend:
npm start(terminal)
# Nếu xảy ra xung đột
git pull origin main
# Sửa files conflict (mở file, chọn phần cần giữ)
git add .
git commit -m "Resolve conflict"
git push origin mainLast Updated: 10/12/2025
Version: 1.0