# moubashirhafeez17/bijliguard-ai architecture

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

- Interactive diagram: https://gitdiagram.com/moubashirhafeez17/bijliguard-ai
- Repository: https://github.com/moubashirhafeez17/bijliguard-ai

## Overview

BijliGuard is a simulated-data exhibition dashboard for electricity-theft signals and transformer fault-risk estimates in Karachi. Its analytical workflow generates synthetic records, cleans and validates them, and saves processed datasets; the Streamlit dashboard loads and scores those datasets, then presents overview, theft-search, transformer-monitoring, and area-map views. Theft and transformer scoring are centralized in one prediction service, currently using rule-based placeholders. The README documents the map’s online/offline behavior and exploratory charts. Some subsystem links are based on README or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`app.py`](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app.py) (Streamlit entry), [`app/utils/helpers.py`](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/utils/helpers.py) (Dashboard data), [`app/pages/1_Theft_Detection.py`](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/pages/1_Theft_Detection.py) (Theft detection), [`src/data/clean_data.py`](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/data/clean_data.py) (Data cleaning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Data pipeline"]
  node_generator["Synthetic generation"]
  node_synthetic[("Synthetic records")]
  node_cleaning["Data cleaning<br/>[clean_data.py]"]
  node_validation["Data validation<br/>[validate_data.py]"]
  node_processed[("Processed datasets")]
  node_loader["Dataset loading<br/>[load_data.py]"]
  node_settings["Shared settings<br/>[settings.py]"]
end

subgraph group_scoring["Risk scoring"]
  node_theft_score["Theft scoring"]
  node_transformer_score["Transformer scoring"]
end

subgraph group_dashboard["Dashboard experience"]
  node_entry["Streamlit entry<br/>[app.py]"]
  node_data_helpers["Dashboard data<br/>[helpers.py]"]
  node_overview["Overview<br/>[app.py]"]
  node_theft_page["Theft detection"]
  node_transformer_page["Transformer monitoring"]
  node_map_page["Karachi area map"]
end

subgraph group_presentation["Presentation"]
  node_ui_components["Shared UI components"]
  node_interactive_charts["Interactive charts<br/>[charts.py]"]
  node_formatting["Display formatting<br/>[formatting.py]"]
  node_area_map["Map renderer<br/>[karachi_map.py]"]
  node_exploratory_charts["Exploratory charts<br/>[plot_charts.py]"]
end

node_operator(("Dashboard user"))

node_generator -.->|"generates"| node_synthetic
node_synthetic -.->|"cleaned by"| node_cleaning
node_cleaning -->|"validated by"| node_validation
node_cleaning -->|"saves datasets"| node_processed
node_validation -->|"reports quality"| node_processed
node_entry -->|"renders"| node_overview
node_entry -->|"routes to"| node_theft_page
node_entry -->|"routes to"| node_transformer_page
node_entry -->|"routes to"| node_map_page
node_operator -.->|"opens dashboard"| node_entry
node_overview -->|"loads data"| node_data_helpers
node_theft_page -->|"loads data"| node_data_helpers
node_transformer_page -->|"loads data"| node_data_helpers
node_map_page -.->|"loads data"| node_data_helpers
node_data_helpers -->|"loads datasets"| node_loader
node_data_helpers -->|"scores theft"| node_theft_score
node_data_helpers -->|"scores transformers"| node_transformer_score
node_loader -.->|"reads"| node_processed
node_data_helpers -->|"runs pipeline if missing"| node_entry
node_theft_page -->|"scores test reading"| node_theft_score
node_overview -->|"renders cards alerts"| node_ui_components
node_theft_page -->|"renders alerts"| node_ui_components
node_transformer_page -.->|"renders shared UI"| node_ui_components
node_overview -->|"renders charts"| node_interactive_charts
node_theft_page -->|"renders charts"| node_interactive_charts
node_transformer_page -->|"renders charts"| node_interactive_charts
node_map_page -.->|"renders charts"| node_interactive_charts
node_map_page -.->|"renders map"| node_area_map
node_theft_page -->|"formats values"| node_formatting
node_entry -.->|"uses shared settings"| node_settings
node_cleaning -.->|"uses settings"| node_settings
node_loader -.->|"uses paths"| node_settings
node_validation -.->|"uses ranges"| node_settings
node_entry -.->|"pipeline generates figures"| node_exploratory_charts

click node_generator "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/scripts/generate_synthetic_data.py"
click node_synthetic "https://github.com/moubashirhafeez17/bijliguard-ai/tree/main/data/synthetic"
click node_cleaning "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/data/clean_data.py"
click node_validation "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/data/validate_data.py"
click node_processed "https://github.com/moubashirhafeez17/bijliguard-ai/tree/main/data/processed"
click node_loader "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/data/load_data.py"
click node_settings "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/config/settings.py"
click node_theft_score "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/services/prediction_service.py"
click node_transformer_score "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/services/prediction_service.py"
click node_entry "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app.py"
click node_data_helpers "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/utils/helpers.py"
click node_overview "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app.py"
click node_theft_page "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/pages/1_Theft_Detection.py"
click node_transformer_page "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/pages/2_Transformer_Monitoring.py"
click node_map_page "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/pages/3_Karachi_Area_Map.py"
click node_ui_components "https://github.com/moubashirhafeez17/bijliguard-ai/tree/main/app/components"
click node_interactive_charts "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/components/charts.py"
click node_formatting "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/utils/formatting.py"
click node_area_map "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/visualization/karachi_map.py"
click node_exploratory_charts "https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/visualization/plot_charts.py"

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_generator,node_synthetic,node_cleaning,node_validation,node_processed,node_loader,node_settings,node_operator toneBlue
class node_theft_score,node_transformer_score toneAmber
class node_entry,node_data_helpers,node_overview,node_theft_page,node_transformer_page,node_map_page toneMint
class node_ui_components,node_interactive_charts,node_formatting,node_area_map,node_exploratory_charts toneRose
```

## Components

### Data pipeline

- [Synthetic generation](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/scripts/generate_synthetic_data.py): `scripts/generate_synthetic_data.py`
- [Synthetic records](https://github.com/moubashirhafeez17/bijliguard-ai/tree/main/data/synthetic): `data/synthetic`
- [Data cleaning](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/data/clean_data.py): `src/data/clean_data.py`
- [Data validation](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/data/validate_data.py): `src/data/validate_data.py`
- [Processed datasets](https://github.com/moubashirhafeez17/bijliguard-ai/tree/main/data/processed): `data/processed`
- [Dataset loading](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/data/load_data.py): `src/data/load_data.py`
- [Shared settings](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/config/settings.py): `config/settings.py`

### Risk scoring

- [Theft scoring](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/services/prediction_service.py): `src/services/prediction_service.py`
- [Transformer scoring](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/services/prediction_service.py): `src/services/prediction_service.py`

### Dashboard experience

- [Streamlit entry](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app.py): `app.py`
- [Dashboard data](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/utils/helpers.py): `app/utils/helpers.py`
- [Overview](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app.py): `app.py`
- [Theft detection](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/pages/1_Theft_Detection.py): `app/pages/1_Theft_Detection.py`
- [Transformer monitoring](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/pages/2_Transformer_Monitoring.py): `app/pages/2_Transformer_Monitoring.py`
- [Karachi area map](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/pages/3_Karachi_Area_Map.py): `app/pages/3_Karachi_Area_Map.py`

### Presentation

- [Shared UI components](https://github.com/moubashirhafeez17/bijliguard-ai/tree/main/app/components): `app/components`
- [Interactive charts](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/components/charts.py): `app/components/charts.py`
- [Display formatting](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/app/utils/formatting.py): `app/utils/formatting.py`
- [Map renderer](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/visualization/karachi_map.py): `src/visualization/karachi_map.py`
- [Exploratory charts](https://github.com/moubashirhafeez17/bijliguard-ai/blob/main/src/visualization/plot_charts.py): `src/visualization/plot_charts.py`

### Other components

- **Dashboard user**

## Connections

- Synthetic generation → Synthetic records: generates
- Synthetic records → Data cleaning: cleaned by
- Data cleaning → Data validation: validated by (evidence: `scripts/run_pipeline.py`)
- Data cleaning → Processed datasets: saves datasets
- Data validation → Processed datasets: reports quality
- Streamlit entry → Overview: renders (evidence: `app.py`)
- Streamlit entry → Theft detection: routes to (evidence: `app.py`)
- Streamlit entry → Transformer monitoring: routes to (evidence: `app.py`)
- Streamlit entry → Karachi area map: routes to (evidence: `app.py`)
- Dashboard user → Streamlit entry: opens dashboard
- Overview → Dashboard data: loads data (evidence: `app.py`)
- Theft detection → Dashboard data: loads data (evidence: `app/pages/1_Theft_Detection.py`)
- Transformer monitoring → Dashboard data: loads data (evidence: `app/pages/2_Transformer_Monitoring.py`)
- Karachi area map → Dashboard data: loads data (evidence: `app/pages/3_Karachi_Area_Map.py`)
- Dashboard data → Dataset loading: loads datasets (evidence: `app/utils/helpers.py`)
- Dashboard data → Theft scoring: scores theft (evidence: `app/utils/helpers.py`)
- Dashboard data → Transformer scoring: scores transformers (evidence: `app/utils/helpers.py`)
- Dataset loading → Processed datasets: reads
- Dashboard data → Streamlit entry: runs pipeline if missing (evidence: `app/utils/helpers.py`)
- Theft detection → Theft scoring: scores test reading (evidence: `app/pages/1_Theft_Detection.py`)
- Overview → Shared UI components: renders cards alerts (evidence: `app.py`)
- Theft detection → Shared UI components: renders alerts (evidence: `app/pages/1_Theft_Detection.py`)
- Transformer monitoring → Shared UI components: renders shared UI (evidence: `app/pages/2_Transformer_Monitoring.py`)
- Overview → Interactive charts: renders charts (evidence: `app.py`)
- Theft detection → Interactive charts: renders charts (evidence: `app/pages/1_Theft_Detection.py`)
- Transformer monitoring → Interactive charts: renders charts (evidence: `app/pages/2_Transformer_Monitoring.py`)
- Karachi area map → Interactive charts: renders charts (evidence: `app/pages/3_Karachi_Area_Map.py`)
- Karachi area map → Map renderer: renders map (evidence: `app/pages/3_Karachi_Area_Map.py`)
- Theft detection → Display formatting: formats values (evidence: `app/pages/1_Theft_Detection.py`)
- Streamlit entry → Shared settings: uses shared settings
- Data cleaning → Shared settings: uses settings (evidence: `src/data/clean_data.py`)
- Dataset loading → Shared settings: uses paths (evidence: `src/data/load_data.py`)
- Data validation → Shared settings: uses ranges (evidence: `src/data/validate_data.py`)
- Streamlit entry → Exploratory charts: pipeline generates figures (evidence: `README.md`)
