# genecodeafrica/battery-lifespan architecture

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

- Interactive diagram: https://gitdiagram.com/genecodeafrica/battery-lifespan
- Repository: https://github.com/genecodeafrica/battery-lifespan

## Overview

BatteryLife AI is a Laravel battery-monitoring application integrated with a Python prediction API. Users manage battery records, enter or import measurements, request RUL/EOL estimates, and review monitoring dashboards, prediction history, alerts, and reports. The graph preserves the documented capability branches and the sampled controller-to-model/service responsibilities. Route dispatch links are supported by the route file’s controller references; the Laravel-to-FastAPI connection is documented in the README. Some view and API internals were not sampled, so those links are limited to documented relationships.

Main entry points: [`routes/web.php`](https://github.com/genecodeafrica/battery-lifespan/blob/main/routes/web.php) (Web routes), [`app/Models/Battery.php`](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/Battery.php) (Battery records), [`app/Models/Prediction.php`](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/Prediction.php) (Prediction history), [`app/Models/BatteryMeasurement.php`](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/BatteryMeasurement.php) (Measurements)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web access"]
  node_routes["Web routes<br/>[web.php]"]
  node_dashboard["Dashboard"]
end

subgraph group_battery["Battery monitoring"]
  node_battery_ctrl["Battery records"]
  node_csv_import["CSV import"]
  node_measurement_ctrl["Measurement tracking"]
  node_measurement_views["Measurement review"]
end

subgraph group_analytics["Prediction and reporting"]
  node_prediction_ctrl["RUL prediction"]
  node_ml_service["ML client"]
  node_prediction_api["FastAPI predictor<br/>[main.py]"]
  node_report_ctrl["Reports and analytics"]
  node_pdf_report["PDF generation"]
end

subgraph group_identity["Accounts and alerts"]
  node_auth["Authentication<br/>[AuthController.php]"]
  node_admin["User administration"]
  node_profile["Profile management"]
  node_settings["Application settings"]
  node_notification_ctrl["Notification inbox"]
  node_notification_service["Alert evaluation"]
end

subgraph group_persistence["Domain records"]
  node_battery_model[("Battery records<br/>[Battery.php]")]
  node_measurement_model[("Measurements")]
  node_prediction_model[("Prediction history<br/>[Prediction.php]")]
  node_notification_model[("Notifications<br/>[Notification.php]")]
  node_user_model[("User accounts<br/>[User.php]")]
end

node_user(("User"))
node_mysql[("MySQL")]

node_user -->|"uses"| node_routes
node_routes -->|"dispatches"| node_auth
node_routes -->|"dispatches"| node_dashboard
node_routes -->|"dispatches"| node_admin
node_routes -->|"dispatches"| node_profile
node_routes -->|"dispatches"| node_settings
node_routes -->|"dispatches"| node_battery_ctrl
node_routes -->|"dispatches"| node_csv_import
node_routes -->|"dispatches"| node_measurement_ctrl
node_routes -->|"dispatches"| node_measurement_views
node_routes -->|"dispatches"| node_prediction_ctrl
node_routes -->|"dispatches"| node_report_ctrl
node_routes -->|"dispatches"| node_pdf_report
node_routes -->|"dispatches"| node_notification_ctrl
node_admin -->|"manages"| node_user_model
node_auth -->|"uses"| node_user_model
node_profile -->|"uses"| node_user_model
node_settings -->|"reads"| node_battery_model
node_settings -->|"reads"| node_prediction_model
node_dashboard -->|"reads"| node_battery_model
node_dashboard -->|"reads"| node_measurement_model
node_dashboard -->|"reads"| node_prediction_model
node_battery_ctrl -->|"manages"| node_battery_model
node_csv_import -->|"creates"| node_battery_model
node_csv_import -->|"imports"| node_measurement_model
node_measurement_ctrl -->|"uses"| node_battery_model
node_measurement_ctrl -->|"manages"| node_measurement_model
node_measurement_views -->|"reads"| node_battery_model
node_measurement_views -->|"reads"| node_measurement_model
node_prediction_ctrl -->|"reads"| node_battery_model
node_prediction_ctrl -->|"records"| node_prediction_model
node_prediction_ctrl -->|"requests prediction"| node_ml_service
node_ml_service -->|"sends features"| node_prediction_api
node_prediction_ctrl -->|"notifies"| node_notification_service
node_notification_service -->|"creates alerts"| node_notification_model
node_notification_service -->|"checks health"| node_battery_model
node_notification_service -->|"checks RUL"| node_prediction_model
node_notification_service -->|"notifies"| node_user_model
node_notification_ctrl -->|"manages"| node_notification_model
node_report_ctrl -->|"reads"| node_battery_model
node_report_ctrl -->|"reads"| node_prediction_model
node_pdf_report -->|"loads report data"| node_battery_model
node_battery_model -->|"has measurements"| node_measurement_model
node_battery_model -->|"has predictions"| node_prediction_model
node_measurement_model -->|"has predictions"| node_prediction_model
node_prediction_model -->|"references"| node_measurement_model
node_user_model -->|"has notifications"| node_notification_model
node_battery_model -.->|"persists"| node_mysql

click node_routes "https://github.com/genecodeafrica/battery-lifespan/blob/main/routes/web.php"
click node_auth "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/AuthController.php"
click node_dashboard "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/DashboardController.php"
click node_admin "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/AdminController.php"
click node_profile "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/ProfileController.php"
click node_settings "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/SettingsController.php"
click node_battery_ctrl "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/BatteryController.php"
click node_csv_import "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/BatteryImportController.php"
click node_measurement_ctrl "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/BatteryMeasurementController.php"
click node_measurement_views "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/MeasurementController.php"
click node_prediction_ctrl "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/PredictionController.php"
click node_ml_service "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Services/MachineLearningService.php"
click node_prediction_api "https://github.com/genecodeafrica/battery-lifespan/blob/main/ml/api/main.py"
click node_report_ctrl "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/ReportController.php"
click node_pdf_report "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/BatteryReportPdfController.php"
click node_notification_ctrl "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/NotificationController.php"
click node_notification_service "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Services/NotificationService.php"
click node_battery_model "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/Battery.php"
click node_measurement_model "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/BatteryMeasurement.php"
click node_prediction_model "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/Prediction.php"
click node_notification_model "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/Notification.php"
click node_user_model "https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/User.php"

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_routes,node_dashboard,node_user toneBlue
class node_battery_ctrl,node_csv_import,node_measurement_ctrl,node_measurement_views,node_mysql toneAmber
class node_prediction_ctrl,node_ml_service,node_prediction_api,node_report_ctrl,node_pdf_report toneMint
class node_auth,node_admin,node_profile,node_settings,node_notification_ctrl,node_notification_service toneRose
class node_battery_model,node_measurement_model,node_prediction_model,node_notification_model,node_user_model toneIndigo
```

## Components

### Web access

- [Web routes](https://github.com/genecodeafrica/battery-lifespan/blob/main/routes/web.php): `routes/web.php`
- [Dashboard](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/DashboardController.php): `app/Http/Controllers/DashboardController.php`

### Battery monitoring

- [Battery records](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/BatteryController.php): `app/Http/Controllers/BatteryController.php`
- [CSV import](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/BatteryImportController.php): `app/Http/Controllers/BatteryImportController.php`
- [Measurement tracking](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/BatteryMeasurementController.php): `app/Http/Controllers/BatteryMeasurementController.php`
- [Measurement review](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/MeasurementController.php): `app/Http/Controllers/MeasurementController.php`

### Prediction and reporting

- [RUL prediction](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/PredictionController.php): `app/Http/Controllers/PredictionController.php`
- [ML client](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Services/MachineLearningService.php): `app/Services/MachineLearningService.php`
- [FastAPI predictor](https://github.com/genecodeafrica/battery-lifespan/blob/main/ml/api/main.py): `ml/api/main.py`
- [Reports and analytics](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/ReportController.php): `app/Http/Controllers/ReportController.php`
- [PDF generation](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/BatteryReportPdfController.php): `app/Http/Controllers/BatteryReportPdfController.php`

### Accounts and alerts

- [Authentication](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/AuthController.php): `app/Http/Controllers/AuthController.php`
- [User administration](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/AdminController.php): `app/Http/Controllers/AdminController.php`
- [Profile management](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/ProfileController.php): `app/Http/Controllers/ProfileController.php`
- [Application settings](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/SettingsController.php): `app/Http/Controllers/SettingsController.php`
- [Notification inbox](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Http/Controllers/NotificationController.php): `app/Http/Controllers/NotificationController.php`
- [Alert evaluation](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Services/NotificationService.php): `app/Services/NotificationService.php`

### Domain records

- [Battery records](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/Battery.php): `app/Models/Battery.php`
- [Measurements](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/BatteryMeasurement.php): `app/Models/BatteryMeasurement.php`
- [Prediction history](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/Prediction.php): `app/Models/Prediction.php`
- [Notifications](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/Notification.php): `app/Models/Notification.php`
- [User accounts](https://github.com/genecodeafrica/battery-lifespan/blob/main/app/Models/User.php): `app/Models/User.php`

### Other components

- **User**
- **MySQL**

## Connections

- User → Web routes: uses (evidence: `README.md`)
- Web routes → Authentication: dispatches (evidence: `routes/web.php`)
- Web routes → Dashboard: dispatches (evidence: `routes/web.php`)
- Web routes → User administration: dispatches (evidence: `routes/web.php`)
- Web routes → Profile management: dispatches (evidence: `routes/web.php`)
- Web routes → Application settings: dispatches (evidence: `routes/web.php`)
- Web routes → Battery records: dispatches (evidence: `routes/web.php`)
- Web routes → CSV import: dispatches (evidence: `routes/web.php`)
- Web routes → Measurement tracking: dispatches (evidence: `routes/web.php`)
- Web routes → Measurement review: dispatches (evidence: `routes/web.php`)
- Web routes → RUL prediction: dispatches (evidence: `routes/web.php`)
- Web routes → Reports and analytics: dispatches (evidence: `routes/web.php`)
- Web routes → PDF generation: dispatches (evidence: `routes/web.php`)
- Web routes → Notification inbox: dispatches (evidence: `routes/web.php`)
- User administration → User accounts: manages (evidence: `app/Http/Controllers/AdminController.php`)
- Authentication → User accounts: uses (evidence: `app/Http/Controllers/AuthController.php`)
- Profile management → User accounts: uses (evidence: `app/Http/Controllers/ProfileController.php`)
- Application settings → Battery records: reads (evidence: `app/Http/Controllers/SettingsController.php`)
- Application settings → Prediction history: reads (evidence: `app/Http/Controllers/SettingsController.php`)
- Dashboard → Battery records: reads (evidence: `app/Http/Controllers/DashboardController.php`)
- Dashboard → Measurements: reads (evidence: `app/Http/Controllers/DashboardController.php`)
- Dashboard → Prediction history: reads (evidence: `app/Http/Controllers/DashboardController.php`)
- Battery records → Battery records: manages (evidence: `app/Http/Controllers/BatteryController.php`)
- CSV import → Battery records: creates (evidence: `app/Http/Controllers/BatteryImportController.php`)
- CSV import → Measurements: imports (evidence: `app/Http/Controllers/BatteryImportController.php`)
- Measurement tracking → Battery records: uses (evidence: `app/Http/Controllers/BatteryMeasurementController.php`)
- Measurement tracking → Measurements: manages (evidence: `app/Http/Controllers/BatteryMeasurementController.php`)
- Measurement review → Battery records: reads (evidence: `app/Http/Controllers/MeasurementController.php`)
- Measurement review → Measurements: reads (evidence: `app/Http/Controllers/MeasurementController.php`)
- RUL prediction → Battery records: reads (evidence: `app/Http/Controllers/PredictionController.php`)
- RUL prediction → Prediction history: records (evidence: `app/Http/Controllers/PredictionController.php`)
- RUL prediction → ML client: requests prediction (evidence: `app/Http/Controllers/PredictionController.php`)
- ML client → FastAPI predictor: sends features (evidence: `README.md`)
- RUL prediction → Alert evaluation: notifies (evidence: `app/Http/Controllers/PredictionController.php`)
- Alert evaluation → Notifications: creates alerts (evidence: `app/Services/NotificationService.php`)
- Alert evaluation → Battery records: checks health (evidence: `app/Services/NotificationService.php`)
- Alert evaluation → Prediction history: checks RUL (evidence: `app/Services/NotificationService.php`)
- Alert evaluation → User accounts: notifies (evidence: `app/Services/NotificationService.php`)
- Notification inbox → Notifications: manages (evidence: `app/Http/Controllers/NotificationController.php`)
- Reports and analytics → Battery records: reads (evidence: `app/Http/Controllers/ReportController.php`)
- Reports and analytics → Prediction history: reads (evidence: `app/Http/Controllers/ReportController.php`)
- PDF generation → Battery records: loads report data (evidence: `app/Http/Controllers/BatteryReportPdfController.php`)
- Battery records → Measurements: has measurements (evidence: `app/Models/Battery.php`)
- Battery records → Prediction history: has predictions (evidence: `app/Models/Battery.php`)
- Measurements → Prediction history: has predictions (evidence: `app/Models/BatteryMeasurement.php`)
- Prediction history → Measurements: references (evidence: `app/Models/Prediction.php`)
- User accounts → Notifications: has notifications (evidence: `app/Models/User.php`)
- Battery records → MySQL: persists (evidence: `README.md`)
