Agentic Scope 3 Stage 2: Quantification (LCA) module.
Current MVP supports:
- CSV ingestion → normalized storage (
activity_rows) - LCA compute → factor mapping + deterministic emissions + DQS (
inventory_items) - Hotspots + gap detection (emissions-based)
- Finance-grade primitives: append-only run history + item versions + adjustment restatements + factor overrides w/ approvals
Docs:
docs/DEVELOPMENT.mddocs/API.mddocs/DATA_MODEL.mddocs/TESTING.mddocs/MATURITY_GAP_ANALYSIS.mddocs/CALCULATOR_TEST_MATRIX.mddocs/TRACEABILITY.mddocs/SWARM_ORCHESTRATION.md
Create backend/.env (or export env vars):
MONGO_URL(required)DB_NAME(required)CORS_ORIGINS(optional, comma-separated; default*)MAX_UPLOAD_MB(optional; default20)MONGO_INSERT_CHUNK_SIZE(optional; default1000)LCA_FACTORS_PREFETCH_LIMIT(optional; default5000)LCA_FACTOR_CANDIDATES_K(optional; default3)LCA_VECTOR_STORE(optional;mongodefault;chromaoptional)PINECONE_API_KEY,PINECONE_INDEX(optional; required only whenLCA_VECTOR_STORE=pinecone)LCA_HASH_DIMS(optional; default512; must be integer in[64, 4096])
Vector-store fallback semantics:
- If
vector_storeis explicitly provided in request payload (/api/lca/factors/indexor/api/lca/factors/search), the backend is strict and returns an error when that store is unavailable/misconfigured. - If
vector_storeis omitted and defaulted from env (LCA_VECTOR_STORE), optional-store availability/config errors (501/502) automatically fall back tomongofor reliability.
cd backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn server:app --reload --port 8000GET /api/health-ish pingPOST /api/ingestion-jobs/upload(multipartfile; optionalcolumn_mapJSON form field)GET /api/ingestion-jobslist recent jobsGET /api/ingestion-jobs/{job_id}job detail/statusGET /api/ingestion-jobs/{job_id}/preview?limit=25&offset=0paged previewPOST /api/lca/ingestPRD-aligned alias of uploadPOST /api/lca/computecreateinventory_items(maps to mock factors + deterministic emissions + DQS)GET /api/lca/inventory?job_id=...paged inventory ledgerGET /api/lca/hotspots?job_id=...vendor pareto (by emissions by default)GET /api/lca/gaps?job_id=...high-impact, low-DQS items (emissions by default)GET /api/lca/summary?job_id=...last run summaryGET /api/lca/runs?job_id=...list run history (append-only)GET /api/lca/summary/as-of?job_id=...&run_id=...immutable replay totals for a runPOST /api/lca/period/closeclose a period (blocks recompute unlessforce=true)GET /api/lca/inventory/versions?job_id=...&ledger_key=...version history for a ledger rowGET /api/lca/overrides?job_id=...list factor override requestsPOST /api/lca/overrides/createcreate a pending factor override requestPOST /api/lca/overrides/reviewapprove/reject an override (applies to current view)POST /api/lca/adjustments/createcreate an adjustment restatement for a ledger rowGET /api/lca/adjustments?job_id=...list adjustmentsPOST /api/lca/factors/searchfactor search (regex/semantic)POST /api/lca/factors/seedseed a small mock EF library (only if empty)POST /api/lca/factors/importimport a packaged EF catalogPOST /api/lca/factors/indexbuild local semantic indexPOST /api/lca/primary-data/upsertadd supplier-specific PCF (upgrades methodology)POST /api/material-iros/upsertupsert material IROGET /api/material-iros?job_id=...list material IROsPOST /api/fx-rates/upsertupsert FX rateGET /api/fx-rates?...get FX rate
Create frontend/.env:
REACT_APP_BACKEND_URL=http://localhost:8000cd frontend
yarn
yarn start- Open
http://localhost:3000/ingest - Upload a CSV or XLSX with required headers:
vendor,description,spend,currency - You’ll be routed to
/jobs/:jobIdfor preview; click Compute LCA to populate emissions + DQS + hotspots/gaps