Skip to content

About

群組餐廳決策 App 後端 API | Laravel + MySQL + Google Places API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

飯友 Meal Buddy — 後端 API

飯友 App 的後端服務,提供群組管理、餐廳搜尋、決策流程等 RESTful API。


功能介紹

  • 帳號系統:註冊、登入,使用 Laravel Sanctum Token 驗證
  • 群組管理:建立群組、邀請碼加入、退出(建立者退出自動解散)
  • Google Places 整合:地址自動補全、地點詳情、反向地理編碼、附近餐廳搜尋
  • 決策流程:
    • 各成員設定個人篩選條件後進入 Ready 狀態
    • 海選:每位成員從候選餐廳中勾選有興趣的選項
    • PK 賽:多輪淘汰,Race condition 防護確保結果一致
  • 即時狀態 API:前端輪詢用,回傳當前決策進度

技術架構

項目 技術
框架 Laravel 11
語言 PHP 8.2
資料庫 MySQL
驗證 Laravel Sanctum
外部 API Google Places API
容器化 Docker + Laravel Sail

資料庫結構

users               # 使用者
groups              # 群組
group_user          # 群組成員(多對多)
decisions           # 決策
decision_options    # 候選餐廳(含 user_id 區分各成員選項)
user_votes          # 海選投票記錄
user_filters        # 各成員篩選條件

主要 API 路由

POST   /api/register                          # 註冊
POST   /api/login                             # 登入

GET    /api/groups                            # 群組列表
POST   /api/groups                            # 建立群組
POST   /api/groups/join                       # 加入群組
POST   /api/groups/{id}/leave                 # 退出群組
GET    /api/groups/{id}/current-decision      # 當前決策狀態

POST   /api/decisions                         # 發起決策
POST   /api/decisions/{id}/ready              # 設定篩選條件並準備
GET    /api/decisions/{id}                    # 取得決策與候選餐廳
POST   /api/decisions/{id}/vote               # 海選投票
GET    /api/decisions/{id}/status             # 輪詢決策狀態
POST   /api/decisions/{id}/pk-submit          # PK 賽送出選擇

GET    /api/places/autocomplete               # 地址自動補全
GET    /api/places/detail                     # 地點詳情
GET    /api/places/reverse-geocode            # 反向地理編碼

本地啟動

環境需求

  • PHP 8.2+
  • Composer
  • Docker(使用 Laravel Sail)
  • Google Places API Key

步驟

# 安裝依賴
composer install

# 複製環境設定
cp .env.example .env

# 填入必要環境變數
# GOOGLE_PLACES_API_KEY=your_key
# DB_DATABASE / DB_USERNAME / DB_PASSWORD

# 啟動 Docker
./vendor/bin/sail up -d

# 執行 Migration
./vendor/bin/sail artisan migrate

前端 Repository

前端使用 React Native + Expo 開發,請參考:meal-buddy-frontend

About

群組餐廳決策 App 後端 API | Laravel + MySQL + Google Places API

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages