# manikantaguptha29/sif-guard-ai architecture

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

- Interactive diagram: https://gitdiagram.com/manikantaguptha29/sif-guard-ai
- Repository: https://github.com/manikantaguptha29/sif-guard-ai

## Overview

SIF-Guard AI is a prototype safety-reporting dashboard for oil production sites. Field workers submit typed, spoken, or photo-tagged reports; browser-side keyword rules triage them, and staff review the feed, dispatch responses, and track escalation and acknowledgement. The Express API handles authentication, report access, and persistence. Separately, `ml-model/` provides an offline synthetic-data training, evaluation, and inference pipeline; the README explicitly says it is not connected to the application. Frontend source was indexed but not excerpted, so detailed UI call relationships are not asserted.

Main entry points: [`frontend/index.html`](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/index.html) (Dashboard Page), [`backend/server.js`](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/server.js) (Express API), [`backend/db.js`](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/db.js) (Storage & Crypto), [`frontend/js/quick-report.js`](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/quick-report.js) (Report Composer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Dashboard"]
  node_page["Dashboard Page<br/>[index.html]"]
  node_auth_ui["Login &amp; Auth UI<br/>[auth.js]"]
  node_report_ui["Report Composer<br/>[quick-report.js]"]
  node_rule_triage["Keyword Triage<br/>[simulator.js]"]
  node_feed["Report Feed<br/>[feed-alerts.js]"]
  node_dashboard["Dashboard Views<br/>[dashboard.js]"]
  node_charts["Safety Charts<br/>[charts.js]"]
  node_ui_state["UI State<br/>[state.js]"]
end

subgraph group_api["Application API"]
  node_api_server["Express API<br/>[server.js]"]
  node_auth_api["Authentication<br/>[server.js]"]
  node_report_api["Report Handling<br/>[server.js]"]
end

subgraph group_storage["Persistence"]
  node_db_layer["Storage &amp; Crypto<br/>[db.js]"]
  node_json_store[("Local JSON State")]
end

subgraph group_ml_data["ML Data &amp; Prep"]
  node_synthetic["Synthetic Reports"]
  node_preprocess["Text Prep &amp; Splits<br/>[prepare.py]"]
  node_clean_text["Text Normalization<br/>[clean.py]"]
end

subgraph group_ml_runtime["ML Model"]
  node_train["Baseline Training<br/>[train_baseline.py]"]
  node_rules["Rules Baseline<br/>[rules_baseline.py]"]
  node_evaluate["Model Evaluation<br/>[evaluate.py]"]
  node_predict["Model Inference<br/>[predict.py]"]
  node_serve["Inference HTTP<br/>[serve.py]"]
end

node_worker(("Field Worker"))
node_staff(("Safety Staff"))
node_redis_store[("Upstash Redis")]

node_worker -->|"uses"| node_page
node_staff -->|"uses"| node_page
node_page -.->|"hosts"| node_auth_ui
node_page -.->|"hosts"| node_report_ui
node_report_ui -.->|"triages with"| node_rule_triage
node_page -.->|"shows"| node_feed
node_page -.->|"shows"| node_dashboard
node_dashboard -.->|"renders"| node_charts
node_auth_ui -.->|"authenticates via"| node_api_server
node_report_ui -.->|"submits to"| node_api_server
node_feed -.->|"loads from"| node_api_server
node_api_server -->|"routes auth"| node_auth_api
node_api_server -->|"routes reports"| node_report_api
node_auth_api -->|"loads and saves"| node_db_layer
node_report_api -->|"loads and saves"| node_db_layer
node_db_layer -->|"reads or writes"| node_json_store
node_db_layer -->|"reads or writes"| node_redis_store
node_synthetic -->|"supplies data"| node_preprocess
node_preprocess -->|"normalizes with"| node_clean_text
node_train -.->|"uses"| node_clean_text
node_evaluate -->|"scores against"| node_rules
node_predict -->|"normalizes with"| node_clean_text
node_serve -->|"calls"| node_predict

click node_page "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/index.html"
click node_auth_ui "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/auth.js"
click node_report_ui "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/quick-report.js"
click node_rule_triage "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/simulator.js"
click node_feed "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/feed-alerts.js"
click node_dashboard "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/dashboard.js"
click node_charts "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/charts.js"
click node_ui_state "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/state.js"
click node_api_server "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/server.js"
click node_auth_api "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/server.js"
click node_report_api "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/server.js"
click node_db_layer "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/db.js"
click node_synthetic "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/dataset/generate_synthetic.py"
click node_preprocess "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/preprocessing/prepare.py"
click node_clean_text "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/preprocessing/clean.py"
click node_train "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/training/train_baseline.py"
click node_rules "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/evaluation/rules_baseline.py"
click node_evaluate "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/evaluation/evaluate.py"
click node_predict "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/inference/predict.py"
click node_serve "https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/inference/serve.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_page,node_auth_ui,node_report_ui,node_rule_triage,node_feed,node_dashboard,node_charts,node_ui_state toneBlue
class node_api_server,node_auth_api,node_report_api,node_redis_store toneAmber
class node_db_layer,node_json_store toneMint
class node_synthetic,node_preprocess,node_clean_text,node_worker toneRose
class node_train,node_rules,node_evaluate,node_predict,node_serve,node_staff toneIndigo
```

## Components

### Dashboard

- [Dashboard Page](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/index.html): `frontend/index.html`
- [Login & Auth UI](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/auth.js): `frontend/js/auth.js`
- [Report Composer](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/quick-report.js): `frontend/js/quick-report.js`
- [Keyword Triage](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/simulator.js): `frontend/js/simulator.js`
- [Report Feed](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/feed-alerts.js): `frontend/js/feed-alerts.js`
- [Dashboard Views](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/dashboard.js): `frontend/js/dashboard.js`
- [Safety Charts](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/charts.js): `frontend/js/charts.js`
- [UI State](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/frontend/js/state.js): `frontend/js/state.js`

### Application API

- [Express API](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/server.js): `backend/server.js`
- [Report Handling](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/server.js): `backend/server.js`

### Persistence

- [Storage & Crypto](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/backend/db.js): `backend/db.js`
- **Local JSON State**

### ML Data & Prep

- [Synthetic Reports](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/dataset/generate_synthetic.py): `ml-model/dataset/generate_synthetic.py`
- [Text Prep & Splits](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/preprocessing/prepare.py): `ml-model/preprocessing/prepare.py`
- [Text Normalization](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/preprocessing/clean.py): `ml-model/preprocessing/clean.py`

### ML Model

- [Baseline Training](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/training/train_baseline.py): `ml-model/training/train_baseline.py`
- [Rules Baseline](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/evaluation/rules_baseline.py): `ml-model/evaluation/rules_baseline.py`
- [Model Evaluation](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/evaluation/evaluate.py): `ml-model/evaluation/evaluate.py`
- [Model Inference](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/inference/predict.py): `ml-model/inference/predict.py`
- [Inference HTTP](https://github.com/manikantaguptha29/sif-guard-ai/blob/main/ml-model/inference/serve.py): `ml-model/inference/serve.py`

### Other components

- **Field Worker**
- **Safety Staff**
- **Upstash Redis**

## Connections

- Field Worker → Dashboard Page: uses (evidence: `README.md`)
- Safety Staff → Dashboard Page: uses (evidence: `README.md`)
- Dashboard Page → Login & Auth UI: hosts
- Dashboard Page → Report Composer: hosts
- Report Composer → Keyword Triage: triages with
- Dashboard Page → Report Feed: shows
- Dashboard Page → Dashboard Views: shows
- Dashboard Views → Safety Charts: renders
- Login & Auth UI → Express API: authenticates via
- Report Composer → Express API: submits to
- Report Feed → Express API: loads from
- Express API → Authentication: routes auth (evidence: `backend/server.js`)
- Express API → Report Handling: routes reports (evidence: `backend/server.js`)
- Authentication → Storage & Crypto: loads and saves (evidence: `backend/server.js`)
- Report Handling → Storage & Crypto: loads and saves (evidence: `backend/server.js`)
- Storage & Crypto → Local JSON State: reads or writes (evidence: `backend/db.js`)
- Storage & Crypto → Upstash Redis: reads or writes (evidence: `backend/db.js`)
- Synthetic Reports → Text Prep & Splits: supplies data (evidence: `ml-model/preprocessing/prepare.py`)
- Text Prep & Splits → Text Normalization: normalizes with (evidence: `ml-model/preprocessing/prepare.py`)
- Baseline Training → Text Normalization: uses
- Model Evaluation → Rules Baseline: scores against (evidence: `ml-model/evaluation/evaluate.py`)
- Model Inference → Text Normalization: normalizes with (evidence: `ml-model/inference/predict.py`)
- Inference HTTP → Model Inference: calls (evidence: `ml-model/inference/serve.py`)
