Skip to content

innovations in centers page - #6

Merged
sujaynsv merged 1 commit into
mainfrom
feat-r
Jun 6, 2026
Merged

sujaynsv merged 1 commit into
mainfrom
feat-r

Conversation

@rishitsura

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings June 6, 2026 17:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/geo and /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 thread backend/routers/admin.py
Comment on lines +820 to +822
open_emergencies = (await db.execute(
select(func.count(EmergencyCase.id)).where(EmergencyCase.case_closed == False)
)).scalar_one()
Comment thread backend/routers/admin.py
Comment on lines +903 to +905
import json as json_mod
insights = json_mod.loads(cleaned)
return {"source": "bedrock", "insights": insights}
Comment thread backend/test_aws.py
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))
@sujaynsv
sujaynsv merged commit e726db3 into main Jun 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants