Aurora refactoring#4
Merged
Merged
Conversation
…nalysis scenarios
- Configure Groq API key via .env file - Add python-dotenv to load environment variables automatically - Update app.py and Scenario_Analysis.py to load .env at startup - Fix model reference to llama-3.3-70b-versatile (correct available model) - Add .env to .gitignore for security - AURORA scenario simulator now fully operational for workforce planning
- Create visualization_service.py with 10+ Plotly chart types - Timeline impact, budget gauges, risk heatmaps for Prognosen - Knowledge transfer timelines, hiring priority rankings - Budget vs impact scatter plots for scenario comparison - Integrate visualizations into Scenario_Analysis page - Display charts alongside metrics for better insights - Support for gauge charts, bar charts, scatter plots, timelines Chart types: - create_timeline_impact_chart: Timeline delays visualization - create_budget_impact_chart: Budget gauge indicator - create_risk_gauge_chart: Risk scoring visualization - create_confidence_gauge_chart: AI confidence levels - create_alternatives_comparison: Alternative options chart - create_hiring_priority_chart: Priority ranking bars - create_hiring_impact_timeline: Project phase timelines - create_knowledge_transfer_timeline: KT phase breakdown - create_budget_vs_impact_scatter: Trade-off analysis
- Remove invalid 'suffix' property from direct Indicator config - Use 'number' dict with proper 'valueformat' instead - Add annotation layers for status labels (LOW/MEDIUM/HIGH/CRITICAL) - Fix create_budget_impact_chart gauge properties - Fix create_risk_gauge_chart gauge properties - Fix create_confidence_gauge_chart gauge properties - All gauge charts now render without Plotly errors - Charts use annotations to display risk level, budget status, confidence
- Update visualization_service.py: 'AI Confidence' → 'AURORA Confidence' - Update Scenario_Analysis.py: 'AI analyzing' → 'AURORA analyzing' - Update Scenario_Analysis.py: 'AI Reasoning' → 'AURORA Reasoning' - Update Scenario_Analysis.py: 'AI Recommendation' → 'AURORA Recommendation' - Update all spinner messages and metric labels - All 11 occurrences of generic 'AI' replaced with 'AURORA' - More branded and specific engine identification
…ntation - AURORA_PROJECT_ANALYSIS.md (15,000+ words) ├─ Complete project overview & business value ├─ System architecture (3-layer model) ├─ Component deep dive (each module explained) ├─ AURORA engine mechanics & prompt engineering ├─ Database schema with relationships ├─ Data flow analysis ├─ Technology stack details ├─ Integration points ├─ Prototype assessment (strengths & limitations) ├─ Roadmap to production (5 phases) ├─ Deployment architecture ├─ Testing strategy ├─ Security considerations ├─ Cost analysis (prototype vs production) └─ Appendix with glossary - AURORA_ARCHITECTURE_DIAGRAMS.md (10+ detailed diagrams) ├─ System architecture (3-layer model ASCII diagram) ├─ AURORA engine workflow (step-by-step execution) ├─ Data flow diagram (request/response cycle) ├─ Scenario flowchart (hiring delay example) ├─ Database relationship diagram ├─ Request/response cycle detailed ├─ Deployment architecture (current vs future) ├─ Component interaction diagram ├─ State management lifecycle ├─ AURORA decision tree └─ Mermaid-compatible ASCII diagrams Total documentation: - 25,000+ words - 15+ detailed diagrams - Complete technical reference - Business & technical documentation - Roadmap & cost analysis - Everything discussed in development
- Rename documentation files to use AURA prefix (whole tool) - Update README with comprehensive project description - Clarify AURA (resource planning platform) vs AURORA (AI scenario engine) - Fix file references in documentation - Add quick start guide and technology stack details
- Add ask_custom_question() method to AurorAI engine in scenario_engine.py - Supports 4 analysis types: standard, comparative, sensitivity, hypothesis - Flexible context building for custom questions - Add 'Ask AURORA Anything' tab to Scenario_Analysis.py - Build-specific prompts for each analysis mode (standard, comparative, sensitivity, hypothesis) - Display results with mode-specific formatting - Add confidence scoring and detailed reasoning for all custom queries - Validates user input and shows helpful error messages This allows users to ask complex workforce questions beyond the 5 predefined scenarios.
- Add JSON string sanitization to remove problematic control characters - Improve error recovery with regex-based newline handling - Update all prompts with explicit JSON formatting rules - Instruct Groq to escape all special characters properly - Replace multi-line strings with [BREAK] markers - Remove ellipsis from JSON examples that confuse models - Better error messages for API failures This fixes 'Invalid control character' errors in custom query mode.
PROBLEM: JSON parsing errors with complex responses from Groq
SOLUTION: Simplify everything to prevent escape character issues
Changes to scenario_engine.py:
- Rewrite _clean_json_string() with aggressive cleanup
* Remove invalid backslashes before non-escape chars
* Fix newlines within quoted strings
* Strip tabs and carriage returns
- Add _create_fallback_response() for graceful degradation
- Add _create_error_response() for consistent error handling
- Completely rewrite all 4 prompt builders (standard/comparative/sensitivity/hypothesis)
* Remove nested arrays and complex objects
* Use simple flat JSON structure (7-9 fields each)
* Explicitly forbid quotes/backslashes in values
* Much shorter, clearer instructions
Changes to Scenario_Analysis.py:
- Simplify custom query results display
* Remove array iteration (no more complex nested structures)
* Flat field access: result.get('answer'), result.get('risk'), etc.
* Mode-specific simple displays (no nested loops)
- Add fallback display for graceful error handling
- Display raw response for debugging if parse error occurs
Result: Custom queries now work reliably without JSON escape errors.
AURA restructured plus Scenario prediction engine (Aurora) added
added komponent editing feature and removed headcount error
Updated AI and Action plan
Updated README to reflect changes in project name and structure.
There was a problem hiding this comment.
Pull request overview
This PR introduces the AURORA AI scenario analysis feature into the Streamlit-based AURA resource planning app, adds supporting visualization + scenario engine logic, and improves master-data management UX while establishing baseline CI and unit tests.
Changes:
- Add AURORA “Scenario Analysis” page with Groq-backed scenario engine and Plotly visualizations.
- Extend Stammdaten Management with component edit + delete flows and introduce “backup” headcount handling.
- Add pinned dependencies, unit tests for core logic services, and a GitHub Actions workflow to run tests.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
ui/theme.py |
Adds navigation link to the new AURORA scenario page. |
pages/Scenario_Analysis.py |
New Streamlit UI for predefined scenarios + custom AI Q&A mode. |
logic/scenario_engine.py |
New Groq-based AURORA scenario engine (prompting, parsing, context builders). |
logic/visualization_service.py |
New Plotly chart helpers for scenario results. |
pages/Stammdaten_Management.py |
Adds component editing + deletion UIs and backup-aware requirement calculation. |
app.py |
Loads .env, adds executive-focus view, and updates component staffing calculations for backups. |
tests/test_team_service.py |
Unit tests for team service derived fields and override logic. |
tests/test_finance_service.py |
Unit tests for employee cost/FTE calculations and dataframe enrichment. |
tests/test_allocation_service.py |
Unit tests for allocation validation, IDs, and overallocation detection. |
requirements.txt |
Introduces pinned runtime + test dependencies. |
.github/workflows/tests.yml |
Adds CI job to run pytest on PRs and main pushes. |
.gitignore |
Adds .env to ignored files. |
.vscode/settings.json |
Simplifies VS Code Python env settings. |
README.md |
Expanded product documentation and quick-start instructions. |
QUICK_ACTION_PLAN.md |
Adds an action plan document for production hardening. |
CODE_REVIEW.md |
Adds a comprehensive code review document. |
AURA_PROJECT_ANALYSIS.md |
Adds detailed project analysis/architecture documentation. |
AURA_ARCHITECTURE_DIAGRAMS.md |
Adds architecture diagrams and system flow documentation. |
AI_EXPERIMENT.md |
Adds experiment notes/documentation for AURORA. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
830
to
835
| required_people = int(details.get("required_resources", st.session_state.component_requirements.get(component, 1))) | ||
| if details.get("backup_available", False): | ||
| required_people += 1 | ||
| transfer_time_months = int(details.get("knowledge_transfer_time_needed", st.session_state.component_transfer_times.get(component, 6))) | ||
| documentation_status = details.get("documentation_status", "Nicht bewertet") | ||
| backup_available = "Ja" if details.get("backup_available", False) else "Nein" |
Comment on lines
+160
to
+166
| result = aurora.simulate_hiring_delay( | ||
| component_name=selected_component, | ||
| delay_days=delay_days, | ||
| current_staffing=len([ | ||
| t for t in st.session_state.team_data | ||
| if selected_component in (t.get("components") or "").split(",") | ||
| ]) + (1 if comp_data.get("backup_available", False) else 0), |
Comment on lines
+3
to
+5
| from datetime import datetime, timedelta | ||
| import json | ||
| import os |
Comment on lines
+46
to
+69
| # Determine color based on impact | ||
| if budget_impact > 0: | ||
| delta_color = "red" | ||
| impact_label = f"+€{budget_impact:,.0f} (additional cost)" | ||
| else: | ||
| delta_color = "green" | ||
| impact_label = f"€{budget_impact:,.0f} (savings)" | ||
|
|
||
| fig = go.Figure(go.Indicator( | ||
| mode="gauge+number", | ||
| value=abs(budget_impact), | ||
| title={"text": f"💰 Budget Impact ({component_name})"}, | ||
| domain={"x": [0, 1], "y": [0, 1]}, | ||
| gauge={ | ||
| "axis": {"range": [None, abs(budget_impact) * 1.2]}, | ||
| "bar": {"color": delta_color}, | ||
| "steps": [ | ||
| {"range": [0, abs(budget_impact) * 0.3], "color": "lightgray"}, | ||
| {"range": [abs(budget_impact) * 0.3, abs(budget_impact) * 0.7], "color": "gray"} | ||
| ], | ||
| "threshold": { | ||
| "line": {"color": "red", "width": 4}, | ||
| "thickness": 0.75, | ||
| "value": abs(budget_impact) * 0.9 |
Comment on lines
+374
to
+385
| fig.update_layout( | ||
| title="📚 Knowledge Transfer Timeline", | ||
| xaxis_title="KT Phase", | ||
| yaxis_title="Weeks", | ||
| height=350, | ||
| hovermode="closest", | ||
| yaxis2=dict( | ||
| title="Cumulative Weeks", | ||
| overlaying="y", | ||
| side="right" | ||
| ) | ||
| ) |
Comment on lines
+846
to
+850
| json_str = response_text[json_start:json_end] | ||
| result = json.loads(json_str) | ||
| result["scenario_type"] = scenario_type | ||
| result["reasoning"] = response_text[:json_start].strip() | ||
|
|
Comment on lines
+692
to
+696
| # Find exits in next 12 months | ||
| exits_soon = [ | ||
| e for e in team_data | ||
| if e.get("days_until_exit", 999) < 365 | ||
| ] |
Comment on lines
+735
to
+739
| required = comp_data.get("required_resources", 1) | ||
| current = len([ | ||
| t for t in team_data | ||
| if comp in (t.get("components") or "").split(",") | ||
| ]) |
Comment on lines
+46
to
+49
| def required_with_backup(component: dict) -> int: | ||
| """Return required headcount including backup coverage if enabled.""" | ||
| base_required = int(component.get("required_resources", 1) or 1) | ||
| return base_required + 1 if component.get("backup_available", False) else base_required |
Comment on lines
+201
to
205
| # A flagged backup is treated as explicit additional coverage. | ||
| if component_details.get("backup_available", False): | ||
| active_count += 1 | ||
|
|
||
| required = int(st.session_state.component_requirements.get(component, 1)) |
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.