Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
6611a4a
capag-funder-scan: research, ETL, crosswalk + coverage probe
Jun 11, 2026
340e3be
capag-funder-scan: thin explorer UI — tier cards, search, UF filter, …
Jun 11, 2026
fe37c10
capag-funder-scan: adopt CityCatalyst design system
Jun 11, 2026
b3a5892
capag-funder-scan: city click-through + climate risk overlay
Jun 11, 2026
483b1f6
capag-funder-scan: merged multi-source inventory + multiselect filter…
Jun 11, 2026
7eb94dd
capag-funder-scan: Brazil map, contrast fixes, top-3 risks per row
Jun 11, 2026
8af32e2
capag-funder-scan: side-by-side layout + legend, clear-all, CSV expor…
Jun 11, 2026
7d5361e
capag-funder-scan: move search/state/matches to full-width row, short…
Jun 11, 2026
1d42ccb
capag-funder-scan: i18n EN/PT-BR via CityCatalyst's i18next stack
Jun 11, 2026
0273d85
capag-funder-scan: expanded city panel — boundary polygon, funded-pro…
Jun 11, 2026
c55951f
capag-funder-scan: fix city panel z-index over Leaflet map
Jun 11, 2026
c9f68d6
capag-funder-scan: weight project matching by emission share + show m…
Jun 11, 2026
444c72d
capag-funder-scan: move city polygon into the panel, loosen panel spa…
Jun 11, 2026
48a4149
capag-funder-scan: implement CityCatalyst dashboard iframe integration
lemilonkh Jun 12, 2026
34d8330
capage-funder-scan: implement pagination for city list
lemilonkh Jun 12, 2026
667eda8
capag-funder-scan: funder-mandate pipeline + catalytic-leverage cut (…
Jun 15, 2026
b957384
capag-funder-scan: real R$ credit-headroom magnitudes (RCL extraction…
Jun 15, 2026
3a43af0
capag-funder-scan: premium aurora onboarding carousel + info button
Jun 15, 2026
4f72c54
capag-funder-scan: fix PT overflow in mandate rail + explain ICF (car…
Jun 15, 2026
6c8a65b
Add CAPAG funder portfolio + deployable pipeline prototype
carole-88 Jun 15, 2026
c33db05
capag-funder-scan: Explore/Portfolio tabs + real tier×risk matrix + p…
Jun 15, 2026
d229f8f
capag-funder-scan: clarify the 'invisible to credit' matrix cells
Jun 15, 2026
8435a84
capag-funder-scan: active-filters banner in Explore (esp. matrix dril…
Jun 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
description: Match the CityCatalyst design system and stack in this app
globs: "**"
---

# CityCatalyst conventions for capag-funder-scan

This app mirrors the CityCatalyst frontend stack so it can graduate into a CC feature.

## Stack (same as CityCatalyst `app/`)
- **Chakra UI v3** (`@chakra-ui/react` + `@emotion/react`) — no Tailwind, no other UI libs
- Chakra v3 composite API: `Table.Root/Header/Row/Cell`, `NativeSelect.Root/Field`, `ChakraProvider value={system}`
- Fonts: **Poppins** (headings) + **Open Sans** (body), wired as CSS vars `--font-poppins` / `--font-opensans` via `next/font`

## Theme
`src/lib/theme.ts` is a trimmed copy of CityCatalyst's blue_theme tokens
(source of truth: `CityCatalyst/app/src/lib/theme/recipes/app-theme.ts`):

- `content.alternative` #001EA7 (headings), `content.link` #2351DC, `content.primary` #00001F,
`content.secondary` #232640, `content.tertiary` #7A7B9A
- `background.default` #FFFFFF, `background.neutral` #E8EAFB (page bg), `background.overlay` #C5CBF5
- `border.neutral` #D7D8FA
- `rating.*` — CAPAG tier colors, derived from CC sector palette

Always reference tokens (`color="content.tertiary"`), never raw hex in components.

## Data
- CAPAG: `data/capag.json` + `data/crosswalk.json` (regenerate with `scripts/*.py`, see README)
- CityCatalyst Global API patterns: see `research/data-access.md` — locodes are URL-encoded with
the space (`BR%20POA`); CCRA needs the scenario segment (`/current`)

## i18n (EN / PT-BR)
Mirrors CityCatalyst's i18next + react-i18next setup (`src/i18n/settings.ts`, `client.ts`,
`locales/{en,pt}/translation.json`). Two deliberate deviations for this single-route app:
static `resources` instead of `resourcesToBackend` lazy import, and no `LanguageDetector` at
init — server + first paint render `en`, then `LanguageToggle` applies the stored language in a
mount effect (avoids hydration mismatch; same idea as next-themes).

Rules:
- All user-facing strings go through `t("key")`; never hardcode copy in components.
- Keys are flat dotted strings, so init sets `keySeparator: false` / `nsSeparator: false`.
- Numbers: use `{{count, number}}` (i18next built-in Intl formatter, locale-aware: pt-BR `5.566`).
- The recommendation engine (`lib/recommend.ts`) returns i18n keys + vars, not prose, so EN/PT
both render from the same logic. Hazard-name vars are themselves `hazard.*` keys, resolved in
`CityPanel.renderLine` before interpolation.
- Audience is Brazilian funders — keep PT-BR fiscal terminology exact (Endividamento, Poupança
Corrente, Liquidez Relativa, garantia federal).

## If you add components
Check CityCatalyst `app/src/components/` first and copy/adapt rather than inventing new patterns
(e.g. tables, cards, tags). Local checkout lives at `work/oef/citycatalyst/repo` on Joaquin's machine;
otherwise https://github.com/Open-Earth-Foundation/CityCatalyst/tree/develop/app
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
.next/
data/capag-latest.xlsx
data/risks.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# CAPAG Funder Scan

> Brazil's Treasury rates every municipality's creditworthiness. CityCatalyst knows every municipality's emissions, climate risks, and priority actions. Nobody has ever joined the two — until now.

## Team

| Name | Role |
|------|------|
| Joaquin van Peborgh | Dev / Data |
| Carole Viaene | Research / Funder angle |

## What We're Building

A funder-facing scan of all 5,570 Brazilian municipalities that overlays **CAPAG fiscal capacity ratings** (Tesouro Nacional) with **CityCatalyst climate data** (emissions, climate risk, prioritized actions) — so climate funders like BNDES/CCFLA can segment the market and design the right instrument per city:

- **CAPAG A/B** (2,236 cities) → bankable: traditional credit lines + federal guarantees
- **CAPAG C** (2,316 cities) → locked out of federal credit → grant-first / blended finance
- **n.d.** (841 cities) → not even rated (broken accounting) → technical assistance first

## Revenue Connection

Funders' hardest question — "can this city actually absorb and repay climate finance?" — answered at a glance, powered by CityCatalyst data. OEF becomes the trust layer in the deal flow: screening for BNDES/CCFLA, premium scan + per-city investment briefs as a CityCatalyst feature.

## Status

- ✅ Deep research on CAPAG (see `research/` — reusable by other teams)
- ✅ ETL: latest Treasury XLSX → `data/capag.json` (5,568 municipalities, ratings + sub-indicators + ICF)
- ✅ Crosswalk: CAPAG (IBGE) ↔ CityCatalyst (LOCODE) via CCRA BR city list — **99.96% match** (5,566/5,568)
- ✅ Coverage probe: SEEG emissions + CCRA risk verified live for sampled cities in **every** CAPAG tier (32/32)
- ⏳ Product build

## How to Run

```bash
cd events/2026-06-11-unlock-the-money/apps/capag-funder-scan

# data pipeline
python3 scripts/fetch_capag.py # Treasury XLSX → data/capag.json
python3 scripts/probe_citycatalyst.py # crosswalk + coverage report
python3 scripts/fetch_risks.py # national CCRA snapshot → data/risks.json
python3 scripts/fetch_centroids.py # IBGE centroids → data/centroids.json
python3 scripts/fetch_projects.py # funded LatAm projects → data/projects.json

# app
npm install
npm run dev
# Open http://localhost:3000
```

## Demo Script (5 min)

1. [Problem: funders can't tell which Brazilian cities can absorb climate capital]
2. [The scan: 5,570 municipalities, CAPAG tier × climate signal]
3. [The "aha": 2,316 creditless C-cities with high climate need = the blended-finance market nobody can see]
4. [Revenue: screening service for BNDES/CCFLA, premium CityCatalyst feature]
5. [Next: per-city investment briefs, Siconfi live recomputation]

## Built With

- Cursor + Claude
- Next.js / React
- Tesouro Transparente CKAN (CAPAG, ODbL) · CityCatalyst Global API (SEEG + SINIR + SNIS + EPE merged inventory, CCRA risk)
- Chakra UI v3 with CityCatalyst design tokens (see `.cursor/rules/citycatalyst-style.mdc`)
- i18next (EN / PT-BR), CityCatalyst's i18n stack — toggle in the nav, full Portuguese for the Brazilian funder audience

## What We Learned

See `research/` — full verified findings on CAPAG methodology, data access, and gotchas.

## If This Survives the Hackday

- [ ] Per-city investment brief generator (CCFLA direct ask)
- [ ] HIAP prioritized actions in the overlay
- [ ] Live CAPAG recomputation from Siconfi API (TCE-ES-style, national)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading