Smart methane leak detection and emissions intelligence for a synthetic oil and gas field.
MethaneGuard AI is a resume-ready full-stack project that simulates field sensors, detects abnormal methane patterns, localizes likely leak sources, estimates emissions/cost impact, and gives operators a dashboard for alerts, telemetry, sensor health, scenario testing, and compliance-style CSV exports.
Oil and gas operators are under pressure to reduce methane leakage and routine flaring while keeping production reliable. The IEA Global Methane Tracker 2026 reports that fossil fuel operations emitted about 124 Mt of methane in 2025, and the World Bank Global Gas Flaring Tracker reports 151 bcm of gas flared in 2024. MethaneGuard turns that industry problem into a demonstrable software and AI platform.
- Synthetic oilfield model with wellheads, pipeline segment, compressor station, separator, tank battery, fixed sensors, and a drone sensor.
- Live replay API that emits methane ppm, pressure, weather, wind, battery, and signal quality.
- Explainable anomaly detection using robust sensor baselines, methane excess scoring, and multi-sensor alert grouping.
- Geospatial leak localization with confidence scoring and nearest-asset attribution.
- Operator dashboard with KPI cards, field map, alert workflow, trend chart, sensor table, scenario injection, and emissions report.
- MethaneGuard Copilot chat assistant with live dashboard context, domain RAG, source citations, and offline demo mode.
- CSV export for daily or weekly emissions summaries.
- Backend tests for health, alert detection, clean scenario false positives, injected leak detection, and report export.
- Docker Compose and GitHub Actions CI.
- Frontend: React, TypeScript, Vite, Recharts, Lucide icons, custom CSS.
- Backend: FastAPI, Pydantic, Python simulation, analytics, and RAG modules.
- AI/RAG: OpenAI-compatible chat model,
text-embedding-3-smallembeddings, PostgreSQL + pgvector, hybrid retrieval, local fallback embeddings. - Data: Deterministic synthetic telemetry and local project/domain documents, no private industrial data required.
- Deployment: Docker Compose for local full-stack runs.
flowchart LR
A[Synthetic field assets] --> B[Telemetry simulator]
B --> C[FastAPI API]
C --> D[Anomaly scoring]
D --> E[Leak localization]
E --> F[React dashboard]
D --> G[Emissions report]
F --> H[Alert workflow]
J[Docs and PDF corpus] --> K[Embeddings]
K --> L[(pgvector)]
F --> M[MethaneGuard Copilot]
L --> M
C --> M
Backend:
cd backend
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
python scripts/ingest_knowledge.py
uvicorn app.main:app --reload --port 8000Frontend:
cd frontend
npm install
npm run devOpen http://localhost:5173.
docker compose up --buildOpen http://localhost:5173. The API runs at http://localhost:8000.
GET /health- API health check.GET /api/site- Synthetic field assets and sensors.GET /api/dashboard- Complete dashboard payload.GET /api/telemetry?hours=24- Raw readings and chart-ready time series.POST /api/scenarios- Inject a simulated leak and return detection results.PATCH /api/alerts/{alert_id}- Update alert status.GET /api/reports/emissions- JSON emissions report.GET /api/reports/emissions.csv- CSV emissions report.POST /api/chat- MethaneGuard Copilot chat endpoint.GET /api/copilot/sources- Indexed RAG source summaries.
Example scenario request:
{
"source_asset_id": "PIPE-4A",
"emission_rate_kg_hr": 55,
"duration_hours": 6,
"wind_shift_deg": 0
}Backend:
cd backend
pytestFrontend:
cd frontend
npm run buildCopy .env.example to .env for Docker Compose or export the variables locally.
OPENAI_API_KEY=...
OPENAI_CHAT_MODEL=gpt-5.4-mini
OPENAI_EMBEDDING_MODEL=text-embedding-3-small
DATABASE_URL=postgresql://methaneguard:methaneguard@localhost:5432/methaneguardWithout OPENAI_API_KEY, the app automatically runs in offline demo mode with deterministic local embeddings and fallback answers. That keeps tests and screenshots reproducible.
The detection model is intentionally explainable. It builds a robust baseline for each sensor, scores methane excess against expected variation, groups elevated sensors into a single incident, estimates the probable leak location, and converts estimated kg/hr into daily methane and value-at-risk metrics.
This is not a production LDAR system. It is a polished MVP that demonstrates full-stack product thinking, backend API design, AI-style anomaly detection, domain modeling, geospatial reasoning, and operator-centered UI.
- IEA: Global Methane Tracker 2026, https://www.iea.org/reports/global-methane-tracker-2026/key-findings
- World Bank: Global Gas Flaring Data, https://www.worldbank.org/en/programs/gasflaringreduction/global-flaring-data