<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Aksh2758</title>
    <description>The latest articles on Forem by Aksh2758 (@aksh2758).</description>
    <link>https://forem.com/aksh2758</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3628353%2Fb9bafd1d-21c1-48f6-b3cd-8aa116ec3a4b.png</url>
      <title>Forem: Aksh2758</title>
      <link>https://forem.com/aksh2758</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aksh2758"/>
    <language>en</language>
    <item>
      <title>💸 SubZap: Hunting “Zombie Subscriptions” with AlloyDB and Gemini AI</title>
      <dc:creator>Aksh2758</dc:creator>
      <pubDate>Tue, 25 Nov 2025 06:55:25 +0000</pubDate>
      <link>https://forem.com/aksh2758/subzap-hunting-zombie-subscriptions-with-alloydb-and-gemini-ai-2m49</link>
      <guid>https://forem.com/aksh2758/subzap-hunting-zombie-subscriptions-with-alloydb-and-gemini-ai-2m49</guid>
      <description>&lt;p&gt;&lt;strong&gt;Have you ever checked your bank statement and found a $12.99 charge for a service you haven’t used in six months?&lt;/strong&gt; You are not alone. These are “Zombie Subscriptions” — free trials that quietly turned into paid memberships, draining our wallets silently.&lt;/p&gt;

&lt;p&gt;In this blog, I will share how I built &lt;strong&gt;SubZap&lt;/strong&gt;, an intelligent AI Agent that connects to your financial data, hunts down these hidden costs, and helps you reclaim your money. This project was built during the &lt;strong&gt;Google Cloud Build &amp;amp; Blog Marathon 2025&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💡 The Problem&lt;/strong&gt;&lt;br&gt;
Modern banking apps show us what we spent, but they don’t tell us why it matters. Finding a recurring subscription buried in 2,000 rows of coffee and grocery transactions is like finding a needle in a haystack.&lt;/p&gt;

&lt;p&gt;I wanted to build an agent that doesn’t just “show data” but reasons about it. I wanted to ask:&lt;/p&gt;

&lt;p&gt;_“Identify my recurring subscriptions and tell me how much I am wasting.”&lt;br&gt;
_&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🛠️ The Solution &amp;amp; Tech Stack&lt;/strong&gt;&lt;br&gt;
To build a scalable, secure, and intelligent financial agent, I chose the following Google Cloud stack:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Google Cloud Run&lt;/strong&gt;: To host the application (Streamlit) serverlessly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AlloyDB for PostgreSQL&lt;/strong&gt;: A fully managed, PostgreSQL-compatible database to store thousands of transaction records with high performance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vertex AI (Gemini 2.0 Flash)&lt;/strong&gt;: The cognitive engine. It serves two roles
:
     - &lt;strong&gt;Translator&lt;/strong&gt;: Converts natural English questions into complex SQL queries.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;🚀** Building the “Agentic” Workflow**&lt;br&gt;
The core of SubZap is the &lt;strong&gt;Agentic RAG(Retrieval Augmented Generation)&lt;/strong&gt; pattern. Instead of vector search, I used &lt;strong&gt;Text-to-SQL&lt;/strong&gt;, which is more accurate for structured financial data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Setting up the Data Foundation (AlloyDB)&lt;/strong&gt;&lt;br&gt;
I needed a database that could handle complex queries and scale easily. I created an &lt;strong&gt;AlloyDB Cluster&lt;/strong&gt; and connected it via &lt;strong&gt;VPC Peering&lt;/strong&gt; to ensure my transaction data remained on a Private IP (crucial for financial security).&lt;/p&gt;

&lt;p&gt;I designed a simple but effective schema:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`CREATE TABLE transactions (
    id SERIAL PRIMARY KEY,
    date DATE,
    description VARCHAR(255),
    amount DECIMAL(10, 2),
    category VARCHAR(100)
);`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: The “Brain” (Gemini 2.0 Flash)&lt;/strong&gt;&lt;br&gt;
The magic happens in how the AI interacts with the database. I used &lt;strong&gt;Vertex AI’s Gemini 2.0 Flash&lt;/strong&gt; model because of its incredible speed and reasoning capabilities.&lt;/p&gt;

&lt;p&gt;Here is the Python function that powers the Natural Language to SQL conversion:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;`
def ask_gemini_to_write_sql(user_question):
    vertexai.init(project=PROJECT_ID, location="us-central1")
    model = GenerativeModel("gemini-2.0-flash-exp") 

    prompt = f"""
    You are a PostgreSQL expert. Convert the user's request into a SQL query.
    Table: 'transactions'
    Columns: id, date (timestamp), description (text), amount (float), category (text)

    Rules: 
    1. Return ONLY the raw SQL code. No markdown.
    2. Case insensitive searches: Use ILIKE.
    3. Look for recurring patterns for subscriptions.

    User Question: {user_question}
    """
    response = model.generate_content(prompt)
    return response.text.strip()
`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: The Insight (Reasoning)&lt;/strong&gt;&lt;br&gt;
Getting the data isn’t enough. If the database returns 5 rows of “Gym Membership”, the user needs to know the &lt;strong&gt;total impact&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I passed the SQL results back to Gemini with this prompt:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“Act as a financial advisor. Analyze this data. If you see recurring monthly charges, flag them as likely subscriptions and calculate the annual waste.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📊 The Result&lt;/strong&gt;&lt;br&gt;
The final application is a Streamlit dashboard where users can interact naturally with their finances.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqc19zvg54k2eiuaea4oo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqc19zvg54k2eiuaea4oo.png" alt=" " width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I asked, “&lt;em&gt;Identify my recurring subscriptions&lt;/em&gt;,” the agent correctly identified a hidden Gym Membership charging me $49/month and flagged it as a high-priority cancellation. It parsed 2,000+ rows in milliseconds, thanks to Alloy DB’s performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 Challenges &amp;amp; Learnings&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  - **Private Networking:** Connecting Cloud Run to AlloyDB via Private IP was tricky. I learned how VPC Connectors bridge serverless apps to private database clusters.
  - **Prompt Engineering:** Teaching the AI to distinguish between “Coffee” (recurring habit) and “Netflix” (recurring subscription) required refining the system instructions to look for specific keywords and date patterns.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;🔮 What’s Next?&lt;/strong&gt;&lt;br&gt;
I plan to add &lt;strong&gt;automatic cancellation emails&lt;/strong&gt; — where the agent not only finds the subscription but drafts the cancellation email for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SubZap&lt;/strong&gt; proves that with Google Cloud’s composable tools (AlloyDB + Vertex AI), a single developer can build powerful, agentic applications in less than 24 hours.&lt;/p&gt;

&lt;p&gt;Code Repository: &lt;a href="https://github.com/Aksh2758/subzap-ai-agent.git" rel="noopener noreferrer"&gt;https://github.com/Aksh2758/subzap-ai-agent.git&lt;/a&gt;&lt;br&gt;
Demo Video: &lt;a href="https://drive.google.com/file/d/1jLEJ65DeyhCKuSNHp4NokAQVJRI-YX42/view?usp=sharing" rel="noopener noreferrer"&gt;https://drive.google.com/file/d/1jLEJ65DeyhCKuSNHp4NokAQVJRI-YX42/view?usp=sharing&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  GoogleCloud #AlloyDB #Gemini #BuildAndBlog #AI #Hackathon
&lt;/h1&gt;

</description>
      <category>gemini</category>
      <category>ai</category>
      <category>database</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
