BatteryForge AI

Inspiration

Battery failures cost industries billions annually and pose serious safety risks, from Samsung's Galaxy Note 7 recalls to Tesla's thermal runaway incidents. Traditional battery quality control relies on manual inspection, destructive testing, and reactive maintenance—all slow, expensive, and error-prone. We envisioned an AI-powered platform that could:

  • Detect defects visually before they escalate to catastrophic failures
  • Optimize charging strategies using physics-based simulation to extend battery life
  • Predict failures proactively using multimodal AI analysis
  • Coordinate specialist AI agents to handle the complexity of battery manufacturing and fleet management

The breakthrough came from Google's Gemini 3 API & Agent Development Kit (ADK), which enabled building a multi-agent orchestration system where specialized AI "experts" collaborate seamlessly—just like a real battery engineering team.

What it does

BatteryForge AI is a comprehensive battery intelligence platform powered by Gemini 3 and ADK multi-agent orchestration. It provides:

🎯 Core Features

1. AI Commander (ADK Multi-Agent Orchestration)

  • BatteryForgeCommander: Root agent that routes requests to 5 specialist agents
  • DefectAnalysisAgent: Visual inspection expert using Gemini Vision
  • ChargingOptimizationAgent: Electrochemistry and EIS analysis specialist
  • FleetCommanderAgent: Strategic fleet management and scenario simulation
  • SafetyGuardianAgent: Emergency response with Human-in-the-Loop (HITL) controls
  • PredictiveMaintenanceAgent: Lifecycle prediction and maintenance scheduling

2. Visual Intelligence

  • Real-time thermal runaway detection via webcam, screen share, or YouTube video analysis
  • "Detect-Locate-Describe" methodology for precise defect classification
  • PCB/BMS manufacturing defect detection (open circuits, shorts, solder mask issues)
  • Live streaming analysis with persistent audit trails

3. Charging Analysis & Physics Simulation

  • PyBaMM integration for Doyle-Fuller-Newman (DFN) physics-based battery simulation
  • Interactive multi-plot visualization with Recharts (voltage, current, temperature curves)
  • EIS (Electrochemical Impedance Spectroscopy) analysis with layer-by-layer diagnosis
  • Universal CSV parser that auto-detects data types (cycling, impedance, telemetry)

4. Fleet Monitor

  • Real-time monitoring of 100+ battery packs
  • Scenario simulation (heat waves, cold snaps, fast charging stress tests)
  • Strategic risk assessment with thermal spread analytics
  • Pack-level drill-down with maintenance recommendations

5. PCB Manufacturing Automation

  • Gerber file analysis for CAM validation
  • Adaptive etching control (conveyor speed, spray pressure optimization)
  • Lamination scaling prediction for multi-layer boards
  • Automated compliance certificate generation

6. RAG Knowledge Assistant

  • ChromaDB vector store with Gemini text embeddings
  • Ingests PDF manuals and technical documentation
  • Context-aware responses in chat interface
  • Semantic search across battery safety standards

How We built it

Architecture

Architecture Diagram

Backend (Python + FastAPI)

  • ADK Integration: Multi-agent orchestration with Runner.run_async event streaming
  • Services Layer: Modular services for vision, simulation, RAG, fleet management
  • Tools: 20+ specialized tools for agents (vision analysis, PyBaMM simulation, EIS processing)
  • Database: SQLite for analysis history, ChromaDB for vector embeddings

Frontend (React + Vite)

  • Modern UI: Framer Motion animations, glassmorphism, dark mode
  • Interactive Charts: Recharts for scientific data visualization
  • Real-time Features: WebSocket for live agent trace, streaming analysis logs
  • Components: 10+ specialized components (VisualScout, ChargingAnalysis, FleetMonitor, etc.)

Key Technologies

AI/ML Stack

  • Google Gemini 3 Flash Preview (multi-agent orchestration)
  • Google ADK (Agent Development Kit) for workflow coordination
  • Gemini Vision for multimodal defect detection
  • ChromaDB + Gemini Embeddings for RAG

Physics & Simulation

  • PyBaMM (Python Battery Mathematical Modeling) for DFN simulations
  • NumPy/Pandas for data processing
  • Custom EIS analysis engine following IEST standards

Frontend Stack

  • React 18 + Vite (fast development)
  • Recharts for scientific plotting
  • Framer Motion for premium animations
  • React Player for video analysis

Development Process

  1. Phase 1: Built core defect detection using Gemini Vision with "Detect-Locate-Describe" methodology
  2. Phase 2: Integrated PyBaMM for physics-based simulations and universal CSV parsing
  3. Phase 3: Developed Visual Scout with real-time webcam/screen share analysis
  4. Phase 4: Created PCB manufacturing workflows (Gerber analysis, etching control, plating optimization)
  5. Phase 5: Implemented RAG knowledge base with ChromaDB
  6. Phase 6: ADK Multi-Agent System—Migrated to full agentic architecture with 5 specialist agents

Challenges We ran into

1. ADK Tool Schema Generation

Problem: The ADK framework generates JSON schemas from Python function signatures. List parameters without proper type hints caused 400 INVALID_ARGUMENT errors:

GenerateContentRequest.tools[0].function_declarations[3].parameters.properties[video_frames].items: missing field

Solution: Standardized all function signatures to use List[str] from the typing module and ensured docstrings matched the type hints exactly. Updated all 20+ tool functions across the codebase.

2. Event Streaming Architecture

Problem: ADK's Runner.run_async returns an async generator of events, not a simple response object. The initial implementation tried to treat it like a synchronous API call.

Solution: Implemented proper async iteration with event collection:

async for event in self.runner.run_async(...):
    if event.actions.transfer_to_agent:
        # Collect agent transfers
    for fc in event.get_function_calls():
        # Collect tool calls
    if event.content and event.content.parts:
        # Collect streaming response text

3. Model Availability

Problem: Initially used gemini-3-pro-preview which wasn't available in the v1beta API, causing 404 NOT_FOUND errors.

Solution: Discovered gemini-3-flash-preview was available and optimized for tool calling. Migrated all 6 agents to use this model after verification.

4. PyBaMM Threading

Problem: PyBaMM's DFN solver is CPU-intensive and would block the FastAPI event loop, causing the entire backend to freeze during simulations.

Solution: Wrapped all PyBaMM calls in ThreadPoolExecutor with asyncio.run_in_executor() to offload physics calculations to worker threads.

5. Screen Share Video Analysis

Problem: YouTube videos can't be analyzed directly due to CORS. ReactPlayer can display them but can't provide raw frames for canvas capture.

Solution: Implemented getDisplayMedia() screen recording. When a user selects a URL video, the app prompts for screen share permission and analyzes the visible tab instead—a genius workaround for external video analysis!

6. Universal CSV Parsing

Problem: Battery research data comes in countless formats (Arbin cyclers, BioLogic EIS, Tesla telemetry). No single parser could handle them all.

Solution: Built a two-stage system:

  • Gemini-based semantic mapper: Analyzes headers and sample data to identify column meanings
  • Adaptive parser: Uses Gemini's mapping to standardize any CSV into canonical format

Accomplishments that we are proud of

🏆 Technical Achievements

  • First Fully Agentic Battery Platform: Successfully orchestrated 5 specialist AI agents using Google ADK, demonstrating real-world multi-agent coordination beyond simple chatbots.

  • Physics-Integrated AI: Bridged machine learning with electrochemistry by combining Gemini's reasoning with PyBaMM's physics-based DFN simulations—achieving both accuracy and explainability.

  • Real-Time Thermal Runaway Detection: Built a production-ready system that analyzes webcam/video feeds at 1 FPS for battery safety monitoring—potentially life-saving technology.

  • Universal Data Ingestion: Created a Gemini-powered intelligent parser that can understand and process any battery dataset format without manual configuration.

  • Zero-Shot PCB Defect Detection: Achieved reliable open circuit and short circuit detection using only Gemini Vision, no custom training required.

💡 Innovation Highlights

  • Screen Share Analysis: Novel approach to analyze YouTube thermal runaway videos by recording the browser tab
  • Interactive EIS Analysis: Layer-by-layer impedance diagnosis (Ohmic, Kinetics, Diffusion) following industry standards
  • Agent Trace Visualization: Real-time display of agent transfers and tool calls for transparency
  • Scenario Simulation: Fleet-level stress testing (heat waves, cold snaps) with physics-based degradation

📊 Scale Achieved

  • 20+ AI Tools across 5 specialist agents
  • 10+ React Components with premium UI/UX
  • 100+ Battery Packs simulated in fleet monitor
  • 6 Analysis Modes: Visual, Charging, Fleet, Logs, Aging, PCB

What We learned

Technical Learnings

  • Agent Architecture Patterns: Building scalable multi-agent systems requires careful separation of concerns. Each agent needs clear responsibilities and well-defined tool sets.

  • Event-Driven AI: Moving from request-response to event streaming fundamentally changes how you structure async code. ADK's event model is powerful but requires rethinking traditional API patterns.

  • Physics-AI Hybrid Systems: The best battery intelligence comes from combining data-driven AI (Gemini) with first-principles physics (PyBaMM). Neither alone is sufficient.

  • Type System Importance: Python type hints aren't just for IDE autocomplete—they're critical for automatic schema generation in frameworks like ADK.

  • Real-Time Vision Challenges: Analyzing live video at acceptable frame rates while maintaining accuracy requires careful optimization (canvas rendering, async processing, result caching).

Domain Knowledge

  • Battery Failure Modes: Deep understanding of lithium-ion degradation mechanisms (SEI growth, lithium plating, thermal runaway propagation)
  • EIS Interpretation: How to diagnose battery health from impedance spectra using frequency-domain analysis
  • PyBaMM Ecosystem: The DFN model's power and limitations, parameter sensitivity, computational costs
  • PCB Manufacturing: CAM workflows, Gerber file structure, etching chemistry, lamination physics

Product Design

  • Context-Aware AI: The best agent experiences provide workspace context (active tab, current data) automatically
  • Progressive Disclosure: Start with simple interfaces, reveal complexity on demand (e.g., multi-plot analysis)
  • Visual Feedback: Real-time status indicators and live traces build trust in AI systems

What's next for BatteryForgeAI

Short Term (1-3 months)

1. Enhanced Agent Capabilities

  • Add DataAnalystAgent for statistical trend analysis
  • Implement ComplianceAgent for UL/IEC standard verification
  • Add SupplyChainAgent for material sourcing optimization

2. Advanced Workflows

  • Marathon agents for long-running tasks (24-hour pack audits, continuous monitoring loops)
  • Workflow branching based on severity detection
  • Automated report generation for compliance

3. Hardware Integration

  • Direct BMS connection for live telemetry ingestion
  • Integration with thermal cameras for IR analysis
  • Support for EIS hardware (Gamry, BioLogic)

Medium Term (3-6 months)

1. Production Deployment

  • Multi-tenant architecture with enterprise auth
  • Cloud deployment (GCP with Cloud Run + Firestore)
  • REST API for third-party integrations

2. Advanced Analytics

  • Predictive maintenance scheduling with calendar integration
  • Anomaly detection using statistical process control
  • Fleet-level optimization (charging scheduling, load balancing)

3. Expanded Modalities

  • Audio analysis for battery cell venting detection
  • X-ray/CT scan analysis for internal defect detection
  • Acoustic emission monitoring for mechanical failures

Long Term (6-12 months)

1. Industry Adoption

  • Partnership with battery manufacturers for pilot deployment
  • Integration with fleet management platforms (Tesla, Rivian)
  • Certification for safety-critical applications

2. Research Extensions

  • Custom PyBaMM parameter fitting from experimental data
  • Physics-informed neural networks for hybrid modeling
  • Reinforcement learning for optimal charging policies

3. Ecosystem Growth

  • Open-source the agent framework for battery research community
  • Build marketplace for custom agents and workflows
  • Create educational platform for battery engineering training

Technical Stack Summary

  • AI & ML: Gemini 3 Flash Preview, Google ADK, ChromaDB, Gemini Embeddings
  • Physics: PyBaMM (DFN), NumPy, Custom EIS Engine
  • Backend: FastAPI, SQLite, Pydantic, ThreadPoolExecutor
  • Frontend: React 18, Vite, Recharts, Framer Motion, React Player
  • Deployment: Local (uvicorn + npm dev), Docker-ready

Lines of Code: ~15,000+ Development Time: 72 hours (hackathon sprint)
Powered By: Google Gemini 3 & ADK

NOTE: Kindly watch the extended video for witnessing all the cool features in-depth: https://youtu.be/NVNg9XcHVvA

Built With

Share this project:

Updates