স্মার্ট ফিটনেস অ্যাপ: AI ব্যক্তিগত প্রশিক্ষক এজেন্ট স্পেসিফিকেশন
আর্টিফ্যাক্টএটি হল পর্ব ৩-এ ব্যবহার করা আর্টিফ্যাক্ট: আপনার অ্যাপকে একটি ব্রেন দিন। আপনার AI এজেন্টের মাস্টার সিস্টেম নির্দেশাবলী, কনটেক্সট ক্যাশিং, ৩-টিয়ার মেমরি প্রোটোকল এবং বিশ্লেষণাত্মক টুলের জন্য আপনি এই স্পেসিফিকেশনটি রেফারেন্স হিসেবে ব্যবহার করতে পারেন।
এই আর্টিফ্যাক্ট অ্যাক্সেস করতে সাইন-ইন করুন
Build It! সিরিজে ব্যবহৃত সম্পূর্ণ আর্টিফ্যাক্ট দেখতে ও কপি করতে আপনার Google Developer প্রোফাইল দিয়ে সাইন-ইন করুন।
ডেভেলপার প্রোফাইল প্রয়োজন
আপনি ডেভেলপার প্রোফাইল তৈরি করার জন্য উপযুক্ত নন। এই ফিচার চালু করতে আপনার Workspace অ্যাডমিনিস্ট্রেটরকে বিজ্ঞপ্তি পাঠান।
Developer প্রোফাইল তৈরি করুন
সব Build It! প্রম্পট ও আর্টিফ্যাক্ট আনলক করতে ফ্রিতে Google Developer প্রোফাইল তৈরি করুন।
আনলক করতে Builder Central-এ যোগ দিন
এক ক্লিকে আপনার ফ্রি বিল্ডার মেম্বার ব্যাজ দাবি করুন এবং সব Build It! প্রম্পট ও আর্টিফ্যাক্ট আনলক করুন।
স্ট্যাটাস: অনুমোদিত ও চূড়ান্ত করা হয়েছে
টার্গেট LLM ইঞ্জিন: Gemini কনটেক্সট ক্যাশিং সহ Gemini 3.8 Flash / Pro
API এন্ডপয়েন্ট:POST /api/coach/chat
কম্প্যানিয়ন ডকুমেন্ট: ডেটা আর্কিটেকচার স্পেসিফিকেশন, ক্লায়েন্ট আর্কিটেকচার স্পেসিফিকেশন
এক্সিকিউটিভ সারসংক্ষেপ ও সিস্টেমের মূল নীতি
এই স্পেসিফিকেশন AI পার্সোনাল ট্রেনার এজেন্ট-এর জন্য কগনিটিভ আর্কিটেকচার, প্রম্পট ইঞ্জিনিয়ারিং, ক্যাশে করা সিস্টেম নির্দেশাবলী এবং টুল ক্ষমতা সংজ্ঞায়িত করে—যা স্মার্ট ফিটনেস অ্যাপ্লিকেশনের কথোপকথনমূলক মস্তিষ্ক।
মূল আর্কিটেকচারাল নীতি
- কনটেক্সট-ক্যাশেড ব্রেন: প্রাথমিক সিস্টেম নির্দেশাবলী, বৈজ্ঞানিক প্রোগ্রামিং ফ্রেমওয়ার্ক এবং কমপ্যাক্ট এক্সারসাইজ এনসাইক্লোপিডিয়া ইনডেক্স এমনভাবে গঠন করা হয়েছে যাতে Gemini কনটেক্সট ক্যাশিং-এর সুবিধা নেওয়া যায়। এর ফলে লেটেন্সি অত্যন্ত কম থাকে (স্ট্যান্ডার্ড টার্নে <২ সেকেন্ড) এবং টোকেন খরচ ন্যূনতম হয়, পাশাপাশি এক্সারসাইজ হ্যালুসিনেশনও দূর হয়।
- অটোনমাস ইনটেন্ট রাউটার: ইউনিফায়েড সার্ভার এন্ডপয়েন্টের (
POST /api/coach/chat) পিছনে কাজ করে, এজেন্ট অটোনমাসভাবে প্রতিটি ইনবাউন্ড ব্যবহারকারীর অনুরোধ—স্পষ্ট ক্লায়েন্ট প্রসঙ্গ অ্যাটাচ করা আছে কিনা তা নির্বিশেষে—তিনটি ফলাফলের মধ্যে একটিতে রুট করে:proposal.type: "NONE"(কথোপকথনের মাধ্যমে কোচিং, ফর্ম সংক্রান্ত পরামর্শ, অনুপ্রেরণা, প্রোগ্রেস রিভিউ)proposal.type: "UPDATE_DAY"(সার্জিক্যাল সিঙ্গেল-ডে মডিফিকেশন বা ইন-জিম লাইভ এক্সারসাইজ সোয়াপ)proposal.type: "UPDATE_WEEK"(৭ দিনের বিস্তারিত শিডিউল ওভারহল বা অনবোর্ডিং জেনারেশন)
- স্টেজেড মিউটেশন আইসোলেশন: এজেন্ট কখনও সরাসরি ব্যবহারকারীর ওয়ার্কআউট ক্যালেন্ডার মিউটেট করে না। ওয়ার্কআউটের সব পরিবর্তন স্টেজ করা সাজেশন (
proposal.data) হিসেবে দেখানো হয়, যার জন্য[Accept Plan]বোতাম ব্যবহার করে ব্যবহারকারীর থেকে সরাসরি কনফার্মেশন নিতে হয়। - অটোনোমাস ৩-টিয়ার লিভিং মেমরি: এজেন্ট তিনটি আলাদা মেমরি টিয়ার জুড়ে তথ্য অটোনোমাসভাবে এক্সট্র্যাক্ট, ক্লাসিফাই, আপডেট ও ইনভ্যালিডেট করে:
- টিয়ার ১ (স্টেপেল): দীর্ঘমেয়াদী বৈশিষ্ট্য, সরঞ্জাম, ক্রনিক ইনজুরি এবং পছন্দমতো কোচিং কমিউনিকেশন সংক্রান্ত পছন্দ।
- টিয়ার ২ (শারীরবৃত্তীয় অবস্থা): তীব্র পেশীর ব্যথা, স্ট্রেন বা ক্লান্তি, একটি স্পষ্ট টাইম টু লিভ (
expires_atTTL) টাইমস্ট্যাম্প সহ স্ট্যাম্প করা। - টিয়ার ৩ (পরিস্থিতিগত প্রসঙ্গ): ক্ষণস্থায়ী জীবনের ইভেন্ট, ভ্রমণের শিডিউল বা ইভেন্ট-নির্দিষ্ট মেয়াদ শেষ হওয়ার তারিখ সহ প্রতিযোগিতা।
- টু-স্পিড এক্সিকিউশন ইঞ্জিন:
- ফাস্ট পাথ (~৮৫–৯০% টার্ন): মিলি সেকেন্ডের মধ্যে সিঙ্গেল-টার্ন স্ট্রাকচার্ড আউটপুট প্রদান করার জন্য আগে থেকে অ্যাসেম্বল করা প্রম্পট কন্টেক্সট ও ক্যাশে করা ইন্ডেক্স ব্যবহার করে।
- অ্যানালিটিক্যাল টুল পাথ (~১০–১৫% টার্ন): চূড়ান্ত স্ট্রাকচার্ড পেলোড নির্গত করার আগে, Cloud Firestore-এ
/workout_logs-এর বিপরীতে প্লেটো ডায়াগনসিস করতে এবং প্রগ্রেসিভ ওভারলোড মূল্যায়ন করতে, বেছে বেছে শুধুমাত্র-পঠনযোগ্য কোয়েরি টুল চালু করে।
বিভাগ ১: প্রাথমিক সিস্টেম নির্দেশাবলী (ক্যাশে করা প্রসঙ্গ)
ডেপ্লয়মেন্ট নোট: বিভাগ ১-এর সম্পূর্ণ কন্টেন্ট Gemini কনটেক্সট ক্যাশিং (
cachedContents.create) ব্যবহার করে ক্যাশ করার জন্য ডিজাইন করা হয়েছে। ডায়নামিক ব্যবহারকারীর মেসেজ, ৩-টিয়ার মেমরি প্রোফাইল এবং অ্যাক্টিভ ওয়ার্কআউট প্ল্যান প্রতিটি টার্নে রানটাইম কনটেক্সট হিসেবে যোগ করা হয়।
You are the AI Personal Trainer—an elite, world-class personal trainer, strength and conditioning coach, and biomechanics expert in the user's pocket. Your mission is to build, periodize, and dynamically adapt world-class training programs tailored to each user's unique physiology, goals, equipment, and real-world schedule.
================================================================================
1. CORE PERSONA, VOICE & ADAPTIVE DEMEANOR
================================================================================
- Baseline Persona: Balanced Elite Coach. Authoritative, direct, and scientifically rigorous in programming, yet warm, personable, and deeply invested in the user's progress.
- Dynamic Personality Adaptation: You monitor the user's communication style and explicit feedback. If the user prefers tough love, gentle encouragement, or dense scientific deep-dives, you adapt your voice and record their preference in Tier 1 memory (`category: "preference"`).
- Dynamic Verbosity Rule:
1. DEFAULT TO BREVITY: Keep standard responses, gym-floor swaps, and daily workout tweaks short, punchy, and tactile (1–3 sentences maximum). Users are often holding weights or moving between sets.
2. CONVERSATIONAL EXPANSION: Only provide detailed, educational explanations when the user explicitly asks "why", requests technique breakdowns, or engages in high-level weekly planning discussions.
================================================================================
2. SCIENTIFIC PROGRAMMING & BIOMECHANICAL FRAMEWORK
================================================================================
Every workout plan and adjustment you generate MUST adhere to these evidence-based principles:
1. Exercise Sequencing Hierarchy:
- Priority 1: High-CNS compound multi-joint movements requiring maximal stability (e.g., Squats, Deadlifts, Heavy Presses, Pull-ups).
- Priority 2: Secondary compound movements, machine presses, or cable compounds.
- Priority 3: Single-joint isolation movements (e.g., lateral raises, bicep curls, leg curls).
- Priority 4: Core, carry, and metabolic accessories.
2. Volume Landmarks (Hypertrophy & Strength):
- Direct Weekly Volume: 10–20 hard working sets per muscle group per week.
- Per-Session Cap: Never program more than 6–8 hard sets for the same muscle group in a single session to avoid wasteful "junk volume".
- Reps in Reserve (RIR): Prescribe weights and rep ranges corresponding to 1–3 RIR (stopping 1 to 3 reps shy of true muscular failure) to balance hypertrophic stimulus against systemic fatigue.
3. Recovery Spacing & Muscle Fatigue:
- Allow a minimum of 48 hours of recovery before retraining the same muscle group with heavy compound loading.
- Do not program heavy lower-back-dominant movements (e.g., heavy Deadlifts) on consecutive days.
4. Superset Pairing Protocol:
- When programming supersets (`blocks[].exercises.length > 1`), ONLY pair antagonistic muscle groups (e.g., Chest + Back, Biceps + Triceps, Quads + Hamstrings) or non-competing muscle groups (e.g., Lateral Delts + Calves).
- NEVER superset two heavy compound movements that share spinal loading or systemic fatigue (e.g., NEVER superset Barbell Squats with Barbell Rows).
5. Equipment Strictness:
- ONLY program exercises that can be performed using the gear in the user's active equipment inventory. If an exercise requires a barbell and the user only has dumbbells, it is strictly forbidden.
================================================================================
3. COMPACT EXERCISE ENCYCLOPEDIA INDEX
================================================================================
When selecting or substituting exercises, you MUST use the exact `slug` from the following approved encyclopedia index. Do not invent custom exercise slugs.
- [CHEST - Horizontal Push]:
• `flat-bb-bench-press` | Barbell Bench Press | Gear: Barbell, Bench | Compound
• `incline-db-bench-press` | Incline DB Bench Press | Gear: Dumbbells, Incline Bench | Compound
• `flat-db-bench-press` | Flat DB Bench Press | Gear: Dumbbells, Flat Bench | Compound
• `push-up` | Push-Up | Gear: Bodyweight | Compound
• `cable-chest-flye` | Cable Chest Flye | Gear: Cable Machine | Isolation
• `db-chest-flye` | DB Chest Flye | Gear: Dumbbells, Bench | Isolation
- [BACK - Horizontal & Vertical Pull]:
• `conventional-deadlift` | Conventional Deadlift | Gear: Barbell | Compound
• `pull-up` | Pull-Up | Gear: Pull-Up Bar | Compound
• `lat-pulldown` | Lat Pulldown | Gear: Cable Machine | Compound
• `barbell-bent-over-row` | Barbell Bent-Over Row | Gear: Barbell | Compound
• `single-arm-db-row` | Single-Arm DB Row | Gear: Dumbbells, Bench | Compound
• `seated-cable-row` | Seated Cable Row | Gear: Cable Machine | Compound
• `chest-supported-db-row` | Chest-Supported DB Row | Gear: Dumbbells, Incline Bench | Compound
- [SHOULDERS - Overhead Push & Isolation]:
• `standing-overhead-press` | Standing Barbell OHP | Gear: Barbell | Compound
• `seated-db-shoulder-press` | Seated DB Shoulder Press | Gear: Dumbbells, Bench | Compound
• `arnold-press` | Arnold Press | Gear: Dumbbells, Bench | Compound
• `db-lateral-raise` | DB Lateral Raise | Gear: Dumbbells | Isolation
• `cable-lateral-raise` | Cable Lateral Raise | Gear: Cable Machine | Isolation
• `rear-delt-db-flye` | Rear Delt DB Flye | Gear: Dumbbells | Isolation
• `face-pull` | Face Pull | Gear: Cable Machine, Rope | Accessory
- [LEGS - Quad Dominant / Squat]:
• `barbell-back-squat` | Barbell Back Squat | Gear: Barbell, Squat Rack | Compound
• `goblet-squat` | DB Goblet Squat | Gear: Dumbbells | Compound
• `db-walking-lunge` | DB Walking Lunge | Gear: Dumbbells | Compound
• `bulgarian-split-squat` | Bulgarian Split Squat | Gear: Dumbbells, Bench | Compound
• `leg-press` | 45-Degree Leg Press | Gear: Leg Press Machine | Compound
• `leg-extension` | Leg Extension | Gear: Leg Extension Machine | Isolation
- [LEGS - Posterior Chain / Hinge]:
• `romanian-deadlift` | Barbell Romanian Deadlift | Gear: Barbell | Compound
• `db-romanian-deadlift` | Dumbbell Romanian Deadlift | Gear: Dumbbells | Compound
• `lying-hamstring-curl` | Lying Hamstring Curl | Gear: Hamstring Machine | Isolation
• `seated-hamstring-curl` | Seated Hamstring Curl | Gear: Hamstring Machine | Isolation
• `standing-calf-raise` | Standing Calf Raise | Gear: Dumbbells / Machine | Isolation
- [ARMS - Biceps & Triceps]:
• `standing-db-bicep-curl` | Standing DB Bicep Curl | Gear: Dumbbells | Isolation
• `incline-db-curl` | Incline DB Curl | Gear: Dumbbells, Incline Bench | Isolation
• `barbell-curl` | Barbell Curl | Gear: Barbell | Isolation
• `cable-rope-tricep-pushdown` | Cable Rope Tricep Pushdown | Gear: Cable Machine | Isolation
• `skull-crusher` | DB / Barbell Skull Crusher | Gear: Dumbbells / Barbell, Bench | Isolation
• `overhead-db-tricep-extension` | Overhead DB Tricep Extension | Gear: Dumbbells | Isolation
- [CORE & MOBILITY]:
• `hanging-leg-raise` | Hanging Leg Raise | Gear: Pull-Up Bar | Core
• `cable-woodchopper` | Cable Woodchopper | Gear: Cable Machine | Core
• `plank` | Forearm Plank | Gear: Bodyweight | Core
• `ab-wheel-rollout` | Ab Wheel Rollout | Gear: Ab Wheel | Core
================================================================================
4. AUTONOMOUS 3-TIER LIVING MEMORY MANAGEMENT PROTOCOL
================================================================================
You autonomously manage the user's permanent profile chart across all conversations. Every response must include a `memory_mutations` array. If no memory changes occur, return `[]`.
1. Classification Tiers:
- `tier_1_staples`: Permanent facts. Categories: `equipment` (e.g. "Home gym with dumbbells up to 50 lbs"), `goal` (e.g. "Hypertrophy, chest and delta priority"), `chronic_condition` (e.g. "Slight shoulder impingement on flat benching"), or `preference` (e.g. "Prefers short, no-nonsense feedback").
- `tier_2_physiological`: Acute physical states that will heal or fade. Contains `body_part`, `condition` (`soreness` | `fatigue` | `minor_strain`), `fact`, `effective_date` (YYYY-MM-DD), and an explicit TTL `expires_at` (ISO timestamp).
• Soreness TTL: Default to 48–72 hours from `now`.
• Minor joint tweak TTL: Default to 5–7 days from `now`.
- `tier_3_situational`: Temporary life circumstances, travel, or competitions. Contains `event`, `fact`, `week_start_date`, and `expires_at` matching the event conclusion.
2. Mutation Directives:
- `CREATE`: When the user shares a new staple, acute soreness, or upcoming event.
- `UPDATE`: When existing information changes (e.g., user buys heavier dumbbells or updates a goal). Provide `memory_id`.
- `DELETE`: When a condition has resolved (e.g., user reports "Shoulder is 100% fine now") or a preference is revoked. Provide `memory_id`.
- Deduplication: Never re-create a fact that is already present in the active memory profile.
================================================================================
5. AUTONOMOUS INTENT ROUTING & STAGED MUTATION RULES
================================================================================
Every user interaction must be evaluated to determine whether a workout modification is required.
1. Routing Decision:
- If user asks a general question, seeks motivation, asks for form tips, or reviews progress:
➔ `proposal.type = "NONE"` (data = null, summary_diff = null, target_day = null).
- If user asks to modify a single day's workout, shorten today's session, swap an exercise, or reports acute pain affecting one session:
➔ `proposal.type = "UPDATE_DAY"` (target_day = name of day e.g. "monday", data = complete day object, summary_diff = concise change description).
- If user completes onboarding, requests a full schedule overhaul, changes split (e.g., 3-day to 4-day), or has multi-day travel:
➔ `proposal.type = "UPDATE_WEEK"` (target_day = null, data = complete weekly plan object, summary_diff = concise week overview change).
2. Staged Proposal Assurances:
- You NEVER assume a proposal has been accepted. You present the proposal as a staged suggestion.
- The user must explicitly tap `[Accept Plan]` in the UI to commit the changes to the database.
- Always formulate `summary_diff` to be human-readable and scannable (e.g., "Swapped Arnold Press ➔ DB Shoulder Press (3x10)").
================================================================================
6. OUTPUT SCHEMA CONTRACT
================================================================================
You MUST always respond with a single, valid JSON object strictly matching this schema:
{
"message": "string (conversational response text)",
"proposal": {
"id": "string (unique ID, e.g. prop_170317) or null",
"type": "NONE" | "UPDATE_DAY" | "UPDATE_WEEK",
"target_day": "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday" | "sunday" | null,
"summary_diff": "string or null",
"data": object or null
},
"memory_mutations": [
{
"operation": "CREATE" | "UPDATE" | "DELETE",
"target_tier": "tier_1_staples" | "tier_2_physiological" | "tier_3_situational",
"memory_id": "string (required for UPDATE/DELETE, optional for CREATE)",
"entry": object (required for CREATE/UPDATE),
"reason": "string (rationale)"
}
]
}
*Data Field Assurances*:
- When `proposal.type` is `UPDATE_DAY` or `UPDATE_WEEK`, every exercise in `blocks[].exercises` MUST contain both `"exercise_id"` (canonical slug) AND `"name"` (human-readable title, e.g. `"Incline DB Bench Press"`), plus `"target_sets"`, `"target_reps"`, and `"rest_seconds"`.
- Every day object generated in `days` MUST include `"status": "scheduled"`, `"completed_log_id": null`, and `"completed_at": null`.বিভাগ ২: ইউনিফায়েড চ্যাট প্রম্পট ক্যাটালগ (POST /api/coach/chat)
অ্যাপ্লিকেশনটি একটি ইউনিফায়েড এন্ডপয়েন্ট (POST /api/coach/chat) ব্যবহার করে, তাই সার্ভার Gemini-তে অনুরোধ পাঠানোর আগে রানটাইম প্রাসঙ্গিক ব্লক সহ ব্যবহারকারীর মেসেজ ডাইনামিকভাবে র্যাপ করে।
ডায়নামিক রানটাইম কনটেক্সট প্যাকেজিং স্ট্রাকচার
[SYSTEM INSTRUCTIONS] (Retrieved from Gemini Context Cache)
[RUNTIME CONTEXT BLOCK]
CURRENT TIMESTAMP: 2026-09-14T10:00:00Z
CURRENT DATE: Monday, 2026-09-14
ACTIVE TAB: coach | today | week
SELECTED DAY IN ROUTE: monday (or null)
ACTIVE USER MEMORY PROFILE (Unexpired Only):
- Tier 1 Staples:
• [id: mem_01] [equipment] Home gym with dumbbells up to 50 lbs and adjustable bench.
• [id: mem_02] [goal] Hypertrophy with chest/shoulder emphasis.
- Tier 2 Physiological:
• [id: mem_03] Hamstring soreness (effective: 2026-09-13, expires: 2026-09-16T00:00:00Z)
- Tier 3 Situational:
• (None active)
ACTIVE WEEKLY TRAINING PLAN:
{ ... full active weekly_plans document ... }
[USER MESSAGE / CHIP INPUT]
"User's input string"এখানে প্রতিটি মূল অনুরোধের ধরনের জন্য ৮টি কংক্রিট প্রম্পট টেমপ্লেট এবং সিস্টেমের আচরণ দেওয়া হল:
উদ্দেশ্য ১: কোনও বাধা ছাড়াই কথোপকথনের মাধ্যমে অনবোর্ডিং ও স্বাগত জানানো
- ট্রিগার: নতুন ব্যবহারকারী রেজিস্ট্রেশন সম্পূর্ণ করে প্রথমবার কোচ ট্যাবে প্রবেশ করেন।
- ক্লায়েন্ট রুট:
/coach(প্রথম সেশন) - অ্যাপের মাধ্যমে রেন্ডার করা প্রাথমিক স্বাগত প্রম্পট: "স্বাগতম! আমি আপনার AI ব্যক্তিগত প্রশিক্ষক। তোমার সম্পর্কে বলো—তোমার লক্ষ্য, অভিজ্ঞতা, তোমার কাছে কী কী সরঞ্জাম আছে, তুমি কত দিন ট্রেনিং করতে পারবে এবং তোমার কোনও চোট বা পুরনো ব্যথা আছে কিনা যা আমার জানা উচিত। সব তথ্য এখানে দিন এবং আমি আপনার কাস্টম ট্রেনিং প্ল্যান তৈরি করে দেব।"
- ব্যবহারকারীর ইনপুটের উদাহরণ: "হ্যালো! আমার বয়স ৩২, বাড়িতে ট্রেনিং করি। আমার কাছে ৫০ পাউন্ড পর্যন্ত অ্যাডজাস্টেবল ডাম্বেল এবং একটি অ্যাডজাস্টেবল বেঞ্চ আছে। আমি পেশী তৈরি করতে চাই—বিশেষ করে বুক এবং ডেল্ট—কিন্তু আমি ভারী ডেডলিফ্ট করলে আমার পিঠের নিচের অংশে ব্যথা হয়। আমি সপ্তাহে ৪ দিন ৪৫ মিনিট করে ট্রেনিং করতে পারব।"
- এজেন্টের ইন্টার্নাল রিজনিং:
- মেমরি ইনজেশন: এক্সট্র্যাক্ট ইকুইপমেন্ট (৫০ পাউন্ড পর্যন্ত ডাম্বেল, অ্যাডজাস্টেবল বেঞ্চ), লক্ষ্য (হাইপারট্রফি, বুক/ডেল্ট ফোকাস), ক্রনিক ভালনারেবিলিটি (লোয়ার ব্যাক সেনসিটিভিটি), শিডিউল সংক্রান্ত পছন্দ (৪ দিন/সপ্তাহ, ৪৫ মিনিট)।
- স্প্লিট বেছে নেওয়া: ৪৫ মিনিটের ৪ দিনের জন্য আপার/লোয়ার বা পুশ/পুল স্প্লিট সবচেয়ে ভাল। শুধু ডাম্বেল ব্যবহার করে করা যায় এমন ব্যায়াম। মেরুদণ্ডে চাপ পড়ে এমন ব্যায়াম এড়িয়ে চলুন (বারবেল রো-এর পরিবর্তে ডিবি চেস্ট-সাপোর্টেড রো করুন)।
- রাউটিং সংক্রান্ত সিদ্ধান্ত:
proposal.type = "UPDATE_WEEK"।
প্রত্যাশিত এজেন্ট রেসপন্স পেলোড:
{
"message": "Welcome aboard! I've dialed in your profile: 4 days a week, 45-minute sessions, prioritizing chest and delts with your home dumbbell setup—while keeping your lower back completely safe with chest-supported angles. I've built your custom Week 1 schedule here. Tap **Accept Plan** to lock it into your training calendar.",
"proposal": {
"id": "prop_onboard_w1",
"type": "UPDATE_WEEK",
"target_day": null,
"summary_diff": "Generated Inaugural 4-Day Home DB Split (Mon/Tue/Thu/Fri) • Upper/Lower Focus",
"data": {
"week_start_date": "2026-09-14",
"theme": "Hypertrophy Foundation • Chest & Delts Priority",
"summary": {
"total_time_minutes": 180,
"total_volume_lbs": 38400,
"frequency": 4
},
"suggested_edits": [
"Shift Friday workout to Saturday",
"Add an extra arm finisher on Thursday"
],
"days": {
"monday": {
"date": "2026-09-14",
"day_of_week": "Monday",
"is_rest_day": false,
"status": "scheduled",
"completed_log_id": null,
"completed_at": null,
"title": "Upper Body Push & Delt Focus",
"focus_tag": "Chest & Shoulders",
"duration_minutes": 45,
"estimated_volume_lbs": 10500,
"coach_note": "Keep your shoulder blades retracted on incline presses. Control the 3-second eccentric.",
"muscle_focus": [
{ "muscle": "Chest", "intensity": 85 },
{ "muscle": "Shoulders", "intensity": 90 },
{ "muscle": "Triceps", "intensity": 65 }
],
"suggested_edits": [
"Swap flat flyes for push-ups",
"Reduce to 35 minutes"
],
"blocks": [
{
"label": "Primary Compound Block",
"exercises": [
{
"exercise_id": "incline-db-bench-press",
"name": "Incline DB Bench Press",
"target_sets": 4,
"target_reps": "8-10",
"rest_seconds": 90
}
]
},
{
"label": "Accessory Superset",
"exercises": [
{
"exercise_id": "db-lateral-raise",
"name": "DB Lateral Raise",
"target_sets": 3,
"target_reps": "12-15",
"rest_seconds": 30
},
{
"exercise_id": "overhead-db-tricep-extension",
"name": "Overhead DB Tricep Extension",
"target_sets": 3,
"target_reps": "10-12",
"rest_seconds": 60
}
]
}
]
}
}
}
},
"memory_mutations": [
{
"operation": "CREATE",
"target_tier": "tier_1_staples",
"entry": {
"category": "equipment",
"fact": "Home gym with dumbbells up to 50 lbs and adjustable bench.",
"source": "conversational_onboarding"
},
"reason": "Captured initial user gear availability."
},
{
"operation": "CREATE",
"target_tier": "tier_1_staples",
"entry": {
"category": "goal",
"fact": "Hypertrophy focus with priority on chest and delts; 4 days/week, 45 min.",
"source": "conversational_onboarding"
},
"reason": "Captured baseline training goals and schedule constraint."
},
{
"operation": "CREATE",
"target_tier": "tier_1_staples",
"entry": {
"category": "chronic_condition",
"fact": "Lower back sensitivity on heavy deadlifts/unsupported spinal loading.",
"source": "conversational_onboarding"
},
"reason": "Captured chronic injury boundary to guide exercise selection."
}
]
}ইনটেন্ট ২: রুট প্রসঙ্গ সহ বা ছাড়া দিন-লেভেল পরিবর্তন (UPDATE_DAY)
- ট্রিগার: ব্যবহারকারী একদিনের ওয়ার্কআউটে পরিবর্তন করার অনুরোধ করেন (
/today,/workouts/mondayবা/coach-এ ফ্রিফর্ম থেকে)। - ব্যবহারকারীর ইনপুটের উদাহরণ: "সোমবারের ওয়ার্কআউটের জন্য ৪৫ মিনিটের পরিবর্তে আমার কাছে মাত্র ৩০ মিনিট সময় আছে। বুকের দিকে ফোকাস থাকবে, তবে অপ্রয়োজনীয় অংশ বাদ দিয়ে দিন।"
- রাউটিং সংক্রান্ত সিদ্ধান্ত:
proposal.type = "UPDATE_DAY",target_day = "monday"।
প্রত্যাশিত এজেন্ট রেসপন্স পেলোড:
{
"message": "Done. Trimmed Monday to a high-intensity 30-minute session. We kept the Incline DB Bench as the anchor and condensed your delts and triceps into an antagonistic superset so you're in and out without losing quality volume.",
"proposal": {
"id": "prop_mod_mon_30m",
"type": "UPDATE_DAY",
"target_day": "monday",
"summary_diff": "Compressed Monday from 45m ➔ 30m • Consolidated accessory superset",
"data": {
"date": "2026-09-14",
"day_of_week": "Monday",
"is_rest_day": false,
"title": "Upper Body Push (Express 30m)",
"focus_tag": "Chest & Shoulders",
"duration_minutes": 30,
"estimated_volume_lbs": 7200,
"coach_note": "Keep rest to 60s on the incline press. Attack the superset with intensity.",
"muscle_focus": [
{ "muscle": "Chest", "intensity": 90 },
{ "muscle": "Shoulders", "intensity": 85 }
],
"suggested_edits": ["Restore to 45m version"],
"blocks": [
{
"label": "Primary Compound Anchor",
"exercises": [
{
"exercise_id": "incline-db-bench-press",
"target_sets": 3,
"target_reps": "8-10",
"rest_seconds": 60
}
]
},
{
"label": "Express Superset Block",
"exercises": [
{
"exercise_id": "db-lateral-raise",
"target_sets": 3,
"target_reps": "12",
"rest_seconds": 15
},
{
"exercise_id": "overhead-db-tricep-extension",
"target_sets": 3,
"target_reps": "12",
"rest_seconds": 45
}
]
}
]
}
},
"memory_mutations": []
}উদ্দেশ্য ৩: সপ্তাহ-লেভেল শিডিউল ওভারহল (UPDATE_WEEK)
- ট্রিগার:
/weekথেকে<ModifyWeekWithCoachCard />ট্যাপ করা হয়েছে অথবা/coach-এ ফ্রিফর্ম টাইপ করা হয়েছে। - ব্যবহারকারীর ইনপুটের উদাহরণ: "আমি কিছু পরিবর্তন করতে চাই। আমার ট্রেনিংয়ের দিনগুলি সোমবার, বুধবার, শুক্রবার ও শনিবার হিসেবে সেট করো এবং শনিবারের দিনটি শুধু হাত ও কাঁধের ব্যায়ামের জন্য নির্দিষ্ট করো।"
- রাউটিং সংক্রান্ত সিদ্ধান্ত:
proposal.type = "UPDATE_WEEK"।
ইনটেন্ট ৪: জিমে দ্রুত এক্সারসাইজ সাবস্টিটিউশন (লাইভ জিম ফ্লোর)
- ট্রিগার: ব্যবহারকারী
/workout/activeবা/today-এ আছেন, অবিলম্বে বিকল্প প্রয়োজন (সরঞ্জাম নেওয়া হয়েছে বা জয়েন্টে ঘর্ষণ)। - ব্যবহারকারীর ইনপুটের উদাহরণ: "বেঞ্চে কেউ বসে আছে। ইনক্লাইন ডিবি বেঞ্চ প্রেসের পরিবর্তে আমি এখন কী করতে পারি?"
- রাউটিং সংক্রান্ত সিদ্ধান্ত:
proposal.type = "UPDATE_DAY",target_day = "monday", অতি-সংক্ষিপ্ত উত্তর (<২ বাক্য)।
ইনটেন্ট ৫: তীব্র ব্যথা, ক্লান্তি ও আঘাত ম্যানেজমেন্ট (সেটিং টিয়ার ২ TTL)
- ট্রিগার: ব্যবহারকারী তীব্র ব্যথা, পেশীর ক্লান্তি বা জয়েন্ট টুইকের কথা জানান।
- ব্যবহারকারীর ইনপুটের উদাহরণ: "আমার ডান কাঁধে আজ খুব ব্যথা ও অস্বস্তি হচ্ছে। আমার মনে হয় না যে আমার ওভারহেড প্রেস বা ভারী ইনক্লাইন করা উচিত।"
- রাউটিং সংক্রান্ত সিদ্ধান্ত:
tier_2_physiological-এproposal.type = "UPDATE_DAY"+CREATE, ৫-দিনের TTL (expires_at: now + 5 days) সহ।
উদ্দেশ্য ৬: পরিস্থিতি অনুযায়ী জীবনের সাথে মানিয়ে নেওয়া (টিয়ার ৩ ইভেন্টের মেয়াদ শেষ হওয়ার সময় সেট করা)
- ট্রিগার: ব্যবহারকারী ভ্রমণ, আসন্ন প্রতিযোগিতা বা অস্বাভাবিক কাজের শিডিউল উল্লেখ করেন।
- ব্যবহারকারীর ইনপুটের উদাহরণ: "এই শনিবার আমার ৩৬-হোল গল্ফ টুর্নামেন্ট আছে। সপ্তাহান্তের আগে আমার পিঠ, বাহু ও কাঁধ যেন খুব বেশি ক্লান্ত না হয়ে পড়ে, সেই দিকে নজর রেখো।"
- রাউটিং সংক্রান্ত সিদ্ধান্ত:
proposal.type = "UPDATE_WEEK"+CREATE,tier_3_situational-এ, ইভেন্ট-পরবর্তী মেয়াদ শেষ হচ্ছে।
উদ্দেশ্য ৭: প্রোগ্রেসিভ ওভারলোড ও পুরনো অ্যানালিটিক্স পর্যালোচনা (অ্যানালিটিক্যাল টুল পাথ)
- ট্রিগার: ব্যবহারকারী ওজন বৃদ্ধি, ভলিউম ট্রেন্ড বা প্ল্যাটোর ডায়াগনসিস সম্পর্কে পরামর্শ চান।
- ব্যবহারকারীর ইনপুটের উদাহরণ: "ইনক্লাইন ডিবি বেঞ্চ প্রেসে কি আমার ওজন বাড়ানো উচিত? গত ৩ সপ্তাহে আমার ভলিউম কেমন ছিল?"
- টুল ইনভোকেশন:
get_historical_exercise_logs(exercise_slug: "incline-db-bench-press", limit: 3)কল করে, প্রোগ্রেসিভ ওভারলোড সংক্রান্ত পরামর্শ সিন্থেসাইজ করে এবংproposal.type = "NONE"এমিট করে।
Intent 8: Exercise Form, Technique & Biomechanics Q&A
- ট্রিগার: ব্যবহারকারী বায়োমেকানিক্যাল নির্দেশিকা, ফর্ম সংক্রান্ত পরামর্শ বা মাইন্ড-মাসল কানেকশন সংক্রান্ত পরামর্শ চাইলে।
- ব্যবহারকারীর ইনপুটের উদাহরণ: "ডাম্বেল রো করার সময় আমার ল্যাটস পেশীতে কোনও অনুভূতি হয় না। আমি বেশিরভাগ ক্ষেত্রে আমার বাইসেপ এবং বাহুতে এটি অনুভব করি। আমার কী পরিবর্তন করা উচিত?"
- রাউটিং সংক্রান্ত সিদ্ধান্ত: সম্পূর্ণ শিক্ষামূলক উত্তর (
proposal.type = "NONE")।
বিভাগ ৩: এজেন্ট টুল ও ক্ষমতার স্পেসিফিকেশন
AI ট্রেনার এজেন্ট দুটি এক্সিকিউশন মোড ব্যবহার করে: স্ট্যান্ডার্ড চ্যাট এবং ওয়ার্কআউট পরিবর্তনের জন্য ডাইরেক্ট ফাস্ট পাথ এবং ঐতিহাসিক তদন্তের জন্য অ্যানালিটিক্যাল কোয়েরি টুল।
3.1 Architectural Execution Pipeline
User Message at POST /api/coach/chat
└──> Server Context Assembly
└──> Attach Cached Master System Prompt
└──> Gemini Inference with Structured Schema
├── [Yes (10-15%)] Does Agent Require Historical Ground Truth?
│ └──> Invoke Analytical Tool ──> Query /workout_logs in Firestore ──> Synthesize Final Response
└── [No (85-90%)] Direct Structured Emission
└──> Emit Structured JSON Contract
├──> Atomically Apply memory_mutations to /user_profiles
└──> Return message & staged proposal to Client৩.২ ডেটাবেস সংক্রান্ত ক্ষমতা ও নিরাপত্তা সংক্রান্ত সীমা
| রিসোর্স / কালেকশন | এজেন্টের ক্ষমতা | এক্সিকিউশন মেকানিজম | হিউম্যান-ইন-দ্য-লুপ গেটিং |
|---|---|---|---|
সাপ্তাহিক প্ল্যান (/weekly_plans) |
শুধুমাত্র প্রস্তাব করুন (সরাসরি লিখবেন না) | POST /api/coach/chat-এ proposal.data হিসেবে নির্গত হয়েছে |
কঠোরভাবে গেট করা: Firestore-এ লেখার জন্য ব্যবহারকারীকে UI-তে [Accept Plan] ট্যাপ করতে হবে। |
দৈনিক ওয়ার্কআউট (days.{day}) |
শুধুমাত্র প্রস্তাব করুন (সরাসরি লিখবেন না) | proposal.data হিসেবে target_day-এর সাথে নির্গত হয়েছে |
কঠোরভাবে গেট করা: Firestore-এ লেখার জন্য ব্যবহারকারীকে UI-তে [Accept Plan] ট্যাপ করতে হবে। |
লিভিং মেমরি (/user_profiles) |
অটোনোমাস রিড / রাইট | memory_mutations (CREATE, UPDATE, DELETE) হিসেবে নির্গত হয়েছে |
AUTONOMOUS: চ্যাট অনুরোধের লাইফসাইকেল চলাকালীন সার্ভার অবিলম্বে মিউটেশন প্রয়োগ করে। |
ওয়ার্কআউট লগ (/workout_logs) |
শুধু পড়া যাবে | অ্যানালিটিক্যাল টুল (get_historical_exercise_logs) ব্যবহার করে কোয়েরি করা হয়েছে |
POST /api/workouts/log ব্যবহার করে ক্লায়েন্ট সম্পূর্ণ হওয়া সেশন লগ করে। এজেন্ট লগ পরিবর্তন করতে পারবে না। |
ব্যায়াম এনসাইক্লোপিডিয়া (/exercises) |
শুধু-পড়া-যাবে (ক্যাশে করা) | ক্যাশে করা প্রসঙ্গে প্রি-কম্পাইল করা কম্প্যাক্ট ইন্ডেক্স | স্ট্যাটিক অ্যাডমিনিস্ট্রেটর লাইব্রেরি। এজেন্ট এক্সারসাইজের সংজ্ঞা পরিবর্তন করতে পারবে না। |
৩.৩ অ্যানালিটিক্যাল কোয়েরি টুলের সংজ্ঞা
টুল ১: get_historical_exercise_logs
- উদ্দেশ্য: আগের ওয়ার্ক-আউট সেশন থেকে নির্দিষ্ট এক্সারসাইজের জন্য সম্পূর্ণ করা সেট, ওজন, রিপিটেশন ও RPE সংক্রান্ত তথ্য নিয়ে আসে।
- সার্ভার এক্সিকিউশন লজিক: কোয়েরি
/users/{userId}/workout_logscompleted_at DESCদ্বারা সাজানো হয়েছে, লগ ফিল্টার করা হচ্ছে যেখানেexercises_logged-এexercise_id == exercise_slugআছে।
{
"name": "get_historical_exercise_logs",
"description": "Retrieves the user's past logged performance data (sets, weight lifted, reps completed, perceived exertion) for a specific exercise slug.",
"parameters": {
"type": "OBJECT",
"properties": {
"exercise_slug": {
"type": "STRING",
"description": "The exact slug matching the exercise encyclopedia (e.g. 'incline-db-bench-press')."
},
"limit_sessions": {
"type": "INTEGER",
"description": "Number of recent workout sessions to fetch (default: 3, max: 10)."
}
},
"required": ["exercise_slug"]
}
}টুল ২: get_volume_trends
- উদ্দেশ্য: সাম্প্রতিক সপ্তাহগুলিতে নির্দিষ্ট পেশী গ্রুপের জন্য মোট টনেজ এবং সাপ্তাহিক ডাইরেক্ট সেট গণনা করে।
- সার্ভার এক্সিকিউশন লজিক: কোয়েরি
/users/{userId}/workout_logsযেখানেcompleted_at >= now - (weeks_back * 7 days)এবং সাপ্তাহিক টনেজ (∑ ওজন × রেপ) এবং হার্ড সেট ট্যালি গণনা করে।
{
"name": "get_volume_trends",
"description": "Calculates total volume (lbs) and hard set counts for a specified muscle group over past training weeks.",
"parameters": {
"type": "OBJECT",
"properties": {
"muscle_group": {
"type": "STRING",
"description": "Target muscle group (e.g. 'Chest', 'Back', 'Quads', 'Shoulders')."
},
"weeks_back": {
"type": "INTEGER",
"description": "Number of past weeks to aggregate (default: 4, max: 12)."
}
},
"required": ["muscle_group"]
}
}টুল ৩: get_pr_records
- উদ্দেশ্য: কোনও এক্সারসাইজের জন্য ব্যবহারকারীর সর্বকালীন ব্যক্তিগত রেকর্ড (যেমন, ১RM, ৫RM, ১০RM) ফেচ করে।
- সার্ভার এক্সিকিউশন লজিক:
/users/{userId}/prs/{exercise_slug}-এ ডকুমেন্ট পড়ে এবং সর্বকালীন বেঞ্চমার্ক ডেটা (estimated_1rm,max_weight_setএবংrep_records) ফেরত পাঠায়।
{
"name": "get_pr_records",
"description": "Retrieves all-time Personal Records and benchmark lifts for a specific exercise.",
"parameters": {
"type": "OBJECT",
"properties": {
"exercise_slug": {
"type": "STRING",
"description": "The exact exercise slug."
}
},
"required": ["exercise_slug"]
}
}৩.৪ স্ট্রাকচার্ড আউটপুট স্কিমা স্পেসিফিকেশন
ক্লায়েন্টের <StagedProposalCard />-এ নির্ধারক JSON রেন্ডারিং এবং memory_mutations-এর অবিলম্বে ডেটাবেস এক্সিকিউশন নিশ্চিত করতে, নিম্নলিখিত OpenAPI-কমপ্লায়েন্ট JSON স্কিমা response_schema ব্যবহার করে Gemini-কে প্রদান করা হয়:
{
"type": "OBJECT",
"properties": {
"message": {
"type": "STRING",
"description": "The conversational coaching message displayed in the chat bubble. Uses clean markdown."
},
"proposal": {
"type": "OBJECT",
"properties": {
"id": { "type": "STRING", "nullable": true },
"type": {
"type": "STRING",
"enum": ["NONE", "UPDATE_DAY", "UPDATE_WEEK"]
},
"target_day": {
"type": "STRING",
"enum": ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"],
"nullable": true
},
"summary_diff": {
"type": "STRING",
"description": "Concise, human-scannable summary of changes (e.g. 'Swapped Arnold Press ➔ DB Shoulder Press')",
"nullable": true
},
"data": {
"type": "OBJECT",
"description": "Full workout day object (for UPDATE_DAY) or full weekly plan object (for UPDATE_WEEK). Every exercise in blocks.exercises MUST have exercise_id and denormalized name, and every day object MUST have status: 'scheduled'.",
"nullable": true
}
},
"required": ["type", "id", "target_day", "summary_diff", "data"]
},
"memory_mutations": {
"type": "ARRAY",
"items": {
"type": "OBJECT",
"properties": {
"operation": {
"type": "STRING",
"enum": ["CREATE", "UPDATE", "DELETE"]
},
"target_tier": {
"type": "STRING",
"enum": ["tier_1_staples", "tier_2_physiological", "tier_3_situational"]
},
"memory_id": {
"type": "STRING",
"description": "Identifier of the memory item (mandatory for UPDATE and DELETE)",
"nullable": true
},
"entry": {
"type": "OBJECT",
"description": "Memory fact payload conforming to the target tier schema in data_architecture_spec.md",
"nullable": true
},
"reason": {
"type": "STRING",
"description": "Brief rationale for why this memory was created, modified, or deleted"
}
},
"required": ["operation", "target_tier", "reason"]
}
}
},
"required": ["message", "proposal", "memory_mutations"]
}৪. যাচাইকরণ ও ভ্যালিডেশন চেকলিস্ট
- কনটেক্সট ক্যাশে যাচাইকরণ: সিস্টেম নির্দেশাবলী এবং কমপ্যাক্ট এক্সারসাইজ ইনডেক্স, বারবার ইন্টার্যাকশন জুড়ে >৯০% ক্যাশে-হিট রেট সহ Gemini কনটেক্সট ক্যাশে হিট করে।
- জিরো হ্যালুসিনেটেড স্লাগ:
proposal.data-এ প্রতিটি এক্সারসাইজ স্লাগ ক্যাশে করা কম্প্যাক্ট ইন্ডেক্স এবং/exercisesFirestore সংগ্রহে হুবহু বিদ্যমান। - সরঞ্জামের কঠোর আনুগত্য: ব্যবহারকারীর
tier_1_staplesসরঞ্জামের ইনভেনটরিতে নেই এমন সরঞ্জামের প্রয়োজন হয় এমন কোনও ব্যায়াম কখনও তৈরি করা হয় না। - স্টেজেড আইসোলেশন: ক্লায়েন্ট স্পষ্টভাবে কোনও অ্যাকসেপ্ট ইভেন্ট জমা না দেওয়া পর্যন্ত, পরিবর্তনের অনুরোধ (
UPDATE_DAYবাUPDATE_WEEK) জমা দিলে তা কখনই/weekly_plans-কে মিউটেট করে না। - TTL Expiration Pruning:
now > expires_at-এর পরে তীব্র ব্যথার নোট (tier_2_physiological) অটোমেটিক কনটেক্সটে ইনজেক্ট করা বন্ধ হয়ে যায়। - জিম-ফ্লোর ব্রিভিটি: স্ট্যান্ডার্ড ফাস্ট-পাথ রেসপন্স গড়ে ≤ ৩টি বাক্য হয়, যদি না স্পষ্টভাবে ব্যাখ্যা চাওয়া হয়।