利用フロー・状態遷移 User flows & state transitions

エンドツーエンドの利用シナリオ、主要エンティティの状態遷移、 および状態変更トリガを整理します。実装時のステートマシン設計の一次情報源として参照してください。

End-to-end user scenarios, state transitions for core entities, and the triggers that drive state changes. Use this page as the primary reference when designing state machines in implementation.

5.1 主要エンティティ 5.1 Core entities

エンティティEntity テーブルTable 主要ステータスKey statuses
アプリユーザーApp user app_users active / withdrawn / suspended
駐車セッションParking session parking_sessions pending / parking / ended / cancelled
レビューReview parking_reviews draft / pending / approved / rejected
駐車場Parking lot parking_lots new / active / hidden / closed
サポートチケットSupport ticket support_tickets open / in_progress / waiting_user / resolved / closed
誤情報報告Error report error_reports submitted / triaging / resolved / rejected
プレミアム契約Premium subscription user_subscriptions trial / active / grace / cancelled / expired
通知Notification user_notifications unread / read / dismissed

5.2 駐車セッション 状態遷移図 5.2 Parking session state diagram

stateDiagram-v2
  [*] --> pending : ユーザーが「駐車開始」
  pending --> parking : RPC成功 (入庫確定)
  pending --> cancelled : 5分以内に取消
  parking --> ended : ユーザーが「駐車終了」
  parking --> ended : 自動終了 (72h超過)
  ended --> [*]
  cancelled --> [*]

遷移条件 Transition conditions

from to トリガTrigger 副作用Side effects
pending 駐車開始ボタンStart-parking button parking_sessions INSERT, GPS記録parking_sessions INSERT, GPS recorded
pending parking 入庫確定(即時 or 5秒猶予)Entry confirmed (immediate or 5 sec grace) Live Activity 開始、料金計時開始、user_activity_logs INSERTLive Activity starts, fee timer starts, user_activity_logs INSERT
pending cancelled 5分以内の取消Cancelled within 5 minutes セッション破棄、Live Activity 終了Session discarded, Live Activity ended
parking ended 駐車終了ボタンEnd-parking button RPC finalize_parking_session、total_amount 確定、Live Activity 終了、レビュー導線、EXP付与RPC finalize_parking_session, total_amount finalized, Live Activity ended, review prompt, EXP granted
parking ended 72時間自動終了(Cron)72-hour auto-end (Cron) 上記同様+長時間駐車通知Same as above plus long-parking notification

5.3 レビュー 状態遷移図 5.3 Review state diagram

stateDiagram-v2
  [*] --> draft : ユーザー作成
  draft --> pending : 投稿
  pending --> approved : 管理者承認 or 自動承認
  pending --> rejected : 管理者却下
  approved --> [*]
  rejected --> [*]

デフォルトは自動承認(NG ワード検出なし+写真AIチェックOK)で approved になります。疑わしい場合は pending のまま管理者ポータルでレビュー待ちです。

By default reviews are auto-approved (no banned words detected and photo AI check passes) and become approved. Suspicious ones stay pending and wait for moderation in the admin portal.

5.4 ユーザー 状態遷移図 5.4 User state diagram

stateDiagram-v2
  [*] --> active : サインアップ完了
  active --> suspended : 利用規約違反 (管理者)
  suspended --> active : 解除
  active --> withdrawn : ユーザー退会
  withdrawn --> [*]

5.5 主要シナリオ詳細 5.5 Detailed scenarios

シナリオA:目的地から駐車する(初回利用者) Scenario A: Park from a destination (first-time user)

sequenceDiagram
  participant U as ユーザー
  participant App as モバイルアプリ
  participant API as Supabase
  participant Mb as Mapbox

  U->>App: スプラッシュ→オンボーディング→サインアップ
  App->>API: signUp + createAppUser
  API-->>App: session + app_users行
  U->>App: 目的地「渋谷駅」入力
  App->>Mb: Geocoding
  Mb-->>App: 座標
  App->>API: nearby_parking_lots RPC
  API-->>App: 駐車場配列
  App->>App: 料金シミュレーション(ローカル)
  App->>App: 並び替え・ランキングバッジ付与
  U->>App: ピンタップ→詳細表示
  U->>App: 駐車開始ボタン
  App->>API: create_parking_session RPC
  API-->>App: session (parking)
  App->>App: Live Activity開始・料金計時
  Note over App: 駐車中(数時間)
  U->>App: 駐車終了ボタン
  App->>API: finalize_parking_session RPC
  API-->>App: 確定金額
  App->>U: Good/Bad→レビュー投稿導線
  U->>App: ★4・コメント・写真投稿
  App->>API: parking_reviews INSERT + R2 upload

シナリオB:AI検索で意思決定 Scenario B: Decide with AI search

  1. ホームで「AI検索」切替
  2. Toggle "AI search" on the home screen
  3. 「池袋で今夜23時から朝9時まで2000円以下」と入力
  4. Type something like "Ikebukuro, 11pm tonight to 9am, under 2000 yen"
  5. クライアント → Cloudflare Workers ai-search-parse
  6. Client → Cloudflare Workers ai-search-parse
  7. Cloudflare Workers → LLM → 構造化条件を返却
  8. Cloudflare Workers → LLM → returns structured conditions
  9. 通常の検索処理に投入 → 結果を表示
  10. Feed into the normal search pipeline → show results
  11. ユーザーが選択・駐車開始
  12. User picks a lot and starts parking

シナリオC:駐車中に料金アラート Scenario C: Fee alert while parked

  1. ユーザーは料金閾値を1500円に設定
  2. User sets the fee threshold to 1500 yen
  3. 累計料金が1500円に到達
  4. Accumulated fee reaches 1500 yen
  5. DB トリガ(or アプリローカル判定)が user_notifications INSERT
  6. DB trigger (or local app check) inserts into user_notifications
  7. Trigger → Workers queue parky-fcm-dispatch → FCM
  8. Trigger → Workers queue parky-fcm-dispatch → FCM
  9. Push 受信 → タップで駐車詳細画面へ
  10. Push received → tap opens the parking detail screen
  11. ユーザーが駐車終了を判断
  12. User decides whether to end parking

シナリオD:駐車場の誤情報報告 Scenario D: Reporting incorrect parking lot info

  1. 駐車場詳細画面で「誤情報を報告」をタップ
  2. Tap "Report incorrect info" on the parking lot detail screen
  3. 項目選択(料金誤り / 営業時間 / 施設情報等)とコメント入力
  4. Select a category (wrong fee / hours / facility info, etc.) and add a comment
  5. error_reports INSERT(submitted
  6. error_reports INSERT (submitted)
  7. 管理者ポータルで審査 → triagingresolved
  8. Reviewed in the admin portal → triagingresolved
  9. 解決時にユーザーへ通知
  10. User is notified when resolved

5.6 状態変更トリガー一覧 5.6 State change triggers

トリガ種別Trigger type 対象Target Example
ユーザー操作User action セッション・レビュー・保存等Sessions, reviews, saves, etc. 駐車開始ボタン、レビュー投稿、ハートタップStart-parking button, review submission, heart tap
DB トリガDB trigger 通知・EXP・バッジNotifications, EXP, badges parking_sessions INSERT後に EXP付与、バッジ進捗更新Grant EXP and update badge progress after parking_sessions INSERT
スケジューラ (Cron)Scheduler (Cron) 長時間駐車・期限切れLong parking, expirations 72h駐車検知、サブスク更新チェック、定期通知72-hour parking detection, subscription renewal checks, recurring notifications
外部 WebhookExternal webhook 決済・ストアPayments, app stores IAP レシート検証後 subscription 状態更新Update subscription status after IAP receipt verification
管理者操作Admin action ユーザー/駐車場/レビューUsers / lots / reviews suspended 設定、誤情報 resolve、レビュー却下Setting suspended, resolving error reports, rejecting reviews
Realtime 同期Realtime sync 複数端末間の状態State across multiple devices 他端末での駐車終了を即反映Instantly reflect an end-parking action from another device