Skip to content

bcshih/digital_earth_god

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

96 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ๆ•ธไฝๅœŸๅœฐๅ…ฌ Digital Earth God

็น้ซ”ไธญๆ–‡ | English

ไปฅ็ฅžๆ˜Ž็‚บๅ–ป็š„ๅคšๆ™บ่ƒฝ้ซ”็ณป็ตฑ๏ผŒๅฎˆ่ญทๅฐๅ—ไธญ่ฅฟๅ€็š„ๆ–‡ๅŒ–ๆŽข็ดข่ˆ‡็คพๅ€ๆฒป็†ใ€‚

A Multi-Agent System (MAS) that reimagines Tainan City's cultural heritage exploration through the metaphor of Taiwanese folk religion โ€” where a ๅœŸๅœฐๅ…ฌ (Earth God) orchestrates 20 ๅœฐๅŸบไธป (Street Guardians) to bid, debate, and negotiate the best travel itineraries and community insights for you.

๐ŸŒ Live Demo: https://digital-earth-god.netlify.app
(Backend on Railway ยท Frontend on Netlify)


โœจ Features

Flow Description WebSocket
๐Ÿงญ ๅ‘ๅœŸๅœฐๅ…ฌๅ•่ทฏ (Explore) Input your travel intent + GPS โ†’ 20 street guardians scout, bid, debate โ†’ Earth God judges and produces a multi-day itinerary with a Leaflet map /ws/explore/a2ui
๐Ÿ˜๏ธ ๅ•ๅœŸๅœฐๅ…ฌ (Community Ask) Ask a community question โ†’ guardians evaluate relevance, provide answers โ†’ Earth God consolidates a summary /ws/ask/a2ui
๐Ÿ›๏ธ ้‡Œ้•ทๅคงๆœƒ (Council) Raise a community topic โ†’ multi-round deliberation among guardians with support/oppose/question stances โ†’ Earth God delivers a verdict /ws/council/a2ui
๐Ÿ™ ๅ‘ๅœŸๅœฐๅ…ฌ่จฑ้ก˜ (Wish) Submit a prayer/wish to the Earth God /ws/wish

Key Highlights

  • Contract Net Protocol โ€” Decentralized task allocation: broadcast โ†’ scout โ†’ bid โ†’ debate โ†’ judge
  • A2UI (Agent-to-UI) โ€” Server pushes component trees + data patches over WebSocket; the frontend renders them with a generic renderer + domain-specific decorators (seal stamps, jiaobei divination, incense backgrounds)
  • 5 Agent Types โ€” ๅœŸๅœฐๅ…ฌ (orchestrator), 20ร— ๅœฐๅŸบไธป (street guardians), ่™Ž็ˆบ (Tiger God), ๅทกๅขƒไฝฟ (Patrol Officer), ไบ”็‡Ÿๅ…ตๅฐ‡ (Five Camps)
  • 20 Autonomous Street Agents โ€” Each guardian has real NLSC village boundary polygons (from official ่‡บ็ฃๅœ‹ๅœŸๆธฌ็นชไธญๅฟƒ shapefiles) and pre-loaded spatial data (POIs, history, social posts) for one neighborhood in Tainan's West Central District
  • Council: up to 15 participants โ€” Multi-round deliberation across the most relevant guardians; map stays at static overview (no per-statement zoom); compact inline transcript
  • Divine Personality โ€” Random "mood of the day" phrases inject personality into the Earth God's judgments
  • Theatrical UI โ€” Vermillion seal-stamp animations, jiaobei (ๆ“ฒ็ญŠ) divination reveals, incense smoke backgrounds, chat-room-style scout reports, and mobile-friendly slide-out panels
  • Cloud Deployed โ€” Backend on Railway (Docker/FastAPI), Frontend on Netlify (Next.js static export)

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    Frontend (Next.js)                โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ Explore  โ”‚  โ”‚   Ask    โ”‚  โ”‚ Council  โ”‚  โ”‚Wish โ”‚ โ”‚
โ”‚  โ”‚ /        โ”‚  โ”‚ /ask     โ”‚  โ”‚ /council โ”‚  โ”‚/wishโ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”ฌโ”€โ”€โ”˜ โ”‚
โ”‚       โ”‚ WS          โ”‚ WS          โ”‚ WS         โ”‚ WS โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”˜
        โ–ผ             โ–ผ             โ–ผ            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              FastAPI Gateway (:8080)                 โ”‚
โ”‚         apps/api/gateway.py                         โ”‚
โ”‚                                                     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                โ”‚
โ”‚  โ”‚  ๅœŸๅœฐๅ…ฌ Pipeline (ADK)          โ”‚                โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                  โ”‚                โ”‚
โ”‚  โ”‚  โ”‚RouterAgentโ”‚ โ†’ Top N agents   โ”‚                โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                  โ”‚                โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚                โ”‚
โ”‚  โ”‚  โ”‚ParallelAgent (Scout ร—20) โ”‚   โ”‚                โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚                โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚                โ”‚
โ”‚  โ”‚  โ”‚ParallelAgent (Bid ร—N)   โ”‚   โ”‚                โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚                โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚                โ”‚
โ”‚  โ”‚  โ”‚ParallelAgent (Debate ร—N)โ”‚   โ”‚                โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚                โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚                โ”‚
โ”‚  โ”‚  โ”‚LlmAgent (Judge)         โ”‚   โ”‚                โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚                โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚               โ”‚               โ”‚
        โ–ผ               โ–ผ               โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚         Swarm Server (:9000)                 โ”‚
โ”‚   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚   โ”‚็ฅž่พฒ่ก—โ”‚  โ”‚ๆตทๅฎ‰่ทฏโ”‚  โ”‚ๆญฃ่ˆˆ่ก—โ”‚ โ€ฆ  โ”‚ๅ…ฑ20้‡Œโ”‚  โ”‚
โ”‚   โ”‚:9001 โ”‚  โ”‚:9002 โ”‚  โ”‚:9003 โ”‚    โ”‚      โ”‚  โ”‚
โ”‚   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚        (A2A JSON-RPC endpoints)              โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Tech Stack

Layer Technology
LLM Google Gemini 3.1 Flash Lite
Agent Framework Google ADK (Agent Development Kit)
Agent Communication A2A Protocol (Agent-to-Agent)
Backend FastAPI + WebSocket ยท deployed on Railway (Docker)
Frontend Next.js 16 (Turbopack) + Motion (Framer Motion) + Leaflet ยท deployed on Netlify (static export)
Boundary Data Official NLSC shapefiles (ๅœ‹ๅœŸๆธฌ็นชไธญๅฟƒ) โ€” real village polygon coordinates
Data NGSI-LD inspired 5-layer model (spatial, dynamic, historical, citizen opinions, metadata)

๐Ÿ“ Project Structure

digital-earth-god/
โ”œโ”€โ”€ agents/
โ”‚   โ”œโ”€โ”€ tudigong/            # ๅœŸๅœฐๅ…ฌ (Earth God) โ€” orchestrator, judge, council chair, blessing
โ”‚   โ”‚   โ”œโ”€โ”€ agent.py         #   Contract Net pipeline, mood pool, community/council judge
โ”‚   โ”‚   โ””โ”€โ”€ blessing_agent.py#   Wish blessing agent
โ”‚   โ”œโ”€โ”€ dijizhu/             # ๅœฐๅŸบไธป (Street Guardians) โ€” 20 per-street agents
โ”‚   โ”‚   โ”œโ”€โ”€ agent.py         #   Scout, bidding, debate, community, council speaker agents
โ”‚   โ”‚   โ”œโ”€โ”€ a2a_server.py    #   A2A HTTP server (per street)
โ”‚   โ”‚   โ””โ”€โ”€ swarm_server.py  #   Launch all 20 A2A servers in parallel
โ”‚   โ”œโ”€โ”€ huye/                # ่™Ž็ˆบ (Tiger God) โ€” mock evidence adapter, A2A server
โ”‚   โ”œโ”€โ”€ wuying/              # ไบ”็‡Ÿๅ…ตๅฐ‡ (Five Camps) โ€” intent + wish categorizer agents
โ”‚   โ””โ”€โ”€ xunjingshi/          # ๅทกๅขƒไฝฟ (Patrol Officer) โ€” mock evidence adapter, A2A server
โ”‚
โ”œโ”€โ”€ apps/
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ””โ”€โ”€ gateway.py       # FastAPI gateway โ€” 4 WS endpoints, pipeline orchestration
โ”‚   โ””โ”€โ”€ web/                 # Next.js 16 frontend
โ”‚       โ”œโ”€โ”€ app/
โ”‚       โ”‚   โ”œโ”€โ”€ page.tsx           #   Explore (ๅ‘ๅœŸๅœฐๅ…ฌๅ•่ทฏ)
โ”‚       โ”‚   โ”œโ”€โ”€ ask/page.tsx       #   Community Ask (ๅ•ๅœŸๅœฐๅ…ฌ)
โ”‚       โ”‚   โ”œโ”€โ”€ council/page.tsx   #   Council (้‡Œ้•ทๅคงๆœƒ)
โ”‚       โ”‚   โ”œโ”€โ”€ wish/page.tsx      #   Wish (่จฑ้ก˜)
โ”‚       โ”‚   โ””โ”€โ”€ dashboard/page.tsx #   Dashboard (ๅŸŽๅธ‚้ขจๅ‘็ƒ)
โ”‚       โ”œโ”€โ”€ components/
โ”‚       โ”‚   โ”œโ”€โ”€ theater/           #   SealStamp, Jiaobei, IncenseBackground
โ”‚       โ”‚   โ”œโ”€โ”€ NegotiationBoard.tsx   # Compact bid/debate viewer with pagination
โ”‚       โ”‚   โ”œโ”€โ”€ ChatBubble.tsx         # Scout chat-room bubbles
โ”‚       โ”‚   โ”œโ”€โ”€ CouncilMap.tsx         # Reactive ้‡Œ boundary map (Leaflet, SSR-safe wrapper)
โ”‚       โ”‚   โ””โ”€โ”€ ResultMap.tsx          # Leaflet itinerary map
โ”‚       โ””โ”€โ”€ lib/a2ui/          # Generic A2UI renderer
โ”‚           โ””โ”€โ”€ Renderer.tsx
โ”‚
โ”œโ”€โ”€ deg/                       # Core library (pip install -e .)
โ”‚   โ”œโ”€โ”€ schemas/
โ”‚   โ”‚   โ””โ”€โ”€ contracts.py       #   Pydantic models (TaskBroadcast โ†’ CouncilVerdict)
โ”‚   โ”œโ”€โ”€ a2ui/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py        #   A2UI protocol (state, patches, builder)
โ”‚   โ”‚   โ””โ”€โ”€ surfaces.py        #   Component tree builders per flow (explore/ask/council/wish)
โ”‚   โ”œโ”€โ”€ adapters/              #   Sensor + social data adapters (่™Ž็ˆบ/ๅทกๅขƒไฝฟ evidence)
โ”‚   โ”œโ”€โ”€ warmdata/              #   SQLite wish store (deg/warmdata/store.py)
โ”‚   โ”œโ”€โ”€ mcp/spatial_db/        #   MCP spatial database for POI queries
โ”‚   โ””โ”€โ”€ seed/loader.py         #   Load 5-layer NGSI-LD agent data from JSON
โ”‚
โ”œโ”€โ”€ dijizu_agent/              # 20 li JSON data files (5-layer NGSI-LD per neighborhood)
โ”‚   โ”œโ”€โ”€ ไบ”ๆขๆธฏ้‡Œ.json           # โ€ฆ (20 files total)
โ”‚   โ””โ”€โ”€ โ€ฆ
โ”‚
โ”œโ”€โ”€ data/seed/
โ”‚   โ”œโ”€โ”€ streets.json           # Street / POI seed data
โ”‚   โ”œโ”€โ”€ sensor.json            # Sensor readings seed data
โ”‚   โ””โ”€โ”€ social.json            # Social / citizen opinion seed data
โ”‚
โ”œโ”€โ”€ tests/                     # 80+ unit tests (integration tests skip without API key)
โ”œโ”€โ”€ docs/                      # Design documents & feature plans
โ”œโ”€โ”€ scripts/demo.py            # CLI demo script
โ”œโ”€โ”€ start.ps1                  # One-click startup script (Windows)
โ”œโ”€โ”€ pyproject.toml             # Python project config
โ””โ”€โ”€ .env.example               # Environment variable template

๐Ÿš€ Quick Start

Prerequisites

  • Python โ‰ฅ 3.11
  • Node.js โ‰ฅ 20
  • Google Gemini API Key (Get one here)

1. Clone & Install

git clone https://github.com/bcshih/digital_earth_god.git
cd digital_earth_god

# Python dependencies
python -m venv .venv
.venv\Scripts\activate      # Windows
# source .venv/bin/activate  # macOS/Linux
pip install -e ".[dev]"

# Frontend dependencies
cd apps/web
npm install
cd ../..

2. Configure Environment

cp .env.example .env
# Edit .env and add your Gemini API key:
#   GOOGLE_API_KEY=your-gemini-api-key-here

3. Start Everything

Option A: One-click (Windows PowerShell)

.\start.ps1

This will start the Swarm Server, FastAPI Gateway, and Next.js frontend, then open your browser.

Option B: Manual (3 terminals)

# Terminal 1 โ€” Swarm Server (20 ๅœฐๅŸบไธป A2A agents)
python agents/dijizhu/swarm_server.py

# Terminal 2 โ€” FastAPI Gateway
uvicorn apps.api.gateway:app --host 127.0.0.1 --port 8080 --reload

# Terminal 3 โ€” Next.js Frontend
cd apps/web && npm run dev

4. Open Browser

Navigate to http://localhost:3000 and start exploring Tainan!


๐ŸŽฎ How It Works

Explore Flow (ๅ‘ๅœŸๅœฐๅ…ฌๅ•่ทฏ)

  1. You type a travel intent (e.g., "ๆˆ‘ๆƒณๆ‰พ่€ๅททๅผ„่ฃก็š„ๆ–‡้’ๅ’–ๅ•กๅปณ") and share your GPS location
  2. ๅœŸๅœฐๅ…ฌ broadcasts a TaskBroadcast to all 20 street guardians
  3. 20 Scouts quickly evaluate relevance (0-10 confidence score) โ€” results stream in real-time as chat bubbles
  4. Top N Guardians are selected and submit full BiddingProposal with POIs, fitness scores, and reasoning
  5. Debate Round โ€” Guardians critique each other's proposals and defend their streets
  6. ๅœŸๅœฐๅ…ฌ Judge โ€” The Earth God reads all bids + debates, applies today's divine mood, and produces a JudgmentResult with a curated multi-day itinerary
  7. ๆ“ฒ็ญŠ (Jiaobei) โ€” The verdict is revealed with a divination animation, followed by an interactive Leaflet map

Community Ask Flow (ๅ•ๅœŸๅœฐๅ…ฌ)

  1. Ask a community question (e.g., "ๆœ€่ฟ‘ไธญ่ฅฟๅ€ๆœ‰ไป€้บผๆดปๅ‹•๏ผŸ")
  2. Scouts evaluate which neighborhoods have relevant data
  3. Selected guardians provide detailed answers from their local data
  4. Earth God consolidates all answers into a unified summary

Council Flow (้‡Œ้•ทๅคงๆœƒ)

  1. Raise a topic for discussion (e.g., "ๆตทๅฎ‰่ทฏ็š„ไบค้€šๆ”นๅ–„")
  2. Up to 15 most relevant guardians join; up to 3 deliberation rounds
  3. Each guardian picks a stance (support / oppose / question / inform / silent) and speaks in โ‰ค 40 characters โ€” compact statements stream in real-time
  4. The council map highlights the speaking boundary in gold; stance colors update as the debate unfolds; response lines connect who is replying to whom
  5. Earth God delivers a final verdict summarizing consensus and disagreements

๐Ÿงช Testing

# Run all tests
pytest

# Run specific test files
pytest tests/test_schemas.py
pytest tests/test_gateway.py

Note: Gateway tests require google-adk to be installed. Schema tests run independently.


๐Ÿ› ๏ธ Utilities

The project includes a visual Agent Editor to easily manage and edit the JSON-LD NGSI-LD files of the 20 street guardians.

  1. Run the local backend: python scripts/agent_editor.py
  2. Open your browser to http://localhost:8081
  3. Select any neighborhood from the left sidebar to edit the agent's persona, boundaries, and add infinite "Local Observations". Changes are saved directly to the local files.

๐Ÿ“ Data Model

The system uses a standard JSON-LD graph structure based on NGSI-LD. Each neighborhood contains a dataset with multiple entities:

  1. VillageAgent: The core entity representing the neighborhood. Contains metadata (personality, name), spatial boundaries (GeoJSON polygons), and historical context.
  2. LocalObservation: Granular data points representing events, locations, or citizen feedback within the neighborhood. These are dynamically loaded into the agent's 5-layer knowledge base:
    • daily_activity, weather, new_shop โ†’ Layer 2 (Dynamic Activities)
    • poi, local_history โ†’ Layer 3 (Spatial & POIs)
    • citizen_feedback โ†’ Layer 4 (Citizen Opinions)

Note: To prevent LLM context overflow during parallel execution, the data loader (deg/seed/loader.py) intelligently truncates observations to the Top 15 most relevant entities per agent.

Key Schemas (Pydantic)

  • TaskBroadcast โ€” Intent + GPS + constraints broadcast to all agents
  • ScoutResult โ€” Quick confidence score (0-10) + one-line reason
  • BiddingProposal โ€” Full proposal with candidate POIs, fitness score, reasoning
  • DebateMessage โ€” Inter-agent debate text
  • JudgmentResult โ€” Final itinerary with ItineraryStop[], recommendation, reasoning
  • CommunityAnswer / CommunityQueryResult โ€” Community Q&A models
  • CouncilStatement / CouncilAlignment / CouncilVerdict โ€” Council deliberation models (stance: support/oppose/question/inform/silent)

๐ŸŽจ A2UI Protocol

The Agent-to-UI (A2UI) protocol decouples the agent pipeline from the frontend:

  1. Server pushes a component tree (JSON) defining the UI structure
  2. Server pushes data model patches as agent results arrive
  3. Frontend renders the tree with a generic Renderer component
  4. Decorators layer domain-specific presentation (animations, maps) on top

This allows the same agent pipeline to power different frontends (web, mobile, voice) without changing agent code.


๐ŸŒ Environment Variables

Variable Description Default
GOOGLE_API_KEY Google Gemini API key (required)
GOOGLE_GENAI_USE_VERTEXAI Use Vertex AI instead of AI Studio FALSE
NEXT_PUBLIC_GATEWAY_WS WebSocket URL for frontend ws://127.0.0.1:8080/ws/explore/a2ui

๐Ÿ“œ License

This project is part of an academic research initiative on multi-agent systems for smart city applications.


๐Ÿฏ ๅฐๅ—ใƒปไธญ่ฅฟๅ€ใƒปๆ•ธไฝๅœŸๅœฐๅ…ฌ ๐Ÿฏ
Built with Google ADK ยท A2A Protocol ยท Gemini ยท Next.js

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors