How dmins06/petrotwin- works
PetroTwin is a Vietnamese fuel-market monitoring and next-adjustment forecasting platform. Its user workflow runs from market observations through a versioned forecast service to a dashboard showing prices, scenarios, and explanations; published actuals later support reconciliation. Separate automated collection and monitoring branches are documented capabilities. Several links are supported by the README or source-index references; unsampled implementation details are represented at directory level rather than inferred as specific calls.
Main entry points: service.py Forecast service · PetroTwinWorkspace.tsx Dashboard workspace · inference.py Forecast inference · main.py Forecast API
Components 23
Data collection
- Change detection
src/petrotwin/collectors/change_detector.py - Market collectors
src/petrotwin/collectors - Validation and publication
src/petrotwin/data/pipeline.py
Forecasting
- Feature engineering
src/petrotwin/features/pipeline.py - Verified model package
src/petrotwin/models/packaging/loader.py - Forecast inference
src/petrotwin/models/packaging/inference.py - Market scenarios
src/petrotwin/scenarios/scenario_engine.py - Model explanations
src/petrotwin/models/explainability/explanation_layer.py
API and persistence
- TiDB market data
src/petrotwin/db/tidb.py - Forecast API
backend/app/main.py - Forecast service
backend/app/service.py
Dashboard
- Frontend API client
frontend/src/lib/api.ts - Dashboard workspace
frontend/src/components/PetroTwinWorkspace.tsx - Market charts
frontend/src/components/MarketCharts.tsx - Forecast chart
frontend/src/components/PriceChart.tsx - XAI panel
frontend/src/components/XaiPanel.tsx - Monitoring views
frontend/src/components/MonitoringTables.tsx
Monitoring and evaluation
- Forecast log
src/petrotwin/monitoring/forecast_log.py - Actual reconciliation
src/petrotwin/monitoring/reconciler.py - Forecast monitoring
src/petrotwin/monitoring/mlops.py - Model evaluation
src/petrotwin/evaluation/model_benchmark.py
Other components
- Market sources
- Dashboard user
Connections 25
- Market sources → Change detection: fingerprints changes
README.md - Market sources → Market collectors: provides observations
README.md - Change detection → Market collectors: dispatches updates
README.md - Market collectors → Validation and publication: normalizes data
README.md - Validation and publication → TiDB market data: publishes observations
README.md - TiDB market data → Forecast service: reads market data
backend/app/service.py - Forecast service → Feature engineering: assembles forecast inputs
- Forecast service → Verified model package: loads active package
backend/app/service.py - Verified model package → Forecast inference: provides verified models
src/petrotwin/models/packaging/inference.py - Forecast service → Forecast inference: requests predictions
backend/app/service.py - Forecast inference → Market scenarios: runs scenarios
src/petrotwin/models/packaging/inference.py - Forecast inference → Model explanations: produces explanations
src/petrotwin/models/packaging/inference.py - Dashboard user → Forecast API: requests forecasts
README.md - Forecast API → Forecast service: routes requests
backend/app/main.py - Forecast service → Forecast log: logs forecasts
backend/app/service.py - Forecast API → Frontend API client: serves API data
README.md - Frontend API client → Dashboard workspace: fetches dashboard data
frontend/src/components/PetroTwinWorkspace.tsx - Dashboard workspace → Market charts: renders market views
frontend/src/components/PetroTwinWorkspace.tsx - Dashboard workspace → Forecast chart: renders forecast series
frontend/src/components/PetroTwinWorkspace.tsx - Dashboard workspace → XAI panel: renders explanations
frontend/src/components/PetroTwinWorkspace.tsx - Dashboard workspace → Monitoring views: renders monitoring
frontend/src/components/PetroTwinWorkspace.tsx - Forecast log → Actual reconciliation: supplies pending forecasts
src/petrotwin/monitoring/reconciler.py - Actual reconciliation → TiDB market data: matches actual prices
- Actual reconciliation → Forecast monitoring: updates monitoring
src/petrotwin/monitoring/reconciler.py - Model evaluation → Feature engineering: benchmarks models