# 🚀 Quick Start - Run Flutter App with Go Backend

## ⚡ 5-Minute Setup

### Step 1: Start Go Backend (Terminal 1)
```powershell
cd "D:\go project\avi_bd"
go run cmd/server/main.go
```

**Wait for:**
```
Server running on http://localhost:8080
```

---

### Step 2: Run Flutter App (Terminal 2)
```powershell
cd "d:\flutter project\avi"
flutter run
```

**Or use F5 in VS Code**

---

### Step 3: Test in Flutter App

#### Test Registration:
1. Open Flutter app
2. Click "Sign up"
3. Enter:
   - Name: `Test User`
   - Email: `test@example.com`
   - Password: `password123`
   - Confirm: `password123`
4. Click "Create Account"
5. ✅ Should redirect to home

#### Test Login:
1. Go back to login screen
2. Enter:
   - Email: `test@example.com`
   - Password: `password123`
3. Click "Login"
4. ✅ Should redirect to home

---

## 📊 Expected Console Output

```
[ApiService] POST request to: /api/v1/register
[ApiService] POST data: {name: Test User, email: test@example.com, password: password123}
[ApiService] POST response status: 201
[ApiService] POST response data: {token: eyJ..., user: {id: abc123, name: Test User, email: test@example.com, balance: 100.0, created_at: 2026-04-08T...}}
[AuthApiService] Register response type: _InternalLinkedHashMap<String, dynamic>
[AuthApiService] Register response: {token: eyJ..., user: {id: abc123...}}
[AuthRepository] Register response: {token: eyJ..., user: {id: abc123...}}
```

---

## ✅ What's Fixed

| Issue | Fix |
|-------|-----|
| Missing `balance` field | ✅ UserModel updated |
| Type casting errors | ✅ Proper validation added |
| Missing DioException case | ✅ All cases handled |
| No response logging | ✅ Full debug logging added |
| No error field checking | ✅ Response validation improved |

---

## 🐛 Troubleshooting

### "Connection refused"
```powershell
# Start backend
cd "D:\go project\avi_bd"
go run cmd/server/main.go
```

### "Invalid login response"
- Check console logs
- Backend might not be running
- Try a different email

### "Email already registered"
- Use a different email or delete database

### Other errors
- Check console logs `[ApiService]`, `[AuthRepository]`
- Backend health: `curl http://localhost:8080/api/v1/health`

---

## 📚 More Info

- [Full Run Guide](FLUTTER_BACKEND_RUN_GUIDE.md)
- [Issues Fixed Detail](API_ISSUES_FIXED_REFERENCE.md)
- [Complete Review](API_CODE_REVIEW_COMPLETE.md)

---

**Status:** ✅ Ready to run!
