Enterprise-grade, multi-agent ESG analytics platform for operational monitoring, financial risk scoring, compliance audit, final risk summarization, and explainable AI output.
This repository provides a production-friendly backend service built with FastAPI plus a Streamlit dashboard for business users.
- Executive Summary
- Core Architecture and Innovations
- System Design
- Technology Stack
- Installation and Operation
- API Endpoints
- Data and Output Lifecycle
- Folder Structure
- Deployment
- Security and Governance Notes
- Troubleshooting
The ESG Intelligence Platform addresses a common enterprise gap: ESG reporting is often retrospective, manual, and disconnected from real operational signals. This system introduces an automated, pipeline-driven architecture where specialized agents process ESG and financial signals in sequence and generate actionable outputs.
Key outcomes:
- Standardized ESG dataset generation from MongoDB
- Automated compliance evaluation across E, S, and G dimensions
- Deterministic risk scoring and alerting
- Explainability layer using SHAP for model-level transparency
- API-first integration model for dashboards and enterprise systems
The platform implements modular agents with clear responsibilities:
- Agent 1: Data extraction and normalization from MongoDB to standardized CSV
- Agent 2: ESG aggregation and financial risk feature enrichment
- Agent 3: Rule-based compliance audit (E, S, G and governance checks)
- Agent 4: Final risk score and alert classification
- Agent 5: Explainability using SHAP on trained model features
- Agent 1 Premium: Background premium data streaming with Socket.IO events
Outputs are generated in company-specific paths using environment-driven firm identification, enabling tenant-like separation for enterprise deployments.
Agent 2 can automatically trigger Agent 1 if prerequisite data is missing. This reduces operational friction and supports resilient execution flows.
Agent 5 does not only score risk; it surfaces top risk drivers through SHAP-based contribution summaries for audit and board-level reporting.
- API Layer: FastAPI routers exposing each agent capability
- Processing Layer: Python agent modules under agents/
- Data Layer: MongoDB source plus generated CSV outputs
- Model Layer: Serialized model artifact under models/
- Visualization Layer: Streamlit dashboard under dashboard/
- Realtime Layer: Socket.IO server for premium stream callbacks
- Agent 1 synchronizes and standardizes source records
- Agent 2 computes ESG and financial risk metrics
- Agent 3 evaluates compliance status
- Agent 4 calculates final risk score and alert level
- Agent 5 generates top risk factor explanation
Core expected fields include:
- Year
- Industry_Type
- E_Score
- S_Score
- G_Score
- ROA
- ROE
- Net Profit Margin
- Board_Independence (optional)
- Python 3.11+
- FastAPI
- Uvicorn
- python-socketio
- pandas
- scikit-learn
- joblib
- shap
- pymongo
- Streamlit
- Plotly
- python-docx
- python-dotenv
- Docker
- Python 3.11 or higher
- pip
- MongoDB access (local or Atlas)
git clone <repository-url>
cd ESG-Intelligence-Platformpython -m venv .venvWindows PowerShell:
.venv\Scripts\Activate.ps1Linux or macOS:
source .venv/bin/activatepip install -r requirements.txtIf you want to run the dashboard, ensure UI dependencies are installed:
pip install streamlit plotlyCreate config/.env and set:
MONGO_URI=mongodb+srv://<username>:<password>@<cluster-url>/?appName=<app-name>
MONGO_DB_NAME=company_database
MONGO_FIRM_ID=TECH001
MONGO_COLLECTION=raw_firm_datauvicorn API.main:app --host 0.0.0.0 --port 8000 --reloadHealth check:
curl http://localhost:8000/streamlit run dashboard/app.pyBase URL: http://localhost:8000
- GET / : API health message
- POST /agent1/sync : Pull, normalize, and persist operational output
- GET /agent1/companies : List available companies from MongoDB
- GET /agent2/process : Create ESG aggregate and financial risk output
- GET /agent3/audit : Generate E/S/G compliance verdicts
- GET /agent4/get-final-summary : Produce final risk score and alert level
- GET /agent5/explain : Return SHAP-based risk factor explanation
- POST /agent1-premium/start : Start premium listener thread and live emit events
Primary output pattern:
- outputs/<FIRM_ID>/<FIRM_ID>_agent1_operational_output.csv
- outputs/<FIRM_ID>/<FIRM_ID>_agent2_financial_output.csv
- outputs/<FIRM_ID>/<FIRM_ID>_agent3_compliance_output.csv
- outputs/<FIRM_ID>/<FIRM_ID>_agent4_final_output.csv
Model artifact:
- models/risk_model.pkl
ESG-Intelligence-Platform/
|-- API/ # FastAPI app, routers, database handlers
|-- agents/ # Core agent implementations and output routing
|-- config/ # Environment and schema configuration
|-- dashboard/ # Streamlit dashboard
|-- database/ # Mongo init and client helpers
|-- Dataset/ # Source dataset assets
|-- docs/ # Reference and report-source docs
|-- ML/ # Notebooks and ML experiment outputs
|-- models/ # Model training scripts and model artifacts
|-- outputs/ # Generated agent outputs (company scoped)
|-- scripts/ # Report generation scripts
|-- utils/ # Shared helpers, validators, scheduler
|-- requirements.txt # Python dependencies
|-- Dockerfile # Container build file
|-- README.md # Project documentation
Build image:
docker build -t esg-intelligence-platform .Run container:
docker run -p 8000:8000 --env-file config/.env esg-intelligence-platform- Provide all MONGO_* variables through platform secret management
- Persist outputs to object storage if container filesystem is ephemeral
- Add API gateway and authentication for enterprise production
- Add centralized logging and alerting before go-live
- Never hardcode credentials in code or notebooks
- Use least-privilege MongoDB users per environment
- Validate incoming payloads and enforce access controls at gateway level
- Keep an auditable trail of agent execution and generated reports
Cause: prior agent output does not exist.
Resolution: run upstream endpoints in order, or begin with /agent1/sync.
Cause: missing shap package, model file, or feature mismatch.
Resolution:
- Confirm models/risk_model.pkl exists
- Confirm input file contains all model feature columns
- Reinstall shap and restart API
Cause: invalid URI, network restrictions, or wrong DB/collection names.
Resolution:
- Validate MONGO_URI format
- Validate MONGO_DB_NAME and MONGO_COLLECTION
- Check Atlas IP allowlist or VPC rules
- Recommended execution order in scheduled jobs: Agent1 -> Agent2 -> Agent3 -> Agent4 -> Agent5
- Use isolated environments for dev, qa, and prod
- Track SLA metrics: sync latency, pipeline success rate, and explanation coverage
- Define incident playbooks for data-source failure and model drift events