1) လိုအပ်ချက်များ (Prerequisites)
- Node.js 18+ နှင့် npm
- MySQL 8+ (သို့) MariaDB
- Google Cloud Console account (Google Login အသုံးပြုမယ်ဆိုလျှင်)
node -v
npm -v
mysql --version
2) Project dependency install
npm install --include=dev
`vite: not found` error တွေဖြစ်ရင် `node_modules` နှင့် lock file ကို fresh install ပြန်လုပ်ပါ။
rm -rf node_modules package-lock.json
npm install --include=dev
3) MySQL database ပြင်ဆင်ခြင်း
MySQL ထဲမှာ database/user တည်ဆောက်ပြီး permission ပေးပါ။
CREATE DATABASE expense_tracker CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'expense_user'@'localhost' IDENTIFIED BY 'strong_password_here';
GRANT ALL PRIVILEGES ON expense_tracker.* TO 'expense_user'@'localhost';
FLUSH PRIVILEGES;
4) .env ဖိုင်ပြင်ဆင်ခြင်း
cp .env.example .env
`.env` ထဲက value များကို သင့်စက်အလိုက် ပြင်ပါ။
VITE_API_BASE_URL=http://localhost:4000
PORT=4000
SERVER_BASE_URL=http://localhost:4000
FRONTEND_URL=http://localhost:5173
JWT_SECRET=your-long-random-jwt-secret
SESSION_SECRET=your-long-random-session-secret
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USER=expense_user
MYSQL_PASSWORD=strong_password_here
MYSQL_DATABASE=expense_tracker
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
5) Server နှင့် Frontend run လုပ်ခြင်း
Terminal (1) Backend server:
npm run dev:server
Terminal (2) Frontend app:
npm run dev
Health check:
curl http://localhost:4000/api/health
6) Google Login setup (လိုအပ်လျှင်)
- Google Cloud Console > APIs & Services > OAuth consent screen ကို configure လုပ်ပါ။
- Credentials > Create Credentials > OAuth client ID (Web application) ဖန်တီးပါ။
- Authorized redirect URI ထဲ `http://localhost:4000/api/auth/google/callback` ထည့်ပါ။
- Client ID/Secret ကို `.env` ထဲဖြည့်ပြီး backend restart လုပ်ပါ။
7) Common Errors & ဖြေရှင်းနည်း
`ECONNREFUSED 127.0.0.1:3306`
MySQL server မဖွင့်ထားတာ (သို့) host/port မမှန်တာဖြစ်နိုင်ပါတယ်။
sudo systemctl status mysql
sudo systemctl start mysql
ss -ltnp | grep 3306
`vite: not found`
devDependencies မပါဘဲ install ဖြစ်ထားနိုင်ပါတယ်။
npm install --include=dev
8) Build & Preview
npm run build
npm run preview
9) မှတ်ချက်
- Backend စတင်ချိန်မှာ `users` နှင့် `user_state` tables ကို auto-create လုပ်ပေးပါတယ်။
- User data ကို MySQL ထဲ sync လုပ်ပြီး browser local cache (`expense-tracker-storage`) လည်းထားပါတယ်။