# ani503/vajra architecture

> Architecture diagram of the GitHub repository ani503/vajra, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ani503/vajra
- Repository: https://github.com/ani503/vajra

## Overview

VAJRA is an offline-first predictive-maintenance and fleet-readiness platform. Operators use its management console to inspect fleet and engine health, review alerts and forecasts, and coordinate maintenance and spares; telemetry replay feeds live scoring and safety-rule evaluation, with results exposed through the API and WebSocket. The graph preserves the documented ML, reporting, audit, and readiness capabilities. Some routes and integrations are represented from README and SOURCE INDEX references rather than inspected implementation excerpts, so only documented or indexed relationships are shown.

Main entry points: [`backend/app/main.py`](https://github.com/ani503/vajra/blob/main/backend/app/main.py) (FastAPI application), [`backend/app/database.py`](https://github.com/ani503/vajra/blob/main/backend/app/database.py) (SQLite database), [`backend/app/services/simulator.py`](https://github.com/ani503/vajra/blob/main/backend/app/services/simulator.py) (Telemetry replay), [`backend/app/api/routes/engines.py`](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/engines.py) (Engine health API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_app["FastAPI application<br/>[main.py]"]
end

subgraph group_predict["Telemetry and prediction"]
  node_simulator_api["Simulator API<br/>[simulator.py]"]
  node_simulator["Telemetry replay<br/>[simulator.py]"]
  node_inference["ML health scoring<br/>[inference.py]"]
  node_live_scoring["Live scoring bridge<br/>[live_scoring.py]"]
  node_preprocessing["Feature engineering<br/>[preprocessing.py]"]
  node_rules["Safety rule engine<br/>[rule_engine.py]"]
  node_websocket["WebSocket hub<br/>[websocket.py]"]
end

subgraph group_operations["Fleet operations"]
  node_engine_api["Engine health API<br/>[engines.py]"]
  node_dashboard_api["Dashboard KPIs<br/>[dashboard.py]"]
  node_fleet_api["Fleet readiness<br/>[fleet.py]"]
  node_alerts_api["Alerts<br/>[alerts.py]"]
  node_maintenance_api["Maintenance optimizer<br/>[maintenance.py]"]
  node_spares_api["Spares routing<br/>[spares.py]"]
  node_reports_api["Reports<br/>[reports.py]"]
  node_pdf["PDF report engine<br/>[pdf_report.py]"]
end

subgraph group_platform["Platform services"]
  node_database[("SQLite database<br/>[database.py]")]
  node_audit["Audit logging<br/>[audit.py]"]
  node_auth["RBAC authentication<br/>[auth.py]"]
end

subgraph group_clients["User interfaces"]
  node_console["Management console<br/>[vajra-bridge.js]"]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_console
node_console -->|"calls API"| node_app
node_app -->|"routes"| node_engine_api
node_app -->|"routes"| node_dashboard_api
node_app -->|"routes"| node_fleet_api
node_app -->|"routes"| node_alerts_api
node_app -->|"routes"| node_maintenance_api
node_app -->|"routes"| node_spares_api
node_app -->|"routes"| node_reports_api
node_app -->|"routes"| node_simulator_api
node_app -->|"registers"| node_websocket
node_engine_api -->|"queries"| node_database
node_dashboard_api -->|"queries"| node_database
node_fleet_api -->|"queries"| node_database
node_alerts_api -->|"queries"| node_database
node_maintenance_api -->|"queries"| node_database
node_spares_api -->|"queries"| node_database
node_reports_api -->|"queries"| node_database
node_engine_api -->|"scores engines"| node_inference
node_simulator_api -->|"delegates"| node_simulator
node_simulator -->|"updates state"| node_database
node_simulator -->|"scores readings"| node_live_scoring
node_simulator -->|"checks thresholds"| node_rules
node_inference -.->|"uses features"| node_preprocessing
node_reports_api -->|"generates PDFs"| node_pdf
node_auth -->|"loads user"| node_database
node_alerts_api -->|"records actions"| node_audit
node_maintenance_api -->|"records actions"| node_audit
node_console -->|"streams telemetry"| node_websocket

click node_app "https://github.com/ani503/vajra/blob/main/backend/app/main.py"
click node_database "https://github.com/ani503/vajra/blob/main/backend/app/database.py"
click node_engine_api "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/engines.py"
click node_dashboard_api "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/dashboard.py"
click node_fleet_api "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/fleet.py"
click node_alerts_api "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/alerts.py"
click node_maintenance_api "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/maintenance.py"
click node_spares_api "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/spares.py"
click node_reports_api "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/reports.py"
click node_audit "https://github.com/ani503/vajra/blob/main/backend/app/services/audit.py"
click node_auth "https://github.com/ani503/vajra/blob/main/backend/app/core/auth.py"
click node_simulator_api "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/simulator.py"
click node_simulator "https://github.com/ani503/vajra/blob/main/backend/app/services/simulator.py"
click node_inference "https://github.com/ani503/vajra/blob/main/ml/inference.py"
click node_live_scoring "https://github.com/ani503/vajra/blob/main/ml/live_scoring.py"
click node_preprocessing "https://github.com/ani503/vajra/blob/main/ml/preprocessing.py"
click node_rules "https://github.com/ani503/vajra/blob/main/backend/app/core/rule_engine.py"
click node_pdf "https://github.com/ani503/vajra/blob/main/backend/app/services/pdf_report.py"
click node_websocket "https://github.com/ani503/vajra/blob/main/backend/app/api/routes/websocket.py"
click node_console "https://github.com/ani503/vajra/blob/main/VAJRA_REVIEW/frontend/vajra-bridge.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app toneBlue
class node_simulator_api,node_simulator,node_inference,node_live_scoring,node_preprocessing,node_rules,node_websocket toneAmber
class node_engine_api,node_dashboard_api,node_fleet_api,node_alerts_api,node_maintenance_api,node_spares_api,node_reports_api,node_pdf toneMint
class node_database,node_audit,node_auth toneRose
class node_console,node_operator toneIndigo
```

## Components

### Application entry

- [FastAPI application](https://github.com/ani503/vajra/blob/main/backend/app/main.py): `backend/app/main.py`

### Telemetry and prediction

- [Simulator API](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/simulator.py): `backend/app/api/routes/simulator.py`
- [Telemetry replay](https://github.com/ani503/vajra/blob/main/backend/app/services/simulator.py): `backend/app/services/simulator.py`
- [ML health scoring](https://github.com/ani503/vajra/blob/main/ml/inference.py): `ml/inference.py`
- [Live scoring bridge](https://github.com/ani503/vajra/blob/main/ml/live_scoring.py): `ml/live_scoring.py`
- [Feature engineering](https://github.com/ani503/vajra/blob/main/ml/preprocessing.py): `ml/preprocessing.py`
- [Safety rule engine](https://github.com/ani503/vajra/blob/main/backend/app/core/rule_engine.py): `backend/app/core/rule_engine.py`
- [WebSocket hub](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/websocket.py): `backend/app/api/routes/websocket.py`

### Fleet operations

- [Engine health API](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/engines.py): `backend/app/api/routes/engines.py`
- [Dashboard KPIs](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/dashboard.py): `backend/app/api/routes/dashboard.py`
- [Fleet readiness](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/fleet.py): `backend/app/api/routes/fleet.py`
- [Alerts](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/alerts.py): `backend/app/api/routes/alerts.py`
- [Maintenance optimizer](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/maintenance.py): `backend/app/api/routes/maintenance.py`
- [Spares routing](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/spares.py): `backend/app/api/routes/spares.py`
- [Reports](https://github.com/ani503/vajra/blob/main/backend/app/api/routes/reports.py): `backend/app/api/routes/reports.py`
- [PDF report engine](https://github.com/ani503/vajra/blob/main/backend/app/services/pdf_report.py): `backend/app/services/pdf_report.py`

### Platform services

- [SQLite database](https://github.com/ani503/vajra/blob/main/backend/app/database.py): `backend/app/database.py`
- [Audit logging](https://github.com/ani503/vajra/blob/main/backend/app/services/audit.py): `backend/app/services/audit.py`
- [RBAC authentication](https://github.com/ani503/vajra/blob/main/backend/app/core/auth.py): `backend/app/core/auth.py`

### User interfaces

- [Management console](https://github.com/ani503/vajra/blob/main/VAJRA_REVIEW/frontend/vajra-bridge.js): `VAJRA_REVIEW/frontend/vajra-bridge.js`

### Other components

- **Operator**

## Connections

- Operator → Management console: uses (evidence: `README.md`)
- Management console → FastAPI application: calls API (evidence: `README.md`)
- FastAPI application → Engine health API: routes (evidence: `backend/app/main.py`)
- FastAPI application → Dashboard KPIs: routes (evidence: `backend/app/main.py`)
- FastAPI application → Fleet readiness: routes (evidence: `backend/app/main.py`)
- FastAPI application → Alerts: routes (evidence: `backend/app/main.py`)
- FastAPI application → Maintenance optimizer: routes (evidence: `backend/app/main.py`)
- FastAPI application → Spares routing: routes (evidence: `backend/app/main.py`)
- FastAPI application → Reports: routes (evidence: `backend/app/main.py`)
- FastAPI application → Simulator API: routes (evidence: `backend/app/main.py`)
- FastAPI application → WebSocket hub: registers (evidence: `backend/app/main.py`)
- Engine health API → SQLite database: queries (evidence: `backend/app/api/routes/engines.py`)
- Dashboard KPIs → SQLite database: queries (evidence: `backend/app/api/routes/dashboard.py`)
- Fleet readiness → SQLite database: queries (evidence: `backend/app/api/routes/fleet.py`)
- Alerts → SQLite database: queries (evidence: `backend/app/api/routes/alerts.py`)
- Maintenance optimizer → SQLite database: queries (evidence: `backend/app/api/routes/maintenance.py`)
- Spares routing → SQLite database: queries (evidence: `backend/app/api/routes/spares.py`)
- Reports → SQLite database: queries (evidence: `backend/app/api/routes/reports.py`)
- Engine health API → ML health scoring: scores engines (evidence: `backend/app/api/routes/engines.py`)
- Simulator API → Telemetry replay: delegates (evidence: `backend/app/api/routes/simulator.py`)
- Telemetry replay → SQLite database: updates state (evidence: `backend/app/services/simulator.py`)
- Telemetry replay → Live scoring bridge: scores readings (evidence: `backend/app/services/simulator.py`)
- Telemetry replay → Safety rule engine: checks thresholds (evidence: `backend/app/services/simulator.py`)
- ML health scoring → Feature engineering: uses features
- Reports → PDF report engine: generates PDFs (evidence: `backend/app/api/routes/reports.py`)
- RBAC authentication → SQLite database: loads user (evidence: `backend/app/core/auth.py`)
- Alerts → Audit logging: records actions (evidence: `backend/app/api/routes/alerts.py`)
- Maintenance optimizer → Audit logging: records actions (evidence: `backend/app/api/routes/maintenance.py`)
- Management console → WebSocket hub: streams telemetry (evidence: `README.md`)
