Final Submission: Integrated Digital Twin with responsive UI dashboard - #6
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR integrates a “digital twin” simulation and safety-intelligence generation endpoints into the FastAPI backend, and adds configuration to serve a frontend UI from the same service.
Changes:
- Adds global CORS middleware and mounts a static frontend at
/. - Introduces new
/intelligenceand/simulationAPI routers and wires them into the application. - Expands the interventions API with a POST endpoint for triggering interventions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| backend/app/main.py | Adds CORS middleware, includes new routers, and mounts the frontend static directory. |
| backend/app/api/simulation.py | Adds a digital-twin-backed simulation controller and endpoints, with optional intelligence fusion. |
| backend/app/api/interventions.py | Updates interventions routing and adds a POST endpoint accepting a request body. |
| backend/app/api/intelligence.py | Adds an intelligence generation endpoint backed by the RAG/LLM service layer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+25
to
+31
| app.add_middleware( | ||
| CORSMiddleware, | ||
| allow_origins=["*"], | ||
| allow_credentials=True, | ||
| allow_methods=["*"], | ||
| allow_headers=["*"], | ||
| ) |
Comment on lines
+5
to
8
| router = APIRouter( | ||
| prefix="/api/interventions", | ||
| tags=["Interventions"] | ||
| ) |
| from app.api.intelligence import get_intelligence_service | ||
| from app.schemas import RiskEngineInput | ||
|
|
||
| router = APIRouter(prefix="/api/simulation", tags=["simulation"]) |
Comment on lines
+10
to
+12
| # Setup paths for digital twin | ||
| BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) | ||
| sys.path.append(os.path.join(BASE_DIR, "digital twin")) |
| def _process_row(self, row: dict): | ||
| self.last_state = row | ||
|
|
||
| zone_ids = ["ZONE_A", "ZONE_B", "ZONE_C", "ZONE_D", "ZONE_E", "ZONE_F", "ZONE_G"] |
| import time | ||
| from typing import Dict, Any, List | ||
| from pathlib import Path | ||
| from pydantic import BaseModel |
Comment on lines
+160
to
+162
| class StartRequest(BaseModel): | ||
| scenario: str | ||
| speed: float = 1.0 |
| "alert_id": "ALT-" + str(int(time.time())) | ||
| }) | ||
|
|
||
| sim_ctrl = SimulationController() |
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.