एआई एजेंट की एंड-टू-एंड सुविधा - वर्कशॉप

1. आपको क्या सीखने को मिलेगा

AI Agent Vibe Full Stack

आपका स्वागत है! अब आपको सॉफ़्टवेयर डेवलपमेंट की अगली ज़रूरी स्किल के बारे में जानकारी मिलेगी. यह स्किल है: प्रोडक्शन-ग्रेड सॉफ़्टवेयर बनाने, उसकी जांच करने, और उसे डिप्लॉय करने के लिए, आर्टिफ़िशियल इंटेलिजेंस को असरदार तरीके से गाइड करना. जनरेटिव एआई, "ऑटोपायलट" नहीं है. यह एक बेहतरीन को-पायलट है, जिसे एक कुशल डायरेक्टर की ज़रूरत होती है.

इस वर्कशॉप में, प्रोफ़ेशनल सॉफ़्टवेयर डेवलपमेंट लाइफ़साइकल (एसडीएलसी) के हर चरण में एआई के साथ मिलकर काम करने के लिए, एक स्ट्रक्चर्ड और दोहराई जा सकने वाली कार्यप्रणाली बताई गई है. आप लाइन-दर-लाइन कोड लिखने वाले व्यक्ति से, एक टेक्निकल डायरेक्टर बन जाएंगे. यानी, एक ऐसा आर्किटेक्ट जिसके पास विज़न है और एक ऐसा जनरल कॉन्ट्रैक्टर जो उस विज़न को सटीक तरीके से लागू करने के लिए, एआई का इस्तेमाल करता है. 🚀

डेमो

इस ट्यूटोरियल को पूरा करने के बाद, आपके पास ये चीज़ें होंगी:

  • एआई का इस्तेमाल करके, किसी आइडिया को क्लाउड आर्किटेक्चर में बदला.
  • टारगेट किए गए खास प्रॉम्प्ट की मदद से, पूरा Python बैकएंड जनरेट किया गया.
  • कोड को डीबग करने और उसे ठीक करने के लिए, एआई का इस्तेमाल पेयर प्रोग्रामर के तौर पर किया गया.
  • एआई को यूनिट टेस्ट बनाने का काम सौंपा गया है. इसमें मॉक टेस्ट भी शामिल हैं.

Terraform की मदद से, प्रोडक्शन के लिए तैयार इन्फ़्रास्ट्रक्चर एज़ कोड (IaC) जनरेट किया गया.

एक प्रॉम्प्ट की मदद से, GitHub Actions में पूरी CI/CD पाइपलाइन बनाई गई.

एआई की मदद से काम करने वाले टूल का इस्तेमाल करके, लाइव ऐप्लिकेशन को मॉनिटर और मैनेज किया.

आपको न सिर्फ़ काम करने वाला ऐप्लिकेशन मिलेगा, बल्कि एआई की मदद से डेवलपमेंट करने के लिए एक ब्लूप्रिंट भी मिलेगा. आइए, शुरू करें!

2. ज़रूरी शर्तें और सेटअप

शुरू करने से पहले, अपने एनवायरमेंट को तैयार करें. वर्कशॉप में शामिल होने के लिए, यह एक ज़रूरी चरण है.

हमारे एआई एजेंट को काम करने के लिए, हमें दो चीज़ों की ज़रूरत होती है: एक Google Cloud प्रोजेक्ट, जो बुनियादी ढांचा उपलब्ध कराता है. दूसरा, Gemini API पासकोड, जो Google के बेहतरीन मॉडल को ऐक्सेस करने के लिए ज़रूरी है.

पहला चरण: बिलिंग खाता चालू करना

  • पांच डॉलर के क्रेडिट वाले बिलिंग खाते पर दावा करें. आपको इसकी ज़रूरत डिप्लॉयमेंट के लिए पड़ेगी. पक्का करें कि आपने अपने gmail खाते से साइन इन किया हो.

दूसरा चरण: नया GCP प्रोजेक्ट बनाना

  • Google Cloud Console पर जाएं और एक नया प्रोजेक्ट बनाएं.

नया GCP खाता बनाना

  • Google Cloud Console पर जाएं और एक नया प्रोजेक्ट बनाएं.
  • बाईं ओर मौजूद पैनल खोलें और Billing पर क्लिक करें. देखें कि बिलिंग खाता, इस GCP खाते से लिंक है या नहीं.

बिलिंग खाते को GCP खाते से लिंक करना

अगर आपको यह पेज दिखता है, तो manage billing account पर जाकर, Google Cloud की बिना शुल्क वाली सदस्यता चुनें और उसे लिंक करें.

तीसरा चरण: Gemini API पासकोड जनरेट करना

कुंजी को सुरक्षित करने से पहले, आपके पास एक कुंजी होनी चाहिए.

  • Google AI Studio पर जाएं : https://aistudio.google.com/
  • अपने Gmail खाते से साइन इन करें.
  • "एपीआई कुंजी पाएं" बटन पर क्लिक करें. यह बटन आम तौर पर, बाईं ओर मौजूद नेविगेशन पैनल या सबसे ऊपर दाएं कोने में होता है.
  • "एपीआई पासकोड" डायलॉग में, "नए प्रोजेक्ट में एपीआई पासकोड बनाएं" पर क्लिक करें. नए प्रोजेक्ट में एपीआई पासकोड बनाना
  • आपने जो नया प्रोजेक्ट बनाया है उसे चुनें. इसमें बिलिंग खाता सेट अप किया गया हो. नया प्रोजेक्ट चुनें
  • आपके लिए एक नई एपीआई कुंजी जनरेट की जाएगी. इस कुंजी को तुरंत कॉपी करें और इसे कुछ समय के लिए किसी सुरक्षित जगह पर सेव करें. जैसे, पासवर्ड मैनेजर या सुरक्षित नोट. इस वैल्यू का इस्तेमाल अगले चरणों में किया जाएगा.

GitHub की पुष्टि करने की सुविधा

Google Cloud Console में सबसे ऊपर दाईं ओर मौजूद "Cloud Shell चालू करें" बटन पर जाकर, Cloud Shell खोलें.

पहला चरण: Cloud Shell खोलें

👉Google Cloud Console में सबसे ऊपर, Cloud Shell चालू करें पर क्लिक करें (यह Cloud Shell पैनल में सबसे ऊपर टर्मिनल के आकार वाला आइकॉन है), cloud-shell.png

👉 "एडिटर खोलें" बटन पर क्लिक करें. यह बटन, पेंसिल वाले खुले फ़ोल्डर की तरह दिखता है. इससे विंडो में Cloud Shell Code Editor खुल जाएगा. आपको बाईं ओर फ़ाइल एक्सप्लोरर दिखेगा. open-editor.png

👉अपना Google Cloud प्रोजेक्ट आईडी ढूंढें:

  • Google Cloud Console खोलें: https://console.cloud.google.com
  • पेज पर सबसे ऊपर मौजूद प्रोजेक्ट ड्रॉपडाउन से, वह प्रोजेक्ट चुनें जिसका इस्तेमाल आपको इस वर्कशॉप के लिए करना है.
  • आपका प्रोजेक्ट आईडी, डैशबोर्ड पर मौजूद प्रोजेक्ट की जानकारी देने वाले कार्ड में दिखता है

03-04-project-id.png

👉क्लाउड आईडीई में टर्मिनल खोलें,

03-05-new-terminal.png

👉💻 टर्मिनल में, पुष्टि करें कि आपने पहले ही पुष्टि कर ली है और प्रोजेक्ट को अपने प्रोजेक्ट आईडी पर सेट किया गया है. इसके लिए, यह कमांड इस्तेमाल करें:

gcloud auth list

दूसरा चरण: GitHub से पुष्टि करना और फ़ोर्क करना

GitHub से पुष्टि करें:

👉💻

gh auth login

git1.png

लॉगिन करने की पुष्टि करने वाले पेज पर कोड कॉपी करें

git2.png

Repo को फ़ोर्क और क्लोन करें: 👉💻

gh repo fork cuppibla/storygen-learning --clone=true

3. आर्किटेक्चर: Cloud Assist की मदद से आइडिया से लेकर ब्लूप्रिंट तक

हर बेहतरीन प्रोजेक्ट की शुरुआत, एक साफ़ विज़न से होती है. हम अपने एआई को-पायलट, Cloud Assist का इस्तेमाल करके अपने ऐप्लिकेशन का आर्किटेक्चर डिज़ाइन करेंगे.

वास्तुकला

कार्रवाइयां

  • Google Cloud Console खोलें: https://console.cloud.google.com
  • सबसे ऊपर दाएं कोने में, "Cloud Assist Chat खोलें" पर क्लिक करें

cloud_assist_1

Cloud Assist चालू करना

  • Get Gemini Assist पर क्लिक करें. इसके बाद, Enable Cloud Assist at no cost पर क्लिक करें.
  • इसके बाद, चैट करना शुरू करें!

cloud_assist_3 Cloud Assist को यह प्रॉम्प्ट दें:

अपना आइडिया सबमिट करें

Generate a Python web application that uses AI to generate children's stories and illustrations. It has Python backend and React frontend host separately on Cloudrun. They communicate through Websocket. It needs to use a generative model for text and another for images. The generated images must be used by Imagen from Vertex AI and stored in a Google Cloud Storage bucket so that frontend can fetch from the bucket to render images. I do not want any load balancer or a database for the story text. We need a solution to store the API key.

अपने ऐप्लिकेशन का ब्लूप्रिंट पाना

  • "ऐप्लिकेशन के डिज़ाइन में बदलाव करें" पर क्लिक करें. आपको डायग्राम दिखेगा. Terraform कोड डाउनलोड करने के लिए, सबसे ऊपर दाईं ओर मौजूद पैनल में "<> Get Code" पर क्लिक करें.
  • Cloud Assist, आर्किटेक्चर का एक डायग्राम जनरेट करेगा. यह हमारा विज़ुअल ब्लूप्रिंट है. cloud_assist_4

सीखने के लिए अहम जानकारी: एआई, सिस्टम डिज़ाइन करने में काफ़ी बेहतर है. यह सामान्य भाषा में बताई गई ज़रूरी शर्तों को तुरंत प्रोफ़ेशनल और विज़ुअल आर्किटेक्चर में बदल सकता है.

4. डेवलपमेंट: Gemini CLI की मदद से ADK बनाना

SDLC

शुरुआती सेटअप

पक्का करें कि हम Gemini CLI का इस्तेमाल करके, रिपॉज़िटरी को फ़ोर्क करें और वर्कस्पेस तैयार करें:

परिवेश का कॉन्फ़िगरेशन

Cloud Shell पर जाएं और "टर्मिनल खोलें" बटन पर क्लिक करें.

  1. एनवायरमेंट टेंप्लेट कॉपी करें:
    cd ~/storygen-learning
    cp ~/storygen-learning/env.template ~/storygen-learning/.env
    

अगर आपको .env फ़ाइल नहीं मिलती है, तो एडिटर में छिपी हुई फ़ाइल देखें

  • सबसे ऊपर मौजूद मेन्यू बार में, देखें पर क्लिक करें.
  • छिपी हुई फ़ाइलें टॉगल करें को चुनें.

.env फ़ाइल में बदलाव करना 2. .env में मौजूद इन वैल्यू को बदलें:

GOOGLE_API_KEY=[REPLACE YOUR API KEY HERE]
GOOGLE_CLOUD_PROJECT_ID=[REPLACE YOUR PROJECT ID]
GITHUB_USERNAME=[REPLACE YOUR USERNAME]
GENMEDIA_BUCKET=[REPLACE YOUR PROJECT ID]-bucket

उदाहरण के लिए, अगर आपका प्रोजेक्ट आईडी testproject है, तो आपको GOOGLE_CLOUD_PROJECT_ID=testproject और GENMEDIA_BUCKET=testproject-bucket डालना चाहिए

सेटअप स्क्रिप्ट

00_Starting_Here पर जाएं नया टर्मिनल खोलें (Gemini CLI में नहीं)

cd ~/storygen-learning/00_Starting_Here

पूरा सेटअप चलाएं:

./setup-complete.sh

आपको टर्मिनल में सेटअप के नतीजे दिखेंगे

अपना पहला एजेंट बनाना

01a_First_Agent_Ready पर जाएं आइए, ADK एजेंट बनाने के लिए Gemini CLI का इस्तेमाल करें:**

cd ~/storygen-learning/01a_First_Agent_Ready

Gemini CLI खोलें

gemini

Gemini CLI विंडो में, यह प्रॉम्प्ट आज़माकर देखें:

I need you to help me create a Google ADK (Agent Development Kit) agent for story generation. I'm working on a children's storybook app that generates creative stories with visual scenes.

Please create a complete `agent.py` file that implements an LlmAgent using Google's ADK framework. The agent should:

**Requirements:**
1. Use the `google.adk.agents.LlmAgent` class
2. Use the "gemini-2.5-flash" model (supports streaming)
3. Be named "story_agent"
4. Generate structured stories with exactly 4 scenes each
5. Output valid JSON with story text, main characters, and scene data
6. No tools needed (images are handled separately)

**Agent Specifications:**
- **Model:** gemini-2.5-flash
- **Name:** story_agent  
- **Description:** "Generates creative short stories and accompanying visual keyframes based on user-provided keywords and themes."
**Story Structure Required:**
- Exactly 4 scenes: Setup  Inciting Incident  Climax  Resolution
- 100-200 words total
- Simple, charming language for all audiences
- Natural keyword integration
**JSON Output Format:**

{
  "story": "Complete story text...",
  "main_characters": [
    {
      "name": "Character Name",
      "description": "VERY detailed visual description with specific colors, features, size, etc."
    }
  ],
  "scenes": [
    {
      "index": 1,
      "title": "The Setup",
      "description": "Scene action and setting WITHOUT character descriptions",
      "text": "Story text for this scene"
    }
    // ... 3 more scenes
  ]
}


**Key Instructions for the Agent:**
- Extract 1-2 main characters maximum
- Character descriptions should be extremely detailed and visual
- Scene descriptions focus on ACTION and SETTING only
- Do NOT repeat character appearance in scene descriptions
- Always respond with valid JSON

Please include a complete example in the instructions showing the exact format using keywords like "tiny robot", "lost kitten", "rainy city".

The file should start with necessary imports, define an empty tools list, include a print statement for initialization, and then create the LlmAgent with all the detailed instructions.

Can you create this agent in backend/story_agent/agent.py

काम पूरा होने के बाद, Control+C की मदद से Gemini CLI टर्मिनल को बंद करें

—————————————— ज़रूरी नहीं है, समाधान वाले हिस्से पर जाएं——————————————–

अब ADK Web में किए गए बदलाव की पुष्टि करें

cd ~/storygen-learning/01a_First_Agent_Ready/backend

source ../../.venv/bin/activate

adk web --port 8080

वेबसाइट को स्पिन अप करना

cd ~/storygen-learning/01a_First_Agent_Ready

./start.sh

अगर आपका बदलाव काम नहीं करता है, तो आपको ADK के वेब यूज़र इंटरफ़ेस (यूआई) और वेबसाइट में गड़बड़ियां दिखेंगी.

——————————————– यहां से समाधान शुरू होता है ——————————————–

समाधान

Control+C का इस्तेमाल करके पिछली प्रोसेस बंद करें या कोई दूसरा टर्मिनल खोलें:

cd ~/storygen-learning/01b_First_Agent_Done

वेबसाइट को स्पिन अप करना:

./start.sh

आपको यह वेबसाइट दिखेगी:

वेबसाइट

ADK के यूज़र इंटरफ़ेस को आज़माएं: कोई दूसरा टर्मिनल खोलें:

cd ~/storygen-learning/01b_First_Agent_Done/backend
source ../../.venv/bin/activate

adk web --port 8080

आपको ADK का यूज़र इंटरफ़ेस (यूआई) दिखेगा. यहां एजेंट से सवाल पूछे जा सकते हैं

adkweb

अगले सेक्शन पर जाने से पहले, प्रोसेस को बंद करने के लिए Ctrl+C दबाएं.

5. डेवलपमेंट: Imagen की मदद से, अपनी पसंद के मुताबिक एजेंट बनाना

2adk

Imagen टूल (दूसरा एजेंट) जनरेट करो

cd ~/storygen-learning/02a_Image_Agent_Ready

इमेज जनरेट करने वाला एजेंट बनाने के लिए, Gemini CLI का इस्तेमाल करें:

gemini generate "I need you to help me create a custom Google ADK (Agent Development Kit) agent for image generation. This is different from the story agent - this one handles image generation directly using the BaseAgent pattern for full control over tool execution.

Please create a complete `agent.py` file that implements a custom image generation agent. The agent should:

**Requirements:**
1. Use the `google.adk.agents.BaseAgent` class (NOT LlmAgent)
2. Be named "custom_image_agent" 
3. Directly execute the ImagenTool without LLM intermediation
4. Handle JSON input with scene descriptions and character descriptions
5. Store results in session state for retrieval by main.py
6. Use async generators and yield Events

**Key Specifications:**
- **Class Name:** CustomImageAgent (inherits from BaseAgent)
- **Agent Name:** "custom_image_agent"
- **Tool:** Uses ImagenTool for direct image generation
- **Purpose:** Bypass LLM agent limitations and directly call ImagenTool

**Input Format:**
The agent should handle JSON input like:
{
  "scene_description": "Scene action and setting",
  "character_descriptions": {
    "CharacterName": "detailed visual description"
  }
}


**Core Method:** `async def _run_async_impl(self, ctx: InvocationContext) -> AsyncGenerator[Event, None]:`
   - Extract user message from `ctx.user_content.parts`
   - Parse JSON input or fallback to plain text
   - Extract scene_description and character_descriptions
   - Build image prompt with style prefix: "Children's book cartoon illustration with bright vibrant colors, simple shapes, friendly characters."
   - Include character descriptions for consistency
   - Call `await self.imagen_tool.run()` directly
   - Store results in `ctx.session.state["image_result"]`
   - Yield Event with results


 **Session State:**
   - Store JSON results in `ctx.session.state["image_result"]`
   - Include success/error status
   - Store actual image URLs or error messages

Expected Output Structure:
- Successful results stored as JSON with image URLs
- Error results stored as JSON with error messages
- Results accessible via session state in main.py

Can you create this agent in backend/story_image_agent/agent.py

"

—————————————— ज़रूरी नहीं है, समाधान वाले हिस्से पर जाएं——————————————–

अब ADK Web में किए गए बदलाव की पुष्टि करें

cd ~/storygen-learning/02a_Image_Agent_Ready/backend

source ../../.venv/bin/activate

adk web --port 8080

वेबसाइट को स्पिन अप करना

cd ~/storygen-learning/02a_Second_Agent_Ready

./start.sh

अगर आपका बदलाव काम नहीं करता है, तो आपको ADK के वेब यूज़र इंटरफ़ेस (यूआई) और वेबसाइट में गड़बड़ियां दिखेंगी.

——————————————- Solution Starting Here ——————————————–

समाधान

Control+C का इस्तेमाल करके पिछली प्रोसेस बंद करें या कोई दूसरा टर्मिनल खोलें:

# Open new terminal
cd ~/storygen-learning/02b_Image_Agent_Done

वेबसाइट को स्पिन अप करना:

./start.sh

आपको यह वेबसाइट दिखेगी:

वेबसाइट

ADK के यूज़र इंटरफ़ेस को आज़माएं: कोई दूसरा टर्मिनल खोलें:

# Open new terminal
cd ~/storygen-learning/02b_Image_Agent_Done/backend

source ../../.venv/bin/activate

adk web --port 8080

आपको ADK का यूज़र इंटरफ़ेस (यूआई) दिखेगा. यहां एजेंट से सवाल पूछे जा सकते हैं:

adkweb

अगले सेक्शन पर जाने से पहले, प्रोसेस को बंद करने के लिए Ctrl+C दबाएं.

6. टेस्टिंग: एजेंट का आकलन

हमारा ऐप्लिकेशन काम करता है, लेकिन हमें टेस्ट के लिए ऑटोमेटेड सेफ्टी नेट की ज़रूरत है. यह एक ऐसा काम है जिसे हमारे एआई को-पायलट को सौंपा जा सकता है.

कार्रवाइयां

cd ~/storygen-learning/03a_Agent_Evaluation_Ready/backend

पूरी तरह से जांच करने के लिए, Gemini CLI का इस्तेमाल करें:

Gemini CLI खोलें

gemini

Gemini CLI विंडो में, यह प्रॉम्प्ट आज़माकर देखें:

I need you to create comprehensive test files for my backend/story_agent in Google ADK. I need three specific JSON files that match the testing structure used in ADK evaluation.

**Context:** 
- The story agent generates structured JSON stories with exactly 4 scenes
- It uses LlmAgent with no tools, just direct LLM responses
- Input: Keywords
- Output: JSON with story, main_characters, and scenes arrays

**Files to Create:**

### 1. `story_agent_eval.evalset.json` (Comprehensive Integration Tests)
Create a comprehensive evaluation set with:
- **eval_set_id**: "story_agent_comprehensive_evalset"
- **name**: "Story Agent Comprehensive Evaluation Set" 
- **description**: "Comprehensive evaluation scenarios for story_agent covering various keyword combinations, edge cases, and story quality metrics"


Each eval_case should include:
- Full conversation arrays with invocation_id, user_content, final_response
- Complete expected JSON responses with detailed stories, characters, and 4 scenes
- session_input with app_name "story_agent"
- All fields: story (narrative text), main_characters (with detailed visual descriptions), scenes (with index, title, description, text)

### 2. `story_generation.test.json` (Unit Tests)
Create basic generation tests with:
- **eval_set_id**: "story_agent_basic_generation_tests"
- **name**: "Story Agent Basic Generation Tests"
- **description**: "Unit tests for story_agent focusing on JSON structure compliance, scene generation, and keyword integration"

### 3. `test_config.json` (Evaluation Configuration)
Create test configuration with:
- **criteria**: response_match_score: 0.7, tool_trajectory_avg_score: 1.0
- **custom_evaluators**: 
  - json_structure_validator (validates required fields, scene count, character fields)
  - story_quality_metrics (word count 80-250, keyword integration threshold 0.8)
- **evaluation_notes**: Story agent specifics and trajectory expectations

**Important Requirements:**
1. All responses must be valid, parseable JSON
2. Stories must have exactly 4 scenes with indices 1-4
3. Each scene must have: index, title, description, text
4. Main characters must have detailed visual descriptions
5. No tool_uses expected (empty arrays) since story agent uses direct LLM
6. Word count should be 100-200 words total
7. Keywords must be naturally integrated into the narrative

Please generate all three files with realistic example stories and comprehensive test coverage matching the ADK evaluation format.

—————————————— ज़रूरी नहीं है, समाधान वाले हिस्से पर जाएं——————————————–

आकलन देखने के लिए:

./run_adk_web_persistent.sh

ADK के यूज़र इंटरफ़ेस (यूआई) पर eval टैब पर जाएं.

आपको ADK का वेब यूज़र इंटरफ़ेस (यूआई) दिखना चाहिए, जिसमें लगातार टेस्टिंग की जा सकती हो

सीखने के लिए मुख्य बातें: एआई, क्वालिटी अश्योरेंस को अपने-आप पूरा करने में एक अहम भूमिका निभाता है. यह टेस्ट लिखने के लिए ज़रूरी जानकारी को अपने-आप भर सकता है, ताकि आप सुविधाओं को बनाने पर ध्यान दे सकें.

——————————————– यहां से समाधान शुरू होता है ——————————————–

समाधान

  • समाधान फ़ोल्डर पर जाएं:
cd ~/storygen-learning/03b_Agent_Evaluation_Done/backend
  • ADK का वेब यूज़र इंटरफ़ेस (यूआई) खोलें
./run_adk_web_persistent.sh

Eval टैब में जाकर, टेस्ट केस देखे जा सकते हैं:

eval1

यहां मेट्रिक में बदलाव करें:

eval2

यहां आकलन के नतीजे देखें:

eval3

7. Infrastructure as Code (IaC): Building a Home in the Cloud

हमारे कोड की जांच हो चुकी है. हालांकि, इसे प्रोडक्शन के लिए तैयार होम की ज़रूरत है. हम अपने एनवायरमेंट को तय करने के लिए, "Infrastructure as Code" का इस्तेमाल करेंगे.

deployprocess

कार्रवाइयां

cd ~/storygen-learning/04a_Manual_Deployment_Ready

बैकएंड के लिए Dockerfile बनाने के लिए, Gemini CLI का इस्तेमाल करें: Gemini CLI खोलें

Gemini

Gemini CLI में, यह प्रॉम्प्ट आज़माएँ:

Create a manual deployment plan for my StoryGen app with Google Cloud Platform. I have a Next.js frontend, Python backend, and Terraform infrastructure.

Generate these deployment files:
1. **01-setup.sh** - Environment setup and authentication
2. **02-build-images.sh** - Build and push Docker images to Google Container Registry
3. **03-deploy-infrastructure.sh** - Deploy with Terraform and configure services
4. **load-env.sh** - Load environment variables for deployment

**Requirements:**
- Use Google Cloud Run for both frontend and backend
- Configure Imagen API and storage buckets
- Set up proper IAM permissions
- Use environment variables from .env file
- Include error handling and status checks

Keep scripts simple, well-commented, and production-ready for manual execution.

समाधान:

cd ~/storygen-learning/04b_Manual_Deployment_Done

रन:

source ../.venv/bin/activate
./01-setup.sh
./02-build-images.sh
./03-deploy-infrastructure.sh

आपको डिप्लॉयमेंट के नतीजे और इन्फ़्रास्ट्रक्चर बनाने की प्रोसेस दिखेगी

8. ऑटोमेशन (सीआई/सीडी): डिजिटल असेंबली लाइन

हमारे ऐप्लिकेशन को मैन्युअल तरीके से डिप्लॉय करने में समय लगता है और यह जोखिम भरा होता है. आइए, हम अपने एआई से GitHub Actions का इस्तेमाल करके, पूरी CI/CD पाइपलाइन लिखने के लिए कहें.

कार्रवाइयां

cd ~/storygen-learning/05a_CICD_Pipeline_Ready

GitHub के साथ CI/CD पाइपलाइन बनाने के लिए, Gemini CLI का इस्तेमाल करें:

Gemini CLI खोलें

Gemini

Gemini CLI में, यह प्रॉम्प्ट आज़माएँ:

Create a CI/CD pipeline for my StoryGen app using Google Cloud Build and GitHub integration.

Generate these automation files:
1. **cloudbuild.yaml** (for backend) - Automated build, test, and deploy pipeline
2. **GitHub Actions workflow** - Trigger builds on push/PR
3. **Deployment automation scripts** - Streamlined deployment process

**Requirements:**
- Auto-trigger on GitHub push to main branch
- Build and push Docker images
- Run automated tests if available
- Deploy to Google Cloud Run
- Environment-specific deployments (staging/prod)
- Notification on success/failure

Focus on fully automated deployment with minimal manual intervention. Include proper secret management and rollback capabilities.

——————————————– यहां से समाधान शुरू होता है ——————————————–

समाधान:

cd ~/storygen-learning/06_Final_Solution/
# Copy the GitHub workflow to parent folder
cp -r 06_Final_Solution/.github ../../../.github

06_Final_Solution फ़ोल्डर पर वापस जाएं और स्क्रिप्ट चलाएं:

cd ~/storygen-learning/06_Final_Solution/

./setup-cicd-complete.sh

आपको CI/CD पाइपलाइन सेटअप पूरा होने का मैसेज दिखेगा

वर्कफ़्लो ट्रिगर करना: अपने कोड को मुख्य ब्रांच में कमिट करें और पुश करें. ध्यान दें कि अनुमति देने के लिए, आपको GitHub पर अपना ईमेल पता और नाम सेट अप करना होगा.

git add .
git commit -m "feat: Add backend, IaC, and CI/CD workflow"
git push origin main

अपने-आप डिप्लॉय होने की प्रोसेस देखने के लिए, GitHub रिपॉज़िटरी में "कार्रवाइयां" टैब पर जाएं.

सीखने के लिए अहम जानकारी: पूरी CI/CD पाइपलाइन को एआई जनरेट कर सकता है. यह DevOps का एक जटिल और अहम हिस्सा है.

9. ऑपरेशंस: एआई कंट्रोल टॉवर

हम लाइव हैं! हालांकि, यह सफ़र अभी खत्म नहीं हुआ है. यह "दूसरा दिन" है—कार्रवाइयां. आइए, चालू ऐप्लिकेशन को मैनेज करने के लिए, Cloud Assist पर वापस जाएं.

कार्रवाइयां

  1. Google Cloud Console में, अपनी Cloud Run सेवा पर जाएं. कुछ ट्रैफ़िक और लॉग जनरेट करने के लिए, अपने लाइव ऐप्लिकेशन से इंटरैक्ट करें.
  2. Cloud Assist पैनल खोलें और इसे ऑपरेशनल को-पायलट के तौर पर इस्तेमाल करें. इसके लिए, इस तरह के प्रॉम्प्ट का इस्तेमाल करें:

लॉग का विश्लेषण:

Summarize the errors in my Cloud Run logs for the service 'genai-backend' from the last 15 minutes.

परफ़ॉर्मेंस को बेहतर बनाना:

My Cloud Run service 'genai-backend' has high startup latency. What are common causes for a Python app and how can I investigate with Cloud Trace?

लागत ऑप्टिमाइज़ेशन:

Analyze the costs for my 'genai-backend' service and its GCS bucket. Are there any opportunities to save money?

सीखने के लिए अहम जानकारी: एआई एसडीएलसी एक लगातार चलने वाली प्रोसेस है. जिस एआई को-पायलट ने ऐप्लिकेशन बनाने में मदद की थी वह प्रोडक्शन में ऐप्लिकेशन की निगरानी करने, समस्या हल करने, और उसे ऑप्टिमाइज़ करने के लिए एक ज़रूरी पार्टनर है.