Self-healing architectural compliance system powered by Google Gemini 3 Pro. Upload a blueprint → SiteWarden autonomously detects building-code violations and generates correction recommendations — no manual review needed.
Built for the Google Gemini 3 Hackathon.
| Feature | Description |
|---|---|
| 🔍 Autonomous Vision Analysis | Sends your real blueprint to Gemini 3 Pro Vision to detect building-code violations |
| 🌍 44-Country Regulation Support | Auto-discovers building codes for 44 countries via Grounding with Google Search |
| 🔄 Self-Healing Loop | Iteratively corrects synthetic floor plans until fully compliant (demo mode) |
| 🏢 Context Adaptation | Describe building type (hospital, school, warehouse) → Gemini generates stricter constraints |
| 📄 PDF Compliance Certificate | Professional downloadable report with before/after visual evidence |
| 📏 Real-Time Annotation | Violations are overlaid directly on your blueprint image |
| ⚡ Rate-Limited & Resilient | Exponential backoff, retry logic, graceful degradation |
┌─────────────────────────────────────────────────┐
│ Streamlit UI │
│ (app.py — upload, sidebar, thought stream) │
└────────────┬───────────────────────┬────────────┘
│ │
┌───────▼────────┐ ┌────────▼──────────┐
│ Agent Brain │ │ Regulations │
│ (agent_brain.py)│ │ (regulations.py) │
│ │ │ │
│ • See→Think→Act│ │ • PDF extraction │
│ • Vision API │ │ • Web discovery │
│ • Multi-turn │ │ • Google Search │
│ compliance │ │ grounding │
│ loop │ │ • Gemini normalize │
└───────┬─────────┘ └────────┬──────────┘
│ │
┌───────▼───────────────────────▼──────────┐
│ Google Gemini 3 Pro │
│ • system_instruction for role context │
│ • Vision (blueprint analysis) │
│ • Structured JSON output │
│ • Grounding with Google Search │
└──────────────────────────────────────────┘
│
┌───────▼──────────┐ ┌──────────────────┐
│ Blueprint │ │ PDF Certificate │
│ Renderer │ │ (pdf_certificate) │
│ (Matplotlib) │ │ (ReportLab) │
└──────────────────┘ └──────────────────┘
- SEE — Render or load the floor plan image
- THINK — Send image + regulations to Gemini Vision with
system_instruction - ACT — Parse structured JSON response, apply corrections
- LOOP — Repeat until compliant or max iterations
- Python 3.11+
- A Google Gemini API key
# Clone the repo
git clone https://github.com/your-username/sitewarden-ai.git
cd sitewarden-ai
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # macOS/Linux
# .venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Configure API key
cp .env.example .env
# Edit .env and paste your GEMINI_API_KEYstreamlit run app.pyOpen http://localhost:8501 in your browser.
| Environment Variable | Description | Required |
|---|---|---|
GEMINI_API_KEY |
Google Gemini API key | Yes (or use Demo Mode) |
Configuration is loaded from a .env file in the project root. See .env.example.
sitewarden-ai/
├── app.py # Streamlit frontend — UI, sidebar, agent orchestration
├── agent_brain.py # Core autonomous agent — Gemini Vision, compliance loop
├── regulations.py # Regulation pipeline — PDF extraction, web discovery, normalization
├── blueprint_renderer.py # Parametric floor plan renderer (Matplotlib)
├── pdf_certificate.py # Professional PDF compliance report (ReportLab)
├── style.css # Custom theme styles (dark + orange)
├── requirements.txt # Python dependencies
├── .env.example # Environment variable template
├── .gitignore # Git ignore rules
└── README.md # This file
| Gemini Feature | Where Used | Purpose |
|---|---|---|
| Gemini 3 Pro | All API calls | Latest model for speed + quality |
| Vision (multimodal) | analyse_real_blueprint() |
Analyze uploaded blueprint images |
system_instruction |
All GenerateContentConfig calls |
Set agent persona without polluting conversation |
| Structured JSON output | Compliance verdicts, parameter extraction | Reliable parsing with Pydantic validation |
| Grounding with Google Search | _gemini_generate_regulations() |
Real-time building code discovery |
| Context-aware generation | adapt_context_constraints() |
Translate building types to numeric constraints |
| Rate limiting + retry | _rate_limited_generate() |
Production-resilient API usage |
Path A — Real Blueprint Upload:
- User uploads an architectural blueprint image
- Gemini 3 Pro Vision analyzes the image against regulations
- Violations are annotated directly on the user's blueprint
- Correction recommendations are generated
- PDF compliance certificate is produced
Path B — Demo Mode (Synthetic Floor Plan):
- A parametric
FloorPlanis rendered with intentionally non-compliant dimensions - Gemini analyzes → detects violations → suggests corrected parameters
- Floor plan is re-rendered with corrections
- Loop continues until all checks pass
- User Upload — Extract text from uploaded PDFs via PyPDF2
- Web Discovery — Search for official building-code PDFs online
- Google Search Grounding — Gemini queries real-time web data for current codes
- Normalization — Gemini extracts structured
ComplianceRulesfrom raw text - Fallback — Regex-based extraction if Gemini is unavailable
44 countries with region-specific building codes:
🇺🇸 US · 🇬🇧 UK · 🇩🇪 Germany · 🇫🇷 France · 🇨🇦 Canada · 🇦🇺 Australia · 🇳🇱 Netherlands · 🇸🇪 Sweden · 🇳🇴 Norway · 🇩🇰 Denmark · 🇫🇮 Finland · 🇦🇹 Austria · 🇨🇭 Switzerland · 🇮🇹 Italy · 🇪🇸 Spain · 🇯🇵 Japan · 🇰🇷 South Korea · 🇸🇬 Singapore · 🇦🇪 UAE · 🇮🇳 India · 🇧🇷 Brazil · 🇲🇽 Mexico · 🇿🇦 South Africa · 🇳🇿 New Zealand · 🇵🇱 Poland · 🇨🇿 Czech Republic · 🇮🇪 Ireland · 🇧🇦 Bosnia & Herzegovina · 🇭🇷 Croatia · 🇷🇸 Serbia · 🇸🇮 Slovenia · 🇹🇷 Turkey · 🇸🇦 Saudi Arabia · 🇪🇬 Egypt · 🇳🇬 Nigeria · 🇰🇪 Kenya · 🇵🇭 Philippines · 🇹🇭 Thailand · 🇲🇾 Malaysia · 🇮🇩 Indonesia · 🇻🇳 Vietnam · 🇨🇳 China · 🇷🇺 Russia · 🇺🇦 Ukraine
MIT License — see LICENSE for details.
SiteWarden AI — Because buildings should be safe by design, not by accident.
Powered by Google Gemini 3 Pro