A working drone power-line inspection platform on AWS, built as a proof of concept for a SaaS product. Drones fly real power lines, stream telemetry over MQTT and report defects. GridSafety carries every defect through the whole loop, from the drone to a repaired line and a costed report.
No sign-in needed: visitors get a read-only view of everything. Open Missions and pick a completed flight for its map, flight profile and findings; open Findings to follow a defect from detection to repair; open Reports for the costs.
86-second walkthrough, recorded from the app. Full-resolution MP4.
flowchart LR
A["✈ Fly<br/>battery-sized flights"] --> B["🔎 Detect<br/>defects + safety alerts"]
B --> C["⏱ Triage<br/>severity SLA, escalates"]
C --> D["📋 Schedule<br/>ranked by risk"]
D --> E["🚚 Dispatch<br/>nearest qualified tech"]
E --> F["🔧 Repair<br/>on real roads"]
F --> G["📊 Report<br/>labor, fuel, upkeep"]
At a glance
- Event-driven AWS backend, all infrastructure as code: IoT Core → Lambda → DynamoDB Streams outbox → EventBridge → Scheduler, SQS and SNS, about 100 resources in CDK (C#), deployed by GitHub Actions over OIDC with no stored keys. (Architecture)
- Live, and traceable end to end: changes are pushed to every open browser over API Gateway WebSockets the moment they're written, and X-Ray follows one finding from the drone's MQTT message to the on-call page with a single query. (Live push · Tracing)
- Real map data: 878 public OpenStreetMap power lines and about 19,700 towers (12 to 500 kV) across Contra Costa, Alameda and Solano counties; crew trucks drive real road routes. No non-public utility data is used.
- Operations logic from the field: flights split to a 20-minute battery and booked as outings, triage SLAs with escalation, work orders only to qualified, on-shift technicians nearest first, hours of service, a risk-ranked repair schedule, and trucks with seats, fuel and service intervals.
- Every hour costed: labor, flight crews, fuel and maintenance by day, week or month, from a rate card with dated pay history, all downloadable as CSV.
- Secure by default: Cognito roles enforced by the API, a separate read-only guest API with names removed, device identity taken from the MQTT topic, least-privilege IAM per function.
- Costs cents a month: pay-per-use services only, and nothing runs until someone clicks, so an idle deployment costs next to nothing. Ten CloudWatch alarms (the free tier) watch every failure path.
- Tested and shipped continuously: 254 .NET tests plus frontend tests on every push, then deploy and a smoke test against the live site.
Contents: Scope · What it does · Architecture · Design decisions · Run it locally · Deploy · Why I built this
Built with .NET 10 · ASP.NET Core Minimal APIs · AWS Lambda · IoT Core · DynamoDB · EventBridge (+ Scheduler) · SQS · SNS · S3 · Cognito · CloudFront · API Gateway WebSockets · X-Ray · AWS CDK (C#) · React 19 + TypeScript + Leaflet.
| Field crews on the roads | Reports: all activity, with costs |
|---|---|
![]() |
![]() |
| Finding with its drone capture | Findings work queue |
|---|---|
![]() |
![]() |
GridSafety is a proof of concept for a software-as-a-service product: one hosted platform that utilities and drone inspection contractors would subscribe to, instead of each building their own pipeline from drone to defect to repair. This repository is the first working slice. It runs as a single demo deployment with real public map data and simulated drones, defects and field crews, and it is built so the parts a paying customer would rely on (the event pipeline, the workflow rules, security and cost) are real rather than mocked.
Who it's for: utility asset-inspection and vegetation-management teams, drone service providers who inspect lines for several utilities, and smaller co-ops and municipal utilities without their own engineering team.
The problem: drone programs collect far more imagery than teams can review, and defects get lost between the inspection, the triage decision and the crew that fixes them. GridSafety covers that whole loop in one place: fly → detect → alert → triage on an SLA → dispatch the nearest qualified crew → repair → report.
| Question a buyer would ask | What's here |
|---|---|
| Can it take live drone data at scale? | MQTT telemetry through AWS IoT Core into an event-driven, serverless pipeline, with per-device identity, idempotent processing and out-of-order tolerance |
| Does it fit how operations actually work? | Flight-safety alerts, a triage queue with severity-based SLAs and escalation, work orders that go only to qualified, on-shift technicians nearest first, crew hours of service, trucks tracked per yard with crews riding together and nearby jobs chained onto the same trip, and an audit trail on every decision |
| Can managers see what happened? | Live ops map, KPIs, a mission overview and downloadable report per flight, flight logs and work reports for every drone, pilot, crew, truck and yard, by day, week or month (CSV) |
| Is it secure? | Cognito sign-in with role-based rights enforced by the API, a read-only guest view with names removed, least-privilege IAM per function, CI/CD through OIDC with no long-lived keys |
| What does it cost to run? | Pay-per-use AWS services only: an idle deployment costs close to nothing, and a budget alert watches spend (default $5/month) |
| Can it be operated? | Structured logs, business metrics, a CloudWatch dashboard, alarms on every failure path and dead-letter queue |
| Real | Simulated |
|---|---|
| Power lines and towers (public OpenStreetMap data, operator and owner tags removed) | Drones and their flights (the same pipeline a real drone would use) |
| Aerial photos of each structure (USDA NAIP, public domain) | Defect detection and the drone captures (badged SIMULATED) |
| Road routes for crew trucks (public OSRM routing) | Field crews, truck rolls and repairs (sped up: 1 s = 1 simulated minute) |
| The AWS architecture, security, alerting and CI/CD | People: every pilot and technician is fictional |
No non-public utility data is used anywhere in the project.
- Multi-tenancy: an organization per customer, with tenant-scoped data keys, sign-in, settings and storage, and per-tenant limits.
- Customer onboarding: importing each customer's own line and asset data (GIS exports) in place of OpenStreetMap, and their crews, yards and drone fleet.
- Real drones and detection: integration with drone vendors' fleet APIs, photo and video upload to S3, and a trained defect-detection model with a human review loop.
- Integrations: pushing work orders to the customer's work-management or EAM system, and enterprise single sign-on (SAML/OIDC).
- Field app: a mobile app for crews to accept jobs, navigate, record repairs and close work orders offline.
- Compliance: security certification (for example SOC 2), handling of critical-infrastructure data rules, and record-keeping for FAA drone operations.
- Billing: subscription plans and usage metering (for example by line miles inspected or by seat).
| Area | Behaviour |
|---|---|
| Live ops map | Circuits colored by voltage, structures, drones moving in real time, the active mission's flight track, and findings sized, colored and marked with a symbol by severity. |
| Flights sized to a battery | A drone battery is good for about 20 minutes in the air, so a line longer than one flight covers (about 15 km at cruise, after 2 minutes for climbing out, landing and reserve) is split into near-equal stretches at towers: 46 of the 878 lines take several flights, up to 7 for the 100 km Olinda–Tracy 500 kV. Each mission flies one stretch ("Flight 3 of 7, OT-082 to OT-123"), and its coverage, map and report cover that stretch. Planning offers the flight due next (one never inspected, else the one inspected longest ago, skipping any in the air), or any other; or tick several to book them as one outing (up to 6): the same drone and crew fly them back to back, swapping the battery between, so the API checks the drone has a charged pack for each and enough flight time before its next inspection, and refuses a flight someone else has booked. Simulating any flight of an outing flies the rest in order (on AWS each next flight is a fresh invocation of the DemoFlight Lambda, so an outing never hits one invocation's time limit). Simulated batteries drain by time in the air, so a full flight lands at about 22%. |
| Flight-safety rules | Every telemetry point is checked against low/critical battery (30% / 15%), the 120 m altitude ceiling (FAA Part 107), and the circuit's right-of-way corridor. An alert fires once per onset; a sustained condition does not page again. |
| Findings → work orders | New → Triaged → Assigned → Resolved, or Dismissed. A work order goes only to an on-duty technician (or whole crew) qualified for that defect type, and the picker lists them nearest depot first, so the closest qualified tech is the default; the API refuses anyone unqualified. Assigning sends a simulated truck (sped up) along real roads (public OSRM routing, straight-line fallback) to the site, repairs, closes the work order and drives back; the technician is busy meanwhile, except that a job within 15 km of where they already are can be lined up after their current one (up to 4 stops), so they drive on instead of returning. Trucks, their road ahead and an In the field panel show on the Operations map. Technicians work up to 8 h of driving and repairs per shift, then rest 10 h (sped up: 1 s = 1 min); jobs that would not fit are not offered, and a Crew shifts panel shows who is working or resting. On the map, Shift/Ctrl-click or drag a box (or use Select mode) to triage or assign several findings at once. Only Supervisors (Cognito group) may dismiss, which the API enforces as well as the UI. Every move is audited with who, when and a note. |
| Schedule | Repairs take far longer than inspection, so work backs up. The Schedule tab ranks every triaged work order nobody has been sent to yet: severity first (nothing jumps a more severe job), then a score for how risky the defect is (fire, outage or failure risk), the line's voltage, how long it has waited, and whether it's past its repair-by date (1 day for critical, 7 for high, 30 for moderate). Going down that list, each job is planned onto the qualified, on-duty technician who'd be done soonest, around the jobs they're already on, their 8 h shifts and 10 h rests, and when a truck is free at their yard, so lower jobs plan around higher ones. A timeline shows each technician's planned jobs from now until the backlog clears, and the table shows who, from which yard and truck, when they'd set off and finish, and anything that will miss its repair-by date or can't be planned at all. Signed-in users dispatch everything that can start now in one click (most important first, the plan redone before each, with the same checks as assigning by hand) or one job at a time. It runs only when clicked. |
| Resources | One place for the drone fleet, flight crews (remote pilots and visual observers) and ground crews. Supervisors add, edit and take things out of service. A drone in maintenance can't be planned, an off-duty crew takes no new work orders, and an edit that would orphan an open work order is refused. Each drone shows its live state, flight time and distance; each crew shows its missions or open work orders. Ground crews depart from depots (yards), and every yard has as many people as its trucks have seats (84 across 14 yards, each yard with a foreman-led yard crew alongside the specialist crews); each technician has their own skills and can depart from a different depot than their crew. Depots appear on the Operations map with who leaves from each. Reports: each drone and pilot has a flight log (missions, flight time, distance, findings, alerts) and each technician a shift report (hours, driving vs repairs, every job), all downloadable as CSV. Maintenance is simulated from what each asset has done: trucks burn fuel along their actual routes and fill up at the yard when they get back under half a tank, and go in for service every 300 road miles; drones fly on a rotation of battery packs that recharge after each flight and wear with every cycle (replaced under 70% health), with an inspection every 2 flight hours. Supervisors log repairs (in the shop for a set time, or until marked back) and services. Anything refueling, charging, in service or in the shop can't be dispatched or flown, and every refuel, swap, service and repair lands in the asset's maintenance log and in the reports. Reports have their own Reports tab, opening on All activity (the whole operation day by day: missions, flight time, findings found and triaged, field jobs, repairs, person-hours); or pick a truck, crew, technician, yard, drone, flight crew or pilot; each report has a shareable link, and the links on Resources open it there). Every report also breaks down by day, week or month (Pacific calendar days, Monday-start weeks): a chart of the chosen measure over the last 14 days, 12 weeks or 12 months, this period against the last, and a table of every period. Every report carries costs from one rate card in Core/Costs.cs (illustrative figures: $95 per technician person-hour, $140 per flight-crew hour of time in the air (distance flown at cruise speed, since demo flights play back 4× fast), $4.90 a gallon, plus service, inspection, battery pack and repair prices; a logged repair can carry its own cost). Each person on a crew has an Edit employee screen (supervisors only): name, role, yard and skills, an employee record (employee ID, hire date, phone, email, home city, emergency contact, certification and expiry, notes) and their own hourly rate in place of the standard one. Each change is kept in a dated rate history, so hours are costed at the rate in effect when they were worked and a raise never reprices past work. Guests never see employee records or pay. All activity totals labor, flight crews, fuel and maintenance by day, week or month, and the rates behind the numbers are listed alongside. |
| Email alerts | Supervisors choose which events email the on-call team (critical findings, overdue triage, critical flight alerts, mission complete), the finding severity threshold, and up to 10 recipients (user menu → Email alerts). The notifier Lambdas read the settings before every page. Recipients are SNS email subscriptions: each address gets a confirmation link from AWS, so nothing has to be verified in the account. |
| Triage SLA | Severity 5 must be triaged within 4 h, severity 4 within 24 h and severity 3 within 72 h. A one-time EventBridge Scheduler timer is set per finding. If the finding is still untriaged when the timer fires, it is escalated to the ops SNS topic. Triaging cancels the timer. |
| Paging | Critical drone alerts and severity 4–5 findings pass through an SQS buffer, then an idempotent notifier, then SNS (email/SMS/PagerDuty). |
| On-demand demo flights | A Supervisor presses Demo flight and a simulated drone flies one of the real lines for 2–4 minutes, through the same pipeline a real drone uses. Nothing runs on a schedule, so an idle deployment costs nothing. One demo flight at a time; a demo mission that stops reporting for 10 minutes is aborted automatically. Supervisors can also press Simulate flight on any planned mission to fly it the same way, under its own drone and pilot. At most 3 simulated flights are in the air at once. |
| Mission overview | One page per flight (#mission/<id>, linkable): coverage, distance, flight time, findings and alerts; a map of the line with inspected and missed towers, the flight path, findings and alert spots; altitude, battery and speed over the flight against their limits; every finding's capture; the alert timeline, status history and towers still to inspect. Live while the drone is up, and available to guests. |
| Mission reports | When a mission completes or aborts, a self-contained HTML report is written to S3: the track as SVG, findings with a capture of each, alerts, and any structures not inspected. Users download it through a presigned URL. |
| Defect images | Each finding gets a synthetic drone capture (SVG): the structure with the defect drawn in, the detector's bounding box and confidence, a GPS/time overlay, and a SIMULATED badge. Thermal hotspots render in an IR palette. Images are drawn from the finding's id, so they never change and nothing is stored; a real drone would upload photos to S3 instead. |
| Guest view | Signed-out visitors see the live site read-only: the map, flights, findings with their images, and reports. They use GET /api/public/*, which has no sign-in but only maps reads; names and emails in audit trails become "Ops user" and no actions are offered. Every write still goes through the Cognito JWT authorizer. |
| Ops KPIs | Active missions, drones flying, miles flown in the last 7 days, open findings by severity, overdue triage, and median hours to triage. |
flowchart TB
subgraph Drones
D["Drone or simulator"]
DEMO["DemoFlight λ<br/>on demand"]
end
subgraph Ingest
IOT["IoT Core<br/>topic rule"]
ING["DroneIngest λ"]
end
subgraph State
DDB[("DynamoDB<br/>single table")]
S3R[("S3<br/>mission reports")]
end
subgraph Workflow["Events and workflow"]
PUB["StreamPublisher λ<br/>outbox"]
BUS{{"EventBridge bus<br/>30-day archive"}}
SLA["SlaScheduler λ"]
SCH["EventBridge Scheduler<br/>a timer per finding"]
ESC["SlaEscalation λ"]
Q["SQS + DLQ"]
NOT["AlertNotifier λ"]
REP["MissionReport λ"]
end
subgraph Console["Ops console"]
U["React SPA"]
CF["CloudFront"]
SITE[("S3<br/>static site")]
APIGW["HTTP API<br/>Cognito JWT"]
API["ASP.NET Core λ"]
WS["WebSocket API<br/>live push"]
end
LIVE["LiveBroadcaster λ"]
SNS[["SNS<br/>on-call email"]]
OSRM["OSRM<br/>public road routing"]
D -- "MQTT gridsafety/drones/id/kind" --> IOT
DEMO -- "publishes like a drone" --> IOT
DEMO -. "next flight of an outing" .-> DEMO
IOT --> ING --> DDB
ING -- "DroneAlertRaised" --> BUS
DDB -- "stream, SK = META" --> PUB --> BUS
BUS -- "finding created / triaged" --> SLA --> SCH --> ESC --> SNS
BUS -- "critical alert, severity 4+" --> Q --> NOT --> SNS
BUS -- "mission completed / aborted" --> REP --> S3R
U --> CF --> SITE
CF -- "/api/*" --> APIGW --> API --> DDB
DDB -- "stream, META / STATE / CATALOG" --> LIVE -- "topic names" --> WS -. "push" .-> U
API -. "presigned download" .-> S3R
API -. "async invoke" .-> DEMO
API -. "truck routes" .-> OSRM
Every arrow out of the bus is at-least-once with its effect made exactly-once (idempotency keys, conditional writes, an Escalated flag), and every failure path ends in a DLQ or a Lambda error that a CloudWatch alarm watches. The design decisions below say why it's built this way.
The console doesn't ask the API for news every few seconds; the backend tells it the moment something changes.
- Every browser holds a WebSocket to an API Gateway WebSocket API.
$connectand$disconnectkeep one row per socket in the table (with a TTL, in case a disconnect is missed). - The LiveBroadcaster Lambda is a second consumer of the table's change stream, next to the outbox publisher. Its filter lets through only rows a screen shows: missions and findings (
META), drone positions (STATE) and the resource catalog (CATALOG). Telemetry points, visits and the socket rows never invoke it. - It turns a batch of writes into topic names,
{"topics":["drones","missions"]}, and posts that to every socket. - The browser refetches just the screens those topics feed, through the normal API.
The message carries no data, only what changed. Sign-in, roles and the guest view's redaction all stay in the HTTP API, so the socket can be open to anyone. Each screen refetches straight away on the first push and then at most once a second or so while a drone is flying, which keeps the call rate near the old polling during a flight and close to zero when nothing is happening. If the socket drops, the app goes back to its old polling until it reconnects. Locally, the API holds the sockets itself at /api/live and signals its own writes, so the same client code works with no AWS account.
Every Lambda runs with X-Ray active tracing (Powertools Tracing), and every AWS SDK call shows as a subsegment: the DynamoDB writes, PutEvents, CreateSchedule, the SNS publish. EventBridge carries the trace on to its rule targets, so the stream publisher, the SLA scheduler and the report generator join one trace.
Two hops start fresh traces by nature: a DynamoDB stream carries no trace context, and an EventBridge Scheduler timer fires hours after it was booked. So each hop also tags its segment with the ids it handled (findingId, missionId, droneId, detailType), and one X-Ray query follows a finding across all of them:
annotation.findingId = "01JD3…"
That returns the ingest that created it from the MQTT message, the outbox publish, the SLA timer being booked, the page to on-call and, if nobody triages it in time, the escalation. Batch handlers (the stream publisher, the SQS notifier) give each record its own subsegment, so a batch holding several findings still tags each one.
Here is a real one from the live demo: a supervisor triages a finding, the change is picked off the table stream, published to EventBridge, and carried by EventBridge into the SLA scheduler, which cancels the finding's deadline timer. Both functions had been idle, so the trace also shows their cold starts (Init); warm, the same chain takes about 280 ms.
Sampling. Lambda records the first request each second plus 5% of the rest, and that rate can't be changed for Lambda. A quiet action like a triage is recorded end to end. In the middle of a flight, when the ingest and the outbox run several times a second, some hops of a given finding go unrecorded, and EventBridge passes that "not recorded" decision on to what it triggers. For the hops X-Ray skipped, the logs fill the gap: every Powertools log line carries its xray_trace_id, and the outbox publisher and the SLA functions log the finding id on every event, so a Logs Insights search on the id across those log groups lists those hops whether or not X-Ray recorded them.
| Path | What |
|---|---|
src/GridSafety.Core |
Domain: missions, findings, workflows, flight rules, geo math, SLA policy, ingest service, DynamoDB + in-memory repositories |
src/GridSafety.Api |
ASP.NET Core Minimal API, which runs on Lambda and also locally with Kestrel |
src/GridSafety.Functions |
Event handlers: DroneIngest, StreamPublisher, SlaScheduler, SlaEscalation, AlertNotifier, MissionReportGenerator, the live-push LiveConnections and LiveBroadcaster, plus the on-demand DemoFlight, which chains an outing's flights |
tools/GridSafety.CircuitImport |
Pulls real power lines + towers from OpenStreetMap (Overpass API) and builds the circuit dataset |
tools/GridSafety.Simulator |
A drone that flies a circuit, with scripted incidents, posting to the local API or publishing to IoT Core |
web/ |
React ops console: live map, findings, missions, schedule, resources and reports |
infra/ |
AWS CDK app in C# (~100 resources) |
tests/GridSafety.Tests |
xUnit tests covering domain, ingest, events, SLA, paging, reports, OSM import, flight legs, scheduling, costs, staffing, live push and HTTP/RBAC (254 tests) |
- Device identity comes from the topic, not the payload. The IoT rule injects
topic(3) AS droneId, and the IoT policy only lets a Thing publish undergridsafety/drones/${ThingName}/*. A compromised drone cannot report as another drone. - Transactional outbox through DynamoDB Streams. State changes are written once. The stream publisher turns them into domain events, so there are no dual writes. A stream filter (
SK = META) keeps telemetry and idempotency records from invoking it at all. - Optimistic concurrency. Every entity carries a
Version, and writes are conditional. Concurrent telemetry and finding messages for one mission retry instead of losing updates (this is tested). - Out-of-order tolerant. The drone "shadow" only moves forward in time (
LastSeen <= :ts). Late MQTT QoS 1 redeliveries don't jump a drone backwards on the map. - At-least-once everywhere, effects exactly once. The SQS notifier uses partial batch responses and a DynamoDB idempotency key per event. SLA escalation is guarded by an
Escalatedflag, so a duplicate scheduler fire never pages twice. - Alert onset, not alert spam. Alerts fire on the transition into a condition. LowBattery is suppressed while CriticalBattery is active.
- Push a signal, pull the data. Live updates name what changed and the browser refetches it, instead of pushing the data itself. One code path serves every screen, nothing new needs securing, and a missed message is healed by the next refetch, so the broadcaster never retries.
- A second stream consumer, not more events. Live push reads the same table stream as the outbox, so it catches every write from every writer (ingest, API, escalations) without any of them knowing about browsers, and puts nothing extra on the event bus or its archive.
- Ops-grade observability. Powertools structured logs and a small set of EMF business metrics, alongside free AWS service metrics, feed a CloudWatch dashboard. Alarms cover Lambda errors, API 5xx, stream iterator age and every DLQ (10 in all, each failure path watched once), and all of them go to an SNS alarm topic.
- Least privilege. Each Lambda gets only the grants it needs. The scheduler role can invoke only the escalation function.
- Long work as a chain of short invocations. An outing of up to 6 back-to-back flights could outlast one Lambda invocation, so each flight's invocation starts the next itself (an async self-invoke, allowed by a narrowly scoped IAM grant). That keeps it serverless without Step Functions or a long-running container.
- Nothing runs until someone clicks. There are no cron jobs: demo flights, outings and schedule dispatch all start from a button. An idle deployment pays only for storage, and the alarms were trimmed to the 10 that CloudWatch gives free.
- Guests get their own read-only API, not a guest role.
/api/public/*maps only reads and removes names; every write sits behind the Cognito JWT authorizer. A misconfigured role can't turn a visitor into an operator. - History is costed as it happened. Pay rates keep a dated history, so hours are priced at the rate in effect when they were worked and a raise never reprices past work.
- Demo data migrates forward exactly once. The resource catalog is one versioned document with a seed version. A change to the demo roster (new yards, trucks, staff) is applied to the live data once, and never overwrites what supervisors have edited.
- Deterministic defect images. Each capture is drawn from the finding's id, so the same finding always looks the same and no image is stored.
Prerequisites: .NET 10 SDK and Node 20+.
dotnet run --project src/GridSafety.Api --launch-profile GridSafety.Apinpm --prefix web install && npm --prefix web run devdotnet run --project tools/GridSafety.Simulator -- --circuit PITT-MART-115 --speed 3Open http://localhost:5173 and watch the drone fly. Or skip the simulator: as a Supervisor, press Missions → Demo flight, and the API flies a demo drone over a random line in-process. In local mode the API uses an in-memory store and dev headers instead of Cognito. Use the Inspector / Supervisor switch in the header to see RBAC in action: only a Supervisor can dismiss a finding.
Simulator options: --list (show circuits), --circuit PITT-MART-115, --drone DRN-07, --speed 5, --seed 42, --no-incidents, --aws --mission <id>.
For reports with history behind them, start the API with four weeks of simulated operations instead (in-memory only): flights on most weekdays, the findings they turned up, triage, repairs dispatched to the nearest qualified technician with a free truck, refuels and services. It is seeded from a fixed number, so it looks the same every run. The screenshots above come from it.
dotnet run --project src/GridSafety.Api --launch-profile "GridSafety.Api (demo history)"To use DynamoDB Local instead of memory:
docker compose up -ddotnet run --project src/GridSafety.Api --launch-profile "GridSafety.Api (DynamoDB Local)"src/GridSafety.Core/Data/circuits.json is generated, not hand-written. In a utility this would be the scheduled GIS/asset-registry sync; here the importer plays that role:
dotnet run --project tools/GridSafety.CircuitImportIt queries the Overpass API for power=line|minor_line and town names inside a county boundary (default: --area "Contra Costa County"), clipped to a bounding box (--bbox s,w,n,e). --area none imports just the bounding box, e.g. --area none --bbox 37.92,-122.19,38.05,-122.03 for Martinez + Pleasant Hill. Operator and owner tags are stripped from the response before anything is saved. Then it:
- fills in missing voltages: about a third of the segments have no
voltagetag. An untagged line takes the voltage of the lines it continues, but only when they all agree, and distribution (minor_line) is never guessed. Anything still unknown is kept and shown as voltage not tagged; - groups segments by voltage and stitches them end to end, but only through two-way splices, so lines meeting at a substation stay separate circuits;
- clips each chain to the area, drops vertices less than 20 m apart (duplicate gantry nodes), and drops pieces under 400 m, which are almost always substation hookups (
--min-length 0keeps them); - names circuits from the OSM
name/reftags (a voltage already in the name, like 500KV, is normalized). Unnamed lines are named after the nearest town (Vine Hill 60 kV line A, idVH-60-A). It also sets the inspection corridor by voltage (60 / 75 / 100 m for 60 / 115 / 230+ kV); - keeps the OSM way and node ids on every circuit and structure, so each tower traces back to its source.
The current dataset has 878 circuits, about 3,079 km of line and 19,681 structures (about 4.5 MB): 21 at 500 kV, 170 at 230 kV, 135 at 115 kV, 52 at 60/69 kV, 7 tagged 12/21 kV feeders, and 493 with no voltage tag. Use --max <n> to keep only the longest lines.
The operations map stays responsive at county scale by drawing on a canvas and filtering by zoom: zoomed out it shows only the 230/500 kV backbone, 115 kV appears from zoom 11, everything else from zoom 13, and tower dots from zoom 14. Only lines inside the view are drawn, and the circuit a drone is flying is always shown with its towers.
Public Overpass servers are often busy, so a snapshot of the response is committed. Rebuild from it offline with:
dotnet run --project tools/GridSafety.CircuitImport -- --input tools/GridSafety.CircuitImport/data/contra-costa-overpass.jsonThe live dataset covers three counties (--area takes several, separated by commas). Their snapshot was fetched one county at a time and merged, since the public servers time out on the combined query:
dotnet run --project tools/GridSafety.CircuitImport -- --input tools/GridSafety.CircuitImport/data/east-bay-overpass.json --area "Contra Costa County,Alameda County,Solano County" --bbox 37.44,-122.45,38.55,-121.46Data © OpenStreetMap contributors, available under the ODbL. The map credits it.
Each finding's capture is shown over a real aerial photo of its structure: a 160 × 100 m frame (about 60 cm per pixel) of USDA NAIP orthoimagery from the USGS National Map, which is public domain. The detection box, camera overlay and defect are simulated, and the frame is badged SIMULATED and credits the imagery. An illustrated close-up is still available, since a top-down photo can't show an insulator.
An export takes 15–30 s, so it never happens on a page view. A FindingCreated rule invokes the AerialImagery Lambda, which fetches the frame while the drone is still flying and caches it in DynamoDB, once per structure (AERIAL#{structureId}). Opening an older finding starts the same fetch and the drawer shows a spinner until it's ready. Only the structure's public coordinates are sent to USGS.
dotnet test GridSafety.slnxnpm --prefix web testscripts/deploy.sh dev -c opsEmail=you@example.comThis publishes the Lambdas (linux-arm64, ReadyToRun), builds the SPA, and runs cdk deploy. After deploying:
- Create users in the Cognito pool and add supervisors to the
Supervisorsgroup. - Press Missions → Demo flight as a Supervisor to watch a simulated drone fly through IoT Core. It runs only when pressed and takes 2–4 minutes. To fly your own mission from your machine instead, attach the
SimulatorPolicyArnoutput to your IAM user, plan a mission in the console, then:dotnet run --project tools/GridSafety.Simulator -- --aws --drone DRN-07 --mission <missionId>
- Confirm the SNS email subscription to receive pages. The same
opsEmailalso gets AWS Budget alerts (see Cost below).
GitHub Actions: .github/workflows/ci.yml builds, tests and runs cdk synth on every push and PR. deploy.yml is run by hand (Actions → Deploy → Run workflow) and deploys through GitHub OIDC with no stored AWS keys (see docs/github-oidc.md).
Cost: everything is serverless and pay-per-request. With simulated drones only, a stack costs about $1–2 a month, mostly CloudWatch logs. Alarms are kept to 10, the always-free allowance. Demo flights run only on demand; each costs well under a cent (a few hundred IoT messages and Lambda invocations). CloudWatch custom metrics, often the surprise line item, are kept to 5 series, inside the always-free 10:
| Kept as custom metrics | Replaced by free AWS metrics |
|---|---|
| TelemetryPoints, FindingsReported, DroneAlerts, MessagesRejected, SlaEscalations | Pages sent → SNS NumberOfMessagesPublished; reports and SLA timers → Lambda Invocations; events published → logs; cold starts → Init Duration in the Lambda logs (Powertools CaptureColdStart would add one billed series per function) |
CostGuardTests fails the build if a handler turns cold-start capture back on or emits a metric that isn't on the list. The free allowance is per account, so other workloads in the same account share it.
Budget alert: when opsEmail is set, the stack also creates an AWS Budget (GridSafety-<stage>-monthly, default $5/month) that emails at 85% and 100% of actual spend, and as soon as the month's forecast goes over. It covers the whole account and only alerts; nothing is shut off. Change it with -c monthlyBudgetUsd=10, or -c monthlyBudgetUsd=0 to skip it (for example on a second stage in the same account).
I've spent the last couple of years supporting grid operations software (ADMS on-call/production support) at a large utility, and before that building DevOps automation, secure pipelines and integrations. GridSafety applies that experience to a growing problem for utilities: inspecting thousands of miles of line with drones and getting defects to crews before they become outages or ignition sources.
| Skill shown | Where |
|---|---|
| Production-support mindset: alerting, SLAs, runbook-friendly events | Flight rules, SLA escalation, paging, DLQ alarms, dashboard |
| Event-driven cloud architecture | IoT Core → Lambda → DynamoDB Streams → EventBridge → Scheduler/SQS/SNS |
| Infrastructure as code | infra/GridSafetyStack.cs (CDK in C#) |
| Secure CI/CD | GitHub Actions with OIDC, no long-lived keys |
| RBAC / identity | Cognito groups → JWT authorizer → API-enforced Supervisor rights |
| Automation and testing | Simulator with scripted incidents; 238 .NET tests + frontend tests |












