Inspiration
Apartment roofs are some of the biggest empty surfaces in any city, and most of them are just sitting in the sun. When we asked why more of them don't have solar, the answer was simple: nobody knows which roofs are worth it. An owner won't pay for a site visit just to find out, and an installer can't visit every building in a city. The answers already exist, but they're scattered across a real-estate database, aerial photos and public weather records. We wanted one agent that could put them together and answer the question for a whole city in minutes.
What it does
Pick Houston or Los Angeles and click Find the roofs. CityLab's agent then:
- Pulls 50 apartment communities from CoStar, with units, lot size and the real owner.
- Follows the sun every 10 minutes for a full year, with NASA POWER cloud data.
- Traces every roof from Vexcel aerial data and splits sloped roofs into their real faces.
- Places real-size 400 W panels only on faces that get at least 80% of the best sun, with a 3 ft fire setback and room for rooftop AC units.
- Prices each site with NREL PVWatts, ranks them, builds the top 5 in 3D and drafts an email to the owner. The email is never sent.
Every step streams live into the page as the agent works. Across 43 Houston sites it found $5.87M a year in potential savings. The top site in Los Angeles saves about $531K a year and pays for itself in 5 to 8 years.
How we built it
- Agent: a DeepAgents (LangChain) orchestrator running on Amazon Bedrock. It plans with
write_todosand calls five tools, one for each stage of the pipeline. Every run is traced in LangSmith. - Backend: FastAPI streams each tool call to the browser as server-sent events. The frontend uses Three.js for the 3D roofs and Leaflet for the map.
- Sun model: the light on a panel at each sun position is calculated using:
I = Ib * max(cos(theta), 0) + Id * (1 + cos(beta)) / 2 + rho * Ig * (1 - cos(beta)) / 2
Where:
- I = total sunlight reaching the panel
- Ib = direct sunlight
- Id = diffuse sunlight
- Ig = global sunlight
- theta = angle between the sun and the panel
- beta = panel tilt angle
- rho = ground reflection coefficient (0.2)
We sum this over every 10-minute step of a typical day in each month, then keep only the roof faces that receive at least 80% of the best possible sunlight.
Roof selection rule:
E_face / E_best >= 0.8
- Money: for a system of P watts at an installed cost of c dollars per watt, producing E kWh a year at a power price of p dollars per kWh:
Payback (years) = (P * c) / (E * p)
We use:
- Installed cost: $1.80 to $2.40 per watt
- Houston electricity price: $0.09 per kWh
Los Angeles electricity price: $0.22 per kWh
- Never invent a number: the AI model only decides the order of the steps and writes the summary. Every number on the screen comes from a tool.
Challenges we ran into
- We pivoted halfway through. We started with research questions about parking and green space. Parking counts from aerial photos were too unreliable to trust, so we focused on the one question where the data is strong: solar.
- Sloped roofs are hard. A gable or hip roof isn't one surface. We had to split each outline into its real faces, each with its own direction, and build the 3D roofs so the faces meet at the ridges.
- Agents skip steps. Sometimes the model jumped ahead or stopped early. We added a guard: if the agent skips a stage, the backend runs it and labels it on screen, so a run never ends half-finished.
- Paid APIs and rate limits. Every Vexcel and NREL call is cached, so a repeat run costs nothing. Bedrock calls retry with adaptive backoff when they're throttled.
- Roof size is genuinely uncertain. Vexcel's footprints and CoStar's building records often disagree, so we show that openly instead of hiding it.
Accomplishments that we're proud of
- It matches NREL. Our sun model agrees with NREL PVWatts within a median of 1.9% in Houston and 3.3% in Los Angeles, and both pick the same best roof.
- It matches reality. On 53 Los Angeles homes that already have solar, Vexcel's panel detector found the real panels. On the median home, 95% of the panel area sits on faces CityLab recommends. No installed panels sit on faces we rate below 60% of the best sun.
- One click, start to finish: from "which roofs?" to a ranked list, 3D models and owner emails.
- 439 automated tests.
What we learned
- The hardest part of an AI agent isn't the model, it's making every step trustworthy. Giving the model tools that return real numbers, and never letting it make numbers up, made the whole system easier to believe.
- Validating against real installations taught us more than any amount of tuning.
- Simple physics, applied carefully, gets surprisingly close to the government's own solar model.
What's next
- Model shade from neighbouring buildings and trees.
- Let users correct a roof in the solar view, and feed those corrections back into the model.
- Add more cities beyond Houston and Los Angeles, and include local incentives and tax credits.
- Send the owner email for real, with the owner's approval.
Built With
- amazon-bedrock
- claude
- costar
- css3
- deepagents
- fastapi
- gsap
- html5
- javascript
- langchain
- langgraph
- langsmith
- leaflet.js
- nasa-power
- nrel-pvwatts
- numpy
- pandas
- pydantic
- pytest
- python
- shapely
- statsmodels
- three.js
- uvicorn
- vexcel