Conversation
There was a problem hiding this comment.
Pull request overview
This PR revamps the Admin “Center Stress” page into a command-center style UI by adding an interactive (SVG + d3-geo) map view and an AI insights panel, backed by new admin APIs for geo-enriched center stress data and AI insight generation via AWS Bedrock (with a local fallback).
Changes:
- Frontend: adds a new interactive center map + AI insights panel to the CenterStress admin page.
- Backend: adds
/api/admin/center-stress/geoand/api/admin/ai-insights, plus a Bedrock integration service and fallback insights generation. - Tooling/assets: introduces Leaflet-related CSS/dependencies and a large world TopoJSON asset.
Reviewed changes
Copilot reviewed 8 out of 11 changed files in this pull request and generated 22 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/pages/admin/CenterStress.tsx | Adds the new “command view” UI: SVG map, center popovers, and AI insights panel. |
| frontend/src/index.css | Adds (Leaflet-themed) global CSS, including a global import of Leaflet CSS. |
| frontend/src/assets/world-110m.json | Adds a large TopoJSON asset (currently unused by the code). |
| frontend/package.json | Adds mapping-related dependencies/types (Leaflet/react-leaflet/topojson-client/d3-geo). |
| frontend/package-lock.json | Lockfile updates for the new frontend dependencies. |
| frontend/fix_backticks.py | Adds a helper script intended to fix escaped template strings (currently has a syntax error). |
| backend/test_aws.py | Adds a quick AWS STS connectivity test script. |
| backend/test_ai.py | Adds a script to invoke the AI insights generator against a DB session. |
| backend/services/bedrock.py | Adds Bedrock invocation helper (Claude Messages API). |
| backend/routers/admin.py | Adds geo-enriched center stress endpoint and AI insights endpoint + fallback insight generation. |
Files not reviewed (1)
- frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Calculate transform for India map | ||
| const mapTransform = viewMode === 'india' && !isZooming | ||
| ? `scale(1) translate(0px, 0px)` | ||
| : `translate(\${mapWidth/2}px, \${mapHeight/2}px) scale(35) translate(\${-hydX}px, \${-hydY}px)` |
| const cfg = STRESS_COLORS[level] | ||
| return ( | ||
| <div key={level} style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 4 }}> | ||
| <div style={{ width: 10, height: 10, borderRadius: '50%', background: cfg.fill, boxShadow: `0 0 8px \${cfg.glow}` }} /> |
| </span> | ||
| </div> | ||
| <div style={{ fontSize: 11, color: '#94a3b8', marginTop: 3 }}> | ||
| {viewMode === 'india' ? 'Select region to inspect' : `\${centers.length} center\${centers.length !== 1 ? 's' : ''} monitored`} |
| </div> | ||
|
|
||
| {/* SVG Canvas */} | ||
| <svg width="100%" height="100%" viewBox={`0 0 \${mapWidth} \${mapHeight}`} style={{ position: 'absolute', inset: 0 }}> |
|
|
||
| {/* Hyderabad Interactive Node */} | ||
| <g | ||
| transform={`translate(\${hydX}, \${hydY})`} |
Comment on lines
+31
to
+33
| import os | ||
| if "AWS_SESSION_TOKEN" in os.environ: | ||
| del os.environ["AWS_SESSION_TOKEN"] |
Comment on lines
+58
to
+66
| response = client.invoke_model( | ||
| modelId=model_id, | ||
| body=body, | ||
| contentType="application/json", | ||
| accept="application/json", | ||
| ) | ||
|
|
||
| response_body = json.loads(response["body"].read()) | ||
|
|
Comment on lines
+820
to
+822
| open_emergencies = (await db.execute( | ||
| select(func.count(EmergencyCase.id)).where(EmergencyCase.case_closed == False) | ||
| )).scalar_one() |
Comment on lines
+903
to
+905
| import json as json_mod | ||
| insights = json_mod.loads(cleaned) | ||
| return {"source": "bedrock", "insights": insights} |
Comment on lines
+1
to
+14
| import boto3 | ||
| from config import settings | ||
|
|
||
| try: | ||
| client = boto3.client( | ||
| 'sts', | ||
| region_name=settings.AWS_REGION, | ||
| aws_access_key_id=settings.AWS_ACCESS_KEY_ID, | ||
| aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY, | ||
| ) | ||
| res = client.get_caller_identity() | ||
| print("SUCCESS: ", res['Arn']) | ||
| except Exception as e: | ||
| print("ERROR: ", str(e)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.