Google Sign-In Required

Use your company Google account to access the BetterFleet private content.

Back to private home

BetterFleet Support Private
Skip to content
BetterFleet Dev Wiki
bf-digital-twin
Initializing search
    bf-dev
    • Home
    • Product Capabilities
    • Process
    • Current Work
    • System Design
    • Software Reference
    • Operations
    bf-dev
    • Home
      • Overview
      • Manage
      • Overview
      • Product Engineering Workflow
      • Product Engineering Delivery
      • Product Engineering Workflow in Linear
        • GitLab Feature Flags
        • In-App Docs Authoring
        • Release Notes
      • Templates
      • Publishing
      • Workflow Companions
      • Overview
      • Active Artifacts
      • Backlog Artifacts
      • Archived Artifacts
      • Overview
      • Microgrid
      • OSCP
        • Challenge
        • Specification
        • Spec
        • Architecture
        • Overview
        • Script Runtime Model
        • Compose Profiles and Modes
        • Repo Topology
        • CI and Release Integration
        • Overview
        • Internal Application Diagrams
          • Overview
          • Web Model
          • Core Model
        • Service Interaction Flows
        • Data and State
          • Index
          • bf-manage-web
          • bf-manage-core
          • bf-manage-connect
          • bf-manage-sitepwrmon
          • bf-manage-incidents
          • bf-telematics
          • bf-depot-sim
          • bf-manage-roaming
          • bf-support-microsite
          • bf-digital-twin
          • bf-schedule-creator
        • Overview
        • Internal Application Diagrams
        • Migration and Flags
        • Simulation Request Lifecycle
          • Index
          • bf-bnl-ui
          • bf-bnl-settings
          • bf-bnl-schedule-analysis-compute
          • bf-route-modelling
          • bf-schedule-creator
          • bf-digital-twin
            • What this service is
            • Code anatomy
            • Architectural characteristics
            • Documentation and tests in-repo
            • Internal request lifecycle
        • Overview
        • Secrets and Env Strategy
        • Vendors and Local Dependencies
        • ADRs
        • Service Matrix
        • Cloud Dependencies
        • Ports and URLs
      • Onboarding
      • Daily Operations Runbook
        • Overview
        • Staging Hotfix Release
        • Production Hotfix Release
        • Terraform Plan Dry Runs
      • Troubleshooting
      • Testing Guide
    • What this service is
    • Code anatomy
    • Architectural characteristics
    • Documentation and tests in-repo
    • Internal request lifecycle

    bf-digital-twin (Plan Role)¶

    What this service is¶

    bf-digital-twin is the target unified Plan backend for migration. It consolidates simulation, resource handling, modelling outputs, and selected ML-backed prediction endpoints.

    Code anatomy¶

    • src/app.py: FastAPI application assembly and lifecycle.
    • src/plan/adapters, src/plan/application, src/plan/domain, src/plan/models: DDD-style Plan core layers.
    • src/service/*: operational service modules for depot, trip, vehicle, geography, weather, charge-point, hvac.
    • src/output_service/*: prediction/output APIs (time_to_charge, range_remaining).
    • src/ml_models/*: model loading/estimator support.
    • src/old/*: legacy modules retained during migration period.

    Architectural characteristics¶

    • Hybrid architecture: newer DDD Plan core plus legacy-compatible service modules.
    • Supports migration path from distributed legacy stack to single-service orchestration.
    • Includes compatibility behavior to interoperate with legacy consumers during transition.

    Documentation and tests in-repo¶

    • Internal docs under docs/architecture.md and archived docs.
    • Broad test coverage across plan/*, service/*, output_service/*, and ml_models/*.

    Internal request lifecycle¶

    sequenceDiagram
      participant UI
      participant Api as fastapi app
      participant AppLayer as plan application layer
      participant Domain as plan domain layer
      participant Services as service modules
      participant Output as output service modules
      participant S3 as aws s3
      participant DDB as aws dynamodb
    
      UI->>Api: simulation or resource request
      Api->>AppLayer: invoke application use case
      AppLayer->>Domain: execute domain logic
      AppLayer->>Services: call service modules for data and modelling
      Services-->>AppLayer: computed results
      AppLayer->>Output: prepare output artifacts
      Output->>S3: persist run artifacts and outputs
      Output->>DDB: persist run metadata
      Api-->>UI: response payload
    Made with Material for MkDocs