

ExpenseTracker is an AI-powered web app that I built to help users effortlessly track expenses, manage monthly budgets, and gain insights into their spending habits through a conversational interface powered by Gemini AI, Google ADK, and Google Firestore.
- Google ADK: Google ADK is an open-source framework for building and deploying collaborative AI agents.
- ADK Web UI: The ADK Web UI provides a browser-based interface to interact with and debug your AI agents built with the Google ADK.
- Google Firestore: A scalable, serverless NoSQL database for storing user expenses and budgets.
- Gemini Flash 2.5: An agentic language model for natural language understanding and reasoning.
Create a new Google Cloud Project:
Sign in or sign up for the Google Cloud Console and create a new project. Store the project ID for further use cases.
Start the Google Cloud Shell, a remote shell environment in the cloud.
Create Environment variables for REGION
and PROJECT_ID
.
export PROJECT_ID=
export REGION=us-east1
Enabling APIs.
gcloud services enable artifactregistry.googleapis.com \
cloudbuild.googleapis.com \
run.googleapis.com \
firestore.googleapis.com
Create a Firestore Database
The documentation has more complete steps to set up a Firestore instance. At a high level, to start, I will follow these steps:
- Go to the Firestore Viewer and from the Select a database service screen, choose Firestore in Native mode
- Select a location for your Firestore (Make sure to choose us-central1 and follow this wherever you choose region/location throughout this codelab)
- In the security rules, select the “OPEN” so Security Rules so that the data is accessible.
- Click Create Database (if this is the first time, leave it as “(default)” database)
When you create a Firestore project, it also enables the API in the Cloud API Manager.
Once it’s set up, you should see the Firestore Database, Collection, and Document view in Native mode as seen in the image below:
Create a GCP Service Account
A service account is a Google Cloud identity used by applications and services to access Google Cloud resources programmatically.
Create a new service account using this command. (Use the same terminal opened in the previous section)
gcloud iam service-accounts create expense-tracker-sacc
To provide access to your project and resources, grant a role to the service account.
gcloud projects add-iam-policy-binding ${PROJECT_ID} --member="serviceAccount:expense-tracker-sacc@${PROJECT_ID}.iam.gserviceaccount.com" --role=roles/datastore.owner
Get GEMINI API Key
Google AI Studio is a web-based platform for prototyping and experimenting with Google’s generative AI models.
- Visit aistudio.google.com and sign in using the same Google Account associated with your Google Cloud Console project.
- In the top navigation bar, click “Get API Key” to access the API key management page.
- Click “Create API Key”, then select the Google Cloud project you created earlier. Your new API key will be generated.
- Save this API key securely — you’ll need it to run and deploy the application.
Great, we’re all set! Now, let’s dive into building the Agentic system and explore how it interacts with our databases.
Let’s see why we chose Firestore as our primary database.
Firestore is a serverless, real-time NoSQL database that perfectly fits ExpenseTracker’s AI-driven, chat-based workflow. It offers:
- Flexible Schema: Easily stores structured data like expenses and budgets.
- Tight Integration: Works seamlessly with Google Cloud and Gemini APIs.
- Secure & Scalable: Granular access rules and built-in scalability for growth.
- Event Triggers: Pairs well with Cloud Functions for reactive flows like alerts or summaries.
Agentic systems shift from traditional software to intelligent, autonomous modules that interpret data, make decisions, and act independently. The Expense Agent uses AI to simplify adding and categorizing expenses with natural language and image processing.
Features of the Expense Agent
Our Expense Agent enhances the typical expense tracking workflow by handling unstructured inputs — text and images — with minimal user effort.
- Smart Text Parsing: Users can type entries like “Paid ₹500 for Zomato yesterday”, and the agent extracts the amount, vendor, category, and date automatically.
- Image-Based Entry: Upload a receipt, and the agent, using Gemini multimodal APIs, analyzes it to extract key data like total amount, vendor name, and purchase date.
- Persistence: The Agent stores the extracted expense data in the Firestore database using the available tools.
How do Agents use Tools?
Agents can’t directly access databases, APIs, or websites. So we give them tools, aka functions, that do those actions (like search, fetch data, update records). The agent “calls” these tools when needed.
Example Interactions
- Add ₹500 for groceries yesterday.
- Set my monthly budget to ₹10,000”.
- Show me my expenses for travel this month.
Clone the repository and go to the directory.
git clone https://github.com/bhaaratkrishnan/expense-tracker-gcp.git
cd expense-tracker-gcp
Open Google Cloud Editor and replace GEMINI_API_KEY
in the Dockerfile
with your API KEY.
If the database name for the Firestore is not (default), mention it as an FIRESTORE_DB
environment variable in the
Docker file
Deploy the application to Cloud Run using this command:
gcloud run deploy expense-tracker-gcp --source=. --port=8000 --allow-unauthenticated --service-account=expense-tracker-sacc@${PROJECT_ID}.iam.gserviceaccount.com --project=${PROJECT_ID} --region=us-east1
Yaay !! Expense Tracker is up and running.
Expense Tracker is designed to simplify personal finance management and add a touch of fun. Give it a try and let Gemini models make your financial life easier and more enjoyable!
Source Credit: https://medium.com/google-cloud/ai-expense-tracker-using-gemini-2-5-flash-google-adk-and-firestore-65bf88ad777f?source=rss—-e52cf94d98af—4