<?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>DEV Community: Daniel Melbourne</title>
    <description>The latest articles on DEV Community by Daniel Melbourne (@daniel_melbourne_babab39c).</description>
    <link>https://dev.to/daniel_melbourne_babab39c</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%2F3846907%2F41173a10-ce17-416d-af4d-53928b82a7cf.png</url>
      <title>DEV Community: Daniel Melbourne</title>
      <link>https://dev.to/daniel_melbourne_babab39c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/daniel_melbourne_babab39c"/>
    <language>en</language>
    <item>
      <title>I built an AI agent that audits businesses for Australian compliance — architecture + economics</title>
      <dc:creator>Daniel Melbourne</dc:creator>
      <pubDate>Sat, 28 Mar 2026 02:17:56 +0000</pubDate>
      <link>https://dev.to/daniel_melbourne_babab39c/i-built-an-ai-agent-that-audits-businesses-for-australian-compliance-architecture-economics-5ghp</link>
      <guid>https://dev.to/daniel_melbourne_babab39c/i-built-an-ai-agent-that-audits-businesses-for-australian-compliance-architecture-economics-5ghp</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gh"&gt;# I built an AI agent that audits businesses for Australian compliance law — here's the architecture&lt;/span&gt;

Hey everyone! I wanted to share a side project I've been working on: an AI agent that audits businesses for compliance with Australian laws. It's still very much a work in progress, but I'm pretty excited about it, and I thought some of you might find the architecture interesting.

&lt;span class="gu"&gt;## The Problem: SMEs are drowning in compliance regulations&lt;/span&gt;

Running a small business in Australia is tough. Beyond the usual challenges, there's a mountain of compliance regulations to navigate.  Things like ABN registration, GST obligations, data privacy (the Privacy Act), workplace health and safety (WHS), and industry-specific licenses can be overwhelming.  Many SMEs simply don't know what they need to comply with, and the cost of hiring a lawyer or consultant to figure it out is often prohibitive.

&lt;span class="gu"&gt;## The Solution: Gemini-powered audit pipeline&lt;/span&gt;

My idea was simple: use a large language model (LLM) to analyze a business's activities and identify relevant compliance obligations. I chose Gemini (specifically Gemini 1.5 Pro) because of its context window size and relatively good performance with Australian legal jargon.

The agent takes a description of the business as input (e.g., "A small online store selling handmade jewelry") and outputs a list of relevant compliance areas, along with brief explanations and links to official government resources.

&lt;span class="gu"&gt;## Architecture: Flask API → Gemini → structured JSON → email delivery&lt;/span&gt;

The system is built around a fairly straightforward architecture:
&lt;span class="p"&gt;
1.&lt;/span&gt;  &lt;span class="gs"&gt;**Flask API:**&lt;/span&gt; A simple Flask API exposes a single endpoint that accepts a business description as input.
&lt;span class="p"&gt;2.&lt;/span&gt;  &lt;span class="gs"&gt;**Gemini Integration:**&lt;/span&gt; The API sends the business description to Gemini 1.5 Pro via the Google AI Python SDK.  I've crafted a prompt that instructs Gemini to analyze the description and return a JSON object containing the audit results.
&lt;span class="p"&gt;3.&lt;/span&gt;  &lt;span class="gs"&gt;**Structured JSON Output:**&lt;/span&gt; Gemini returns a JSON object with a standardized format, including fields for compliance area, description, relevant laws, and links to resources.
&lt;span class="p"&gt;4.&lt;/span&gt;  &lt;span class="gs"&gt;**Email Delivery:**&lt;/span&gt; The API formats the JSON output into a human-readable email and sends it to the user.

Here's a simplified version of the Python code I'm using:

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
python&lt;br&gt;
from flask import Flask, request, jsonify&lt;br&gt;
import google.generativeai as genai&lt;br&gt;
import os&lt;br&gt;
import json&lt;br&gt;
from sendgrid import SendGridAPIClient&lt;br&gt;
from sendgrid.helpers.mail import Mail&lt;/p&gt;

&lt;p&gt;app = Flask(&lt;strong&gt;name&lt;/strong&gt;)&lt;/p&gt;

&lt;p&gt;genai.configure(api_key=os.environ["GOOGLE_API_KEY"])&lt;br&gt;
model = genai.GenerativeModel('gemini-1.5-pro')&lt;/p&gt;

&lt;p&gt;def generate_audit(business_description):&lt;br&gt;
    prompt = f"""&lt;br&gt;
    You are a compliance auditor for Australian businesses. Analyze the following business description and identify relevant compliance areas.&lt;br&gt;
    Return a JSON object with the following format:&lt;br&gt;
    {{&lt;br&gt;
        "compliance_areas": [&lt;br&gt;
            {{&lt;br&gt;
                "area": "Name of compliance area (e.g., ABN Registration)",&lt;br&gt;
                "description": "Brief explanation of the compliance area",&lt;br&gt;
                "relevant_laws": "List of relevant Australian laws (e.g., A New Tax System (Australian Business Number) Act 1999)",&lt;br&gt;
                "resources": "Link to official government resources"&lt;br&gt;
            }}&lt;br&gt;
        ]&lt;br&gt;
    }}&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Business Description: {business_description}
"""
response = model.generate_content(prompt)
try:
    return json.loads(response.text)
except json.JSONDecodeError:
    return {"error": "Failed to parse JSON response from Gemini"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;def send_email(email_address, audit_results):&lt;br&gt;
    # SendGrid email logic (omitted for brevity)&lt;br&gt;
    pass&lt;/p&gt;

&lt;p&gt;@app.route('/api/v1/audit', methods=['POST'])&lt;br&gt;
def audit():&lt;br&gt;
    data = request.get_json()&lt;br&gt;
    business_description = data.get('business_description')&lt;br&gt;
    email_address = data.get('email_address')&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if not business_description or not email_address:
    return jsonify({"error": "Missing business_description or email_address"}), 400

audit_results = generate_audit(business_description)

if "error" in audit_results:
    return jsonify(audit_results), 500

send_email(email_address, audit_results)

return jsonify({"message": "Audit completed and sent to your email address."}), 200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;if &lt;strong&gt;name&lt;/strong&gt; == '&lt;strong&gt;main&lt;/strong&gt;':&lt;br&gt;
    app.run(debug=True)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Here's an example of how to call the API using `curl`:

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
bash&lt;br&gt;
curl -X POST \&lt;br&gt;
  &lt;a href="https://theepic.shop/api/v1/audit" rel="noopener noreferrer"&gt;https://theepic.shop/api/v1/audit&lt;/a&gt; \&lt;br&gt;
  -H 'Content-Type: application/json' \&lt;br&gt;
  -d '{&lt;br&gt;
    "business_description": "A small online store selling handmade jewelry from home in Victoria",&lt;br&gt;
    "email_address": "&lt;a href="mailto:your_email@example.com"&gt;your_email@example.com&lt;/a&gt;"&lt;br&gt;
  }'&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
## The AEA Cost Model: π = revenue - (c_tokens + c_API)

I'm using a simplified cost model to track the profitability of each audit.  It boils down to:

π = revenue - (c\_tokens + c\_API)

Where:

*   π = Profit per audit
*   revenue = Revenue generated per audit (currently zero, it's a free service)
*   c\_tokens = Cost of Gemini tokens used for the audit.
*   c\_API = Cost of SendGrid API calls for email delivery (negligible).

## Actual Results: cost per audit ~$0.0003 USD, margin ~99%

The amazing thing is how cheap it is to run these audits.  Gemini is surprisingly efficient.  I've been running tests with different business descriptions, and the average cost per audit is around **$0.0003 USD**.  Since I'm offering the audit for free right now, my margin is technically negative, but the potential for monetization is huge.  If I were to charge even a dollar per audit, the margin would be over 99%.

Of course, this doesn't factor in development time, hosting costs, etc. But it highlights the power of LLMs to automate tasks at scale.

## Try it out!

If you're curious, you can try the audit tool here: [https://theepic.shop/audit/](https://theepic.shop/audit/)

And the API is available at: [https://theepic.shop/api/v1/](https://theepic.shop/api/v1/)

I'm still actively developing this project, so any feedback or suggestions are welcome!  I'm particularly interested in ideas for improving the accuracy of the audit results and finding ways to monetize the service without being predatory towards small businesses.  Let me know what you think!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>ai</category>
      <category>sideprojects</category>
      <category>api</category>
    </item>
  </channel>
</rss>
