MMB Hero Demo¶
This document describes the Migrate, Modernize, and Build (MMB) hero demo.
Requirements¶
To deploy this demo, you need:
- A Google Cloud project.
- An account that has the
ownerrole on that Google Cloud project. - The gcloud CLI
- Gemini CLI
- The codmod CLI
- Docker Engine (to test locally on
your host). This guide assumes that you can
manage Docker as a non-root user,
so you can run Docker commands without
sudo. - Chrome DevTools MCP
Prepare the environment¶
-
Open Cloud Shell.
-
Install the codmod CLI
-
Install the Chrome DevTools MCP in Gemini CLI:
For more information, see the Chrome DevTools MCP README:
-
Clone the repository and set the working directory:
Chapter 1: Migrate pillar¶
TODO
Chapter 2: Modernize pillar¶
Gemini-powered .NET modernization¶
In this demo, you modernize a .NET Framework application to a Linux-ready .NET application.
This demo guide walks you through the following steps:
- Prepare the environment
- Generate a modernization assessment
- Modernize the application
- Generate deployment descriptors
- Deploy on Google Cloud
Run the Migration Center App Modernization Assessment¶
To generate a Migration Center App Modernization Assessment report, you do the following:
-
Set the working directory:
-
Generate the report:
codmod create full \ --codebase ./dotnet-migration-sample \ --output-path ./codmod-full-report-dotnet-mod.html \ --experiments=enable_pdf,enable_images \ --improve-fidelity \ --intent=MICROSOFT_MODERNIZATION \ --optional-sections "files,classes"This command takes about 15 minutes to run.
-
Open the generated report with a web browser, such as Google Chrome.
To review how the output looks like, see the sample report:
modernization-report-sample/third_party/codmod-full-report-dotnet-mod.html.
Modernize the .NET application using Gemini CLI¶
-
Change the working directory to the .NET application directory:
-
Run Gemini CLI:
-
Copy the prompt defined in
modernization-prompt.md, and paste the prompt in the Gemini CLI user interface, and press the Enter key.
To complete the execution, Gemini CLI takes about 25 minutes.
Sample modernized application¶
The dotnet-migration-sample-modernized directory contains an example of the
modernized .NET application resulting in running Gemini CLI with the above
prompt.
To run the example modernized application locally, you do the following:
-
Change the working directory to the .NET application directory:
-
Run the application using Docker Compose:
-
Wait for the application to accept connections. When the application is ready to accept connections, the output is similar to the following:
-
Open
http://localhost:8080/with a web browser, such as Google Chrome. -
Navigate the application using the web browser.
After completing your test, stop the application by sending the CTRL+C key
combination.
Deploy the application to Google Cloud¶
To deploy the the example modernized application to Google Cloud using Cloud Run, Artifact Registry, and Cloud SQL for PostgreSQL, follow the guidance in this section.
You can follow similar steps to deploy your own modernized .NET application.
1. Set up your Google Cloud environment¶
Set your project ID and region as environment variables in your shell.
export PROJECT_ID="[YOUR_PROJECT_ID]"
export REGION="[YOUR_REGION]" # e.g., us-central1
gcloud config set project $PROJECT_ID
gcloud config set run/region $REGION
2. Enable necessary Google Cloud APIs¶
Enable the APIs for Artifact Registry, Cloud SQL, Cloud Build, and Cloud Run. This allows the services to work together.
gcloud services enable \
iam.googleapis.com \
artifactregistry.googleapis.com \
sqladmin.googleapis.com \
run.googleapis.com \
cloudbuild.googleapis.com
3. Create an Artifact Registry repository¶
Create a Docker repository in Artifact Registry to store the container images for your application.
export REPO_NAME="contoso-university-repo"
gcloud artifacts repositories create $REPO_NAME \
--repository-format=docker \
--location=$REGION \
--description="Docker repository for Contoso University"
4. Create a Cloud SQL for PostgreSQL instance¶
Create a PostgreSQL instance to host the application's database. This may take a few minutes.
export INSTANCE_NAME="contoso-university-db"
export DB_PASSWORD="[YOUR_DB_PASSWORD]" # Choose a strong password
gcloud sql instances create $INSTANCE_NAME \
--database-version=POSTGRES_13 \
--tier=db-g1-small \
--region=$REGION \
--root-password=$DB_PASSWORD
After the instance is created, create a database for the application.
5. Build and push the container image¶
Use Google Cloud Build to build your container image and push it to the Artifact
Registry repository you created. Cloud Build uses the Dockerfile in your
project root.
cd "$(git rev-parse --show-toplevel)/projects/dotnet-modernization-demo/dotnet-migration-sample-modernized"
gcloud builds submit --tag $REGION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/contoso-university:latest .
6. Deploy the application to Cloud Run¶
Deploy the container image from Artifact Registry to Cloud Run. This command creates a new Cloud Run service and connects it to your Cloud SQL instance.
First, get your Cloud SQL instance connection name:
export INSTANCE_CONNECTION_NAME=$(gcloud sql instances describe $INSTANCE_NAME --format='value(connectionName)')
Now, deploy the service to Cloud Run:
gcloud run deploy contoso-university \
--image=$REGION-docker.pkg.dev/$PROJECT_ID/$REPO_NAME/contoso-university:latest \
--platform managed \
--allow-unauthenticated \
--add-cloudsql-instances=$INSTANCE_CONNECTION_NAME \
--region "${REGION}" \
--set-env-vars "ConnectionStrings__SchoolContext=Host=/cloudsql/${INSTANCE_CONNECTION_NAME};Database=contosouniversity;Username=postgres;Password=${DB_PASSWORD}"
This command will prompt you to confirm the deployment. After it completes, it will output the URL for your deployed service.
7. Test the application¶
Once the deployment is complete, you can test the application:
- Copy the URL provided in the output of the
gcloud run deploycommand. - Open the URL in a web browser.
- You should see the Contoso University application homepage. You can navigate through the site to view students, courses, instructors, and departments. The application is now running live on Cloud Run and connected to your Cloud SQL database.
- Optionally, you can go back to the Gemini CLI and ask it to run the automated UI tests again, this time against the deployed application's URL.
Clean up your Google Cloud environment¶
To avoid incurring unwanted charges, follow these steps to remove all the resources provisioned for this demo.
-
Delete the Cloud Run service
-
Delete the Artifact Registry repository
-
Delete the Cloud SQL for PostgreSQL instance
Chapter 3: Build pillar¶
Accelerating Development with Gemini: Prototyping, Implementation, and Code Review¶
In this demo, you prototype and implement application features with Gemini.
This demo guide walks you through the following steps:
- Prepare the environment
- Prototype ADK agents with Gemini CLI
- Implement new features with Gemini CLI
- Automate GitHub Pull Requests reviews with Code Review Agent
Build Pillar Requirements¶
In addition to the requirements, you also need the following to follow this chapter:
- A Google Cloud project with the
Ownerrole. - JIRA/Confluence project
- GitHub account and repository
- Gemini CLI: Installed and configured. For installation instructions, visit geminicli.com.
- GitHub CLI: Installed and configured. For installation instructions, visit Installation.
Detailed setup instructions for each demonstration are located within their respective sections below.
Prototype ADK Agents with Gemini CLI¶
This demonstration guide walks through the process of rapidly prototyping an ADK (Agent Development Kit) agent using the Gemini CLI. You will leverage the Gemini CLI's planning and implementation capabilities to quickly scaffold and refine a functional customer support agent. This "vibe prototyping" approach allows for fast iteration and development, showcasing how AI-assisted tools can accelerate the creation of complex agents and services. By the end of this demo section, you will have a working ADK agent capable of looking up and summarizing in-memory ticket data, all built and debugged primarily through natural language commands in the Gemini CLI.
Key Files¶
- GEMINI.md: Provides instructions on how to use the reference documentation to build ADK agents.
- AGENTS.txt: Contains detailed information and best practices for agent development.
AGENTS.txt file is imported into the GEMINI.md and will be included in the Gemini CLI session’s context when you interact with the Gemini CLI.
This feature facilitates the decomposition of large GEMINI.md files into smaller, more manageable modules that can be seamlessly reused across varied contexts. The import processor supports both relative and absolute paths, incorporating robust safety mechanisms to avoid circular imports and ensure secure file access.
Custom Commands¶
These custom commands help you in both planning and implementing ADK agents.
-
/plan:new- this command leverages provided documentation (GEMINI.md, AGENTS.md) to generate an implementation plan, ensuring adherence to best practices. -
/plan:impl- this command uses the implementation plan to generate the necessary Python files, reducing boilerplate and focusing on ADK requirements.
Start building the agent¶
-
Change the working directory:
-
Rename
.env.sampleto.envfile and update with your Google Cloud project information: -
Acquire new user credentials:
-
Run Gemini CLI:
-
Send prompt to create implementation plan:
/plan:new Build a customer support ADK agent that allows users to look up the full details of any ticket using its ID and also provide the ability to return a summary for any selected ticket. Generate 20 sample tickets (each with an ID, title, and description) and use them as an in-memory db.Review generated plan and request implementation. You can find an example plan in the
projects/build-with-gemini-demo/prototype-adk-agent-sample/plans/customer_support_agent.mdfile. -
Send prompt to implement the plan:
Review and approve tools and suggested code changes.
The
prototype-adk-agent-samplefolder contains sample implementation plan and customer support agent built with the prompts above. -
Exit from Gemini CLI and run commands to setup virtual environment and install required dependencies for ADK agent:
-
Start ADK Web Server to test the agent:
Click on the link to open application in the browser.
In the Cloud Shell environment, select Web Preview from the menu and change port(eg. 8000) and preview the application.
-
Testing the Agent
After you start the application and select the agent from the dropdown in the top left corner. Send a greeting to the agent and ask how they can help. This will prompt the agent to describe available operations.
Sample queries to try:
You can find an example implementation of this agent in the
projects/build-with-gemini-demo/prototype-adk-agent-sample directory.
Implement features with Gemini CLI¶
This guide demonstrates how Gemini CLI accelerate feature development within the SDLC. Using Model Context Protocol (MCP) servers, it brings requirements from external systems(eg. JIRA, Confluence) into Gemini chat for efficient planning, review, and implementation. The workflow covers setup, code generation (adding rating to a menu service), and automatic JIRA updates.
Prerequisites¶
-
For this demo you need to have JIRA and Confluence projects configured. Sign up.
-
Create Atlassian API token:
You will use
API Token Authenticationto configure Atlassian MCP server. Additional details.Go to API Tokens
Click
Create API token, give it a name and save the generated token to set environment variables. -
Create new Confluence page:
-
Create new JIRA user story and assign it to yourself:
Title: Update Menu service Update Menu service: 1. add new fields: description and rating to Menu entity 2. update other dependencies where Menu entity is used in the code, eg MenuResource. 3. Add unit tests for all methods, including new fields. Link to Confluence page: https://YOUR-ORG.atlassian.net/wiki/spaces/SD/pages/87785484/Menu-Service+Rating+capabilities
Prepare the environment for Atlassian integration¶
-
Open Cloud Shell.
-
Set environment variables:
export USERNAME="your.email@company.com" export JIRA_URL="https://your-company.atlassian.net" export CONFLUENCE_URL="https://your-company.atlassian.net/wiki"Set value in secure manner, after running this command, paste the token value and hit Enter:
Export environment variable:
-
Change the working directory:
-
Review MCP servers configuration in
.gemini/settings.json- no changes are required for this step. -
Update JIRA/Confluence instance in
.gemini/GEMINI.md:
Check MCP server configuration¶
-
Run Gemini CLI:
-
List configured MCP servers and tools:
The output confirms that the
mcp-atlassianserver is configured and ready.
Codebase explanation¶
-
Send the prompt to help you learn the codebase:
Act as a Technical Lead. I am a new developer joining this project. Please analyze this codebase and provide an Onboarding Guide. Include the following: - High-Level Architecture: What is the tech stack, and how do the components interact? - Key Functionality: What are the top 3 primary features this code executes? - Folder Structure: Briefly explain the purpose of the main directories. - Data Flow: Trace the path of a request from the entry point to the database and back.
(Optional) If you did not configure JIRA and Confluence projects¶
-
Send prompt with the task requirements:
Review the code and prepare the implementation plan for requirements below. I will approve the plan before you can start implementation. Update Menu service: 1. add new fields: description and rating to Menu entity 2. update other dependencies where Menu entity is used in the code, eg MenuResource. 3. Add unit tests for all methods, including new fields. Rating must be an integer value from 1 to 5. Can’t be null. Can’t be empty. Can’t be zero.
Bring requirements into the context of Gemini CLI session¶
-
Send prompt to list assigned JIRA tasks:
-
Send prompt to query context of linked Confluence page:
Start implementation¶
-
Send prompt to create an implementation plan:
Review the code and prepare the implementation plan. I will approve it before you can start implementation.Review the plan and request to implement the changes.
-
Send prompt to start the implementation:
Review and approve tools and suggested code changes. If Gemini CLI runs into issues, for example test validation, multiple iterations might be required to fix and re-run until generated code is valid.
-
Send prompt to update JIRA user story:
Automate GitHub Pull Requests reviews with Code Review Agent¶
This section goes over the process of integrating and utilizing Gemini Code Assist to improve GitHub code reviews. The demo will cover essential setup procedures in both Google Cloud and GitHub, followed by a showcase of Gemini Code Assist's capabilities in delivering smart suggestions, clear explanations, and concise summaries to optimize the code review workflow.
GitHub Prerequisites¶
Use existing or create a new GitHub repository to configure Gemini Code Assist on GitHub.
Below are the steps to create a new GitHub repository using gh cli from the
Cloud Shell environment.
-
Authenticate with GitHub using HTTPS option:
-
Create a new private repository:
Google Cloud Project Prerequisites¶
You need Admin or Owner basic roles for your Google Cloud project.
Setup details.
Install Gemini Code Assist application on GitHub¶
Follow instructions to install Gemini Code Assist on GitHub.
Code Review Agent Configuration¶
At this point, Code Review agent is enabled for the selected repositories.
- On the
Settingsscreen for your Developer connection, you have an option to select comment severity level and also enable memory to improve review response quality. - On the
Style Guidetab, you have an option to provide a project specific style guide. If your repository already contains a.gemini/styleguide.mdfile, the instructions from both places will be concatenated and used as an input for the Code Review Agent during the PR review process.
GitHub MCP Server configuration¶
Return to the Cloud Shell terminal and configure GitHub MCP Server:
-
Change into
gemini-code-review-agentfolder: -
Copy
menu-servicefolder into the new project: -
Set environment variable in the terminal:
-
Start Gemini CLI:
-
Commit new changes and open a pull request:
Review and approve tools that Gemini CLI requires to complete this task.
Pull Request Review¶
Open GitHub repository in the browser and observe the Code Review Agent providing a summary and review for the created pull request.
Invoking Gemini¶
You can request assistance from Gemini at any point by creating a PR comment in
the GitHub UI using either /gemini <command> or
@gemini-code-assist <command>.
-
Code Review - Performs a code review of the pull request:
-
Pull Request Summary - Provides a summary of the pull request:
-
Comment - Responds in comments when explicitly tagged, both in pull request comments and review comments: