How orenh57/test2 works
Purpose and runtime entry points
CereBI is a tenant-scoped operational digital-twin and intelligence platform. Operational source data is ingested, mapped into a MongoDB-backed twin, then queried by console APIs and bounded calculation workflows. Production runtime starts through the FastAPI application factory at src/cerebi/app/backend/server.py, with composition/lifecycle wiring in src/cerebi/app/backend/composition/application_factories.py and src/cerebi/app/backend/composition/lifespan.py. The browser UI is a React/Vite SPA rooted at src/cerebi/app/frontend/src/main.jsx.
Application boundary and UI
The backend is the sole browser-to-data HTTP boundary; browsers do not access MongoDB. Route modules expose domains including analytics, twin/object browsing, tenant administration, configuration, and task execution: src/cerebi/app/backend/routes/analytics.py, src/cerebi/app/backend/routes/object_browser.py, and src/cerebi/app/backend/routes/task_execution.py. The frontend consumes these APIs through src/cerebi/app/frontend/src/api/client.js; major operational views include src/cerebi/app/frontend/src/pages/DigitalTwinExplorerPage.jsx and src/cerebi/app/frontend/src/pages/WorkbenchPage.jsx. Built frontend assets are served by the backend, while Vite is a separate development runtime.
Composition, tenancy, and authorization
app owns dependency composition and tenant scoping, keeping data and intelligence implementation-independent. Tenant access and configuration are composed in src/cerebi/app/backend/composition/tenant_access.py and src/cerebi/app/backend/configuration.py. Backend workflows translate HTTP operations into domain reads or commands, notably src/cerebi/app/backend/workflows/tenant_catalog.py, src/cerebi/app/backend/workflows/data_operations.py, and src/cerebi/app/backend/workflows/task_execution.py. Analytics-specific and loopback security controls sit at src/cerebi/app/backend/security/analytics.py and src/cerebi/app/backend/security/loopback.py.
Digital twin ingestion and persistence
The data subsystem transforms external sources into normalized twin objects and relationships. Ingestion supports spreadsheet/Drive CSV synchronization and snapshot loading through src/cerebi/data/ingestion/sync_worker.py, src/cerebi/data/ingestion/spreadsheet_ingestion.py, and src/cerebi/data/ingestion/twin_snapshot_loader.py. Object-model mapping and validation form the source-to-twin boundary in src/cerebi/data/object_model/loader.py, src/cerebi/data/object_model/config_mapper.py, and src/cerebi/data/object_model/validation.py. Twin documents and relationships are stored and queried via src/cerebi/data/storage/twin_storage.py, src/cerebi/data/storage/twin_relationships.py, and src/cerebi/data/relationships/twin_map_mongo.py.
External inputs and infrastructure
MongoDB is the operational system of record for tenant configuration, twins, registry state, and persisted intelligence results. The only production Mongo driver-construction boundary is src/cerebi/foundation/mongo/provider.py, configured through src/cerebi/foundation/mongo/configuration.py. Aurora/RDS support is an explicit read-only source adapter in src/cerebi/data/storage/aurora.py, not a normal request-path dependency. Weather enrichment integrates NWS and Open-Meteo through src/cerebi/data/inputs/weather/nws.py and src/cerebi/data/inputs/weather/openmeteo.py.
Intelligence execution pipeline
Intelligence is configured by a model/task registry, then executes capabilities against twin-derived inputs. Bootstrap assembles tenant/client frameworks and validates registry configuration in src/cerebi/intelligence/bootstrap/container.py, src/cerebi/intelligence/bootstrap/registry_config.py, and src/cerebi/intelligence/registry/service.py. The calculation runner resolves inputs, guards execution, invokes adapters, finalizes results, and supports caching/locking: src/cerebi/intelligence/calculation/runner.py, src/cerebi/intelligence/calculation/resolution.py, and src/cerebi/intelligence/calculation/result_finalization.py. Capability adapters include route-delay scoring at src/cerebi/intelligence/capabilities/route_delay/adapter.py and relationship ranking at src/cerebi/intelligence/capabilities/relationship_ranking/adapter.py.
Results, impact, and recommendations
Completed calculations can persist results, write twin-facing outputs, evaluate impact configuration, and generate recommendations. These boundaries are represented by src/cerebi/intelligence/persistence/mongo/store.py, src/cerebi/intelligence/twin/result_sink.py, src/cerebi/intelligence/impact/engine.py, and src/cerebi/intelligence/recommendation/service.py. Memory and no-op implementations across these subsystems provide non-production or isolated execution modes; Mongo implementations are the durable runtime path.
Main entry points: runner.py Calculation runner · twin_storage.py Twin storage · application_factories.py App composition · task_execution.py Backend workflows
Components 23
Browser UI
- React/Vite SPA · Operational console; production assets are served by the backend.
src/cerebi/app/frontend/src/main.jsx - API client
src/cerebi/app/frontend/src/api/client.js
Application
- FastAPI server · Sole browser-to-data HTTP boundary.
src/cerebi/app/backend/server.py - App composition · Builds application services and lifecycle dependencies.
src/cerebi/app/backend/composition/application_factories.py - Tenant access · Composes tenant access and configuration.
src/cerebi/app/backend/composition/tenant_access.py - HTTP routes · Exposes analytics, twin browsing, and task execution.
src/cerebi/app/backend/routes/analytics.py - Backend workflows · Translates HTTP operations into twin reads, commands, and tasks.
src/cerebi/app/backend/workflows/task_execution.py - Analytics security · Analytics and loopback execution controls.
src/cerebi/app/backend/security/analytics.py - Mongo provider · Only production Mongo driver-construction boundary.
src/cerebi/foundation/mongo/provider.py
Digital Twin Data
- Source ingestion · Synchronizes spreadsheet/Drive CSV sources and loads snapshots.
src/cerebi/data/ingestion/sync_worker.py - Object mapping · Maps and validates external records into the twin model.
src/cerebi/data/object_model/loader.py - Twin storage · Stores and queries twin documents and relationships.
src/cerebi/data/storage/twin_storage.py - Aurora read adapter · Explicit non-request-path RDS source adapter.
src/cerebi/data/storage/aurora.py - Weather inputs · NWS and Open-Meteo integrations.
src/cerebi/data/inputs/weather/nws.py
Intelligence
- Intelligence bootstrap · Builds tenant/client frameworks and validates registry configuration.
src/cerebi/intelligence/bootstrap/container.py - Model/task registry
src/cerebi/intelligence/registry/service.py - Calculation runner · Resolves inputs, guards execution, invokes adapters, and finalizes results.
src/cerebi/intelligence/calculation/runner.py - Capability adapters · Includes route-delay scoring and relationship ranking.
src/cerebi/intelligence/capabilities/route_delay/adapter.py - Result store · Persists completed intelligence results in Mongo.
src/cerebi/intelligence/persistence/mongo/store.py - Twin result sink · Writes calculation outputs for twin consumers.
src/cerebi/intelligence/twin/result_sink.py - Impact engine
src/cerebi/intelligence/impact/engine.py - Recommendations
src/cerebi/intelligence/recommendation/service.py
Other components
- MongoDB · Stores tenant configuration, twins, registry state, and persisted results.
Connections 29
- React/Vite SPA → API client: uses
- API client → FastAPI server: HTTP API
- FastAPI server → App composition: starts with
- App composition → Tenant access: composes
- App composition → HTTP routes: registers
- App composition → Mongo provider: constructs
- HTTP routes → Analytics security: enforces
- HTTP routes → Backend workflows: dispatches
- Tenant access → Backend workflows: scopes tenants
- Backend workflows → Twin storage: reads and commands
- Backend workflows → Intelligence bootstrap: requests tasks
- Mongo provider → MongoDB: connects
- Source ingestion → Object mapping: raw records
- Object mapping → Twin storage: normalized twins
- Aurora read adapter → Source ingestion: read-only source
- Twin storage → MongoDB: twin documents
- Intelligence bootstrap → Model/task registry: initializes
- Intelligence bootstrap → Calculation runner: configures
- Model/task registry → Calculation runner: resolves tasks
- Calculation runner → Twin storage: resolves twin inputs
- Weather inputs → Calculation runner: enrichment inputs
- Calculation runner → Capability adapters: invokes
- Calculation runner → Result store: persists
- Calculation runner → Twin result sink: writes outputs
- Calculation runner → Impact engine: evaluates
- Impact engine → Recommendations: informs
- Result store → MongoDB: results
- Twin result sink → Twin storage: twin-facing results
- Model/task registry → MongoDB: registry state