App Setup လမ်းညွှန်

MoneyPilot ကို local environment ထဲမှာ အလုပ်လုပ်အောင် စတင်တပ်ဆင်ခြင်း

ဒီစာမျက်နှာမှာ frontend + backend + MySQL + Google OAuth ကို အစအဆုံး setup လုပ်ပုံကို မြန်မာလို အဆင့်လိုက်ဖော်ပြထားပါတယ်။

1) လိုအပ်ချက်များ (Prerequisites)

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 (လိုအပ်လျှင်)

  1. Google Cloud Console > APIs & Services > OAuth consent screen ကို configure လုပ်ပါ။
  2. Credentials > Create Credentials > OAuth client ID (Web application) ဖန်တီးပါ။
  3. Authorized redirect URI ထဲ `http://localhost:4000/api/auth/google/callback` ထည့်ပါ။
  4. 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) မှတ်ချက်