smooth-app
A collaborative, free and open database of ingredients, nutrition facts and information on food products from around the world
飲みすぎ防止・休肝日管理アプリ
Translation pending
HealthTypeScript · CSSGitHub @YusukeHaradaOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
No updates detected yet. GitHub releases will appear here.
Owners of public repositories under a personal GitHub account can sign in to verify ownership and manage the introduction themselves. No administrator approval is needed.
Sign in, generate a verification file, and commit it to this repository’s default branch within 30 minutes. Files on other branches or forks do not count. Then check the file below to manage the project without administrator approval. Keep the file to retain your access.
If needed, you will go to sign-in. After signing in, return here and press your chosen verification button again.
Run /nomorevibe verify in your project folder to verify ownership and manage the introduction yourself.
Verify in one minuteAsk about other verification options
The maker's introduction consists of the line above. Read the repository README for more details. Repository README ↗
Loading the full README.
Read the full README ↗飲みすぎ防止・休肝日管理アプリ
+ と手動入力の本数欄で、同じ酒をまとめて記録(DBは1レコード=1杯のまま。保存時に展開する)| 層 | 技術 |
|---|---|
| Framework | Next.js 15 (App Router) |
| Language | TypeScript |
| Styling | Tailwind CSS |
| Backend/DB | Supabase |
| Hosting | Vercel |
| Unit Test | Vitest + React Testing Library |
npm install
Supabase でプロジェクトを作成し、Project URL と anon key を取得する。
# Supabase CLI のインストール(未インストールの場合)
npm install -g supabase
# DB マイグレーションを適用
npx supabase db push
プロジェクトルートに .env.local を作成して以下を記入する。
NEXT_PUBLIC_SUPABASE_URL=https://<your-project>.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=<your-anon-key>
| 変数 | 用途 | 公開範囲 |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL | Supabase プロジェクトの URL | クライアント |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Supabase の anon key | クライアント |
Discord リマインドを使う場合は以下も設定する(アプリ本体の動作には不要)。
SUPABASE_SERVICE_ROLE_KEY=<your-service-role-key>
CRON_SECRET=<任意のランダム文字列>
REMINDER_USER_ID=<auth.users.id の UUID>
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
APP_URL=https://<your-app>.vercel.app/
| 変数 | 用途 | 公開範囲 |
|---|---|---|
SUPABASE_SERVICE_ROLE_KEY | cron から DB を読む(RLS をバイパスする) | サーバー専用。絶対に NEXT_PUBLIC_ を付けない |
CRON_SECRET | cron エンドポイントの Bearer 認証。Vercel が自動で付与する | サーバー専用 |
REMINDER_USER_ID | リマインド対象の auth.users.id | サーバー専用 |
DISCORD_WEBHOOK_URL | Discord の Incoming Webhook URL | サーバー専用(漏れると誰でもチャンネルに投稿できる) |
APP_URL | 通知に載せるアプリの URL | サーバー専用 |
本番では Vercel の Settings → Environment Variables に Production スコープで登録する。
ローカル検証は .env.local(gitignore 済み)に置く。
npm run dev
npm test # ウォッチモードで実行
npm run test:run # 1回だけ実行
npm run test:coverage # カバレッジレポート付きで実行
npm run test:ui # ブラウザ UI で確認
src/
app/ # Next.js App Router ページ(calendar / stats / templates / settings / login)
api/cron/ # Vercel Cron から叩かれる Route Handler
domain/ # ビジネスロジック(純粋関数)
components/ # UI コンポーネント
actions/ # Server Actions(drink / goal / restDay / template)
repository/ # Supabase アクセス層
lib/ # 型定義・Supabase クライアント
constants/ # 定数(飲み物カテゴリ等)
supabase/
migrations/ # DB マイグレーション
docs/ # アーキテクチャ・設計ドキュメント
npx vercel --prod
未記録の日の夜21時(JST)に Discord へ通知する。vercel.json の crons で
/api/cron/reminder を叩き、その日に飲酒記録も休肝日登録も無ければ Webhook に POST する。
記録済みの日は送らない(毎晩届く通知は読み飛ばされるようになるため)。
手元での確認:
# 認証なし → 401(302 で /login に飛ぶ場合は middleware の除外が効いていない)
curl -i http://localhost:3000/api/cron/reminder
# 認証あり → 未記録なら Discord に着弾、記録済みなら {"ok":true,"skipped":true}
curl -i -H "Authorization: Bearer $CRON_SECRET" http://localhost:3000/api/cron/reminder
# Webhook 単体の疎通確認
curl -X POST -H 'Content-Type: application/json' \
-d '{"content":"テスト"}' "$DISCORD_WEBHOOK_URL"
注意点:
0 12 * * * = 21:00 JSTCRON_SECRET が未設定だと毎晩 401 になり、通知が来ないまま静かに失敗する。デプロイ後に一度手動で叩いて確認する純アルコール量(g) = 容量(mL) × (度数 / 100) × 0.8
例:ビール 500mL 5% → 500 × 0.05 × 0.8 = 20g