Mood Pick

https://github.com/Shun-Yamana/Portfolio4

React

AWS

DynamoDB

Python

VSCode

今の気分を選ぶだけで、AIがあなたの「今日のデザート」を見つける

yuum

aym

470g877a1h

SP KADOWAKI Yuma

推しアイデア

・エネルギーを使わずに商品を選べる ・新しい商品との出会い ・気分を商品と結びつけること

作った背景

・優柔不断な人ばかりだった →素早い意思決定! ・気分を数値化したかった!

推し技術

・気分と商品のベクトルからMH法を使い、最適化。 ・AIでAWSのベッドロックでレコメンド理由を生成。

プロジェクト詳細

🛒 気分タップだけでコンビニ最適商品をAIがレコメンドするアプリ


🔥 作った背景

コンビニの棚の前で3分間立ち尽くして「まあいっか」で買う体験、誰しも一度はあるはず。 「これだわ」を先に届けたい気持ちで作りました。

image

🎯 使い方(3ステップ)

  1. 気分を選ぶ(甘い・しょっぱい・疲れた etc.)
  2. 候補から一番近い商品をタップ × 2〜3回 途中で決めたり、ランダムで選んでもらえる
  3. AIがあなた専用の一品をレコメンド
  4. 友達にシェア✅

⚙️ 使用技術

S3 CloudFront Lambda API Gateway DynamoDB Amazon Bedrock AWS CDK


🏆 推しポイント

  • 管理者のみ在庫管理設計で実用性が高い
  • 選ぶたびに賢くなる嗜好ベクトルで、3回でレコメンド
  • 選ぶのが面倒になったら気分情報から商品をランダムで決められる
  • Metropolis-Hastings法で 探索と収束を両立 単純なスコア計算ではなく、確率を使用して提案に柔軟性を持たせる!
  • AIが選ばれた理由を人間の言葉で説明してくれる AWS Bedrockを使用
  • シェアすることでアプリの拡散

↓ワンタイムパスワードを生成するpythonコード

import React, { useState } from "react"; function AdminLoginPage({ onLoginSuccess, onBack }) { // ← ここで onBack を受け取る const [password, setPassword] = useState(""); const [error, setError] = useState(""); const handleLogin = (e) => { e.preventDefault(); if (password === "admin123") { onLoginSuccess(); } else { setError("パスワードが違います"); setPassword(""); } }; return ( <div style={{ display: "flex", justifyContent: "center", alignItems: "center", height: "100vh", backgroundColor: "#f0f2f5", fontFamily: "sans-serif", }} > <div style={{ padding: "40px", background: "white", borderRadius: "12px", boxShadow: "0 4px 12px rgba(0,0,0,0.1)", width: "320px", textAlign: "center", }} > <h2 style={{ marginBottom: "20px" }}>管理者ログイン</h2> <form onSubmit={handleLogin}> <input type="password" placeholder="パスワードを入力" value={password} onChange={(e) => setPassword(e.target.value)} style={{ width: "100%", padding: "12px", marginBottom: "10px", boxSizing: "border-box", border: "1px solid #ccc", borderRadius: "6px", }} /> {error && ( <p style={{ color: "red", fontSize: "14px", marginBottom: "10px" }}> {error} </p> )} <button type="submit" style={{ width: "100%", padding: "12px", backgroundColor: "#007bff", color: "white", border: "none", borderRadius: "6px", cursor: "pointer", fontWeight: "bold", }} > ログイン </button> </form> {/* 【修正】onClick で確実に onBack を呼ぶようにしました */} <button type="button" onClick={() => { console.log("戻るボタンが押されました"); // 動作確認用 onBack(); }} style={{ marginTop: "20px", background: "none", border: "none", color: "#666", cursor: "pointer", textDecoration: "underline", }} > キャンセルして戻る </button> </div> </div> ); } export default AdminLoginPage;
import datetime import math def calculate_chaos_pass(): # 1. 強制的に日本時間 (UTC+9) を取得する # 実行環境がUTCでも、これで確実に日本時間になります jst = datetime.timezone(datetime.timedelta(hours=9)) now = datetime.datetime.now(jst) # 2. 月・日・時(24h)・分を数値化 (例: 10時45分 -> 1045) time_str = now.strftime("%m%d%H%M") time_num = int(time_str) # 3. 初期値 x0 (React側と完全に一致させる定数) x = 0.123456 + (time_num / 100000000.0) x = x % 1.0 # 4. カオスパラメータ a=4.0 a = 4.0 for _ in range(50): x = a * x * (1.0 - x) # 5. 6桁抽出 chaos_code = str(math.floor((x * 1000000) % 1000000)).zfill(6) # デバッグ用に計算の元データも出力 return chaos_code, now.strftime("%Y/%m/%d %H:%M"), time_num if __name__ == "__main__": code, full_time, t_num = calculate_chaos_pass() print("=" * 40) print(f" [確定] 日本時間 : {full_time}") print(f" [計算用数値] : {t_num}") print(f" [カオスコード] : {code}") print("=" * 40) print(str(6000)) print(str(6000).zfill(6))

yuum

@eec81b3ea6c21d7e