# maharshith1910/final-year-project architecture

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

- Interactive diagram: https://gitdiagram.com/maharshith1910/final-year-project
- Repository: https://github.com/maharshith1910/final-year-project

## Overview

SafeWatch AI is a scream-audio distress detection prototype. Its documented workflow acquires audio datasets, prepares a manifest and Mel features, trains and evaluates CNN or CNN-LSTM models, then runs file or microphone inference through a Streamlit dashboard that records potential alerts for human review. The graph preserves these domain stages and the model/data-loading layers. Relationships for unsampled data utilities and dashboard capabilities follow README documentation; source excerpts and the index support the shown training, inference, model, and alert interactions.

Main entry points: [`training/evaluate.py`](https://github.com/maharshith1910/final-year-project/blob/main/training/evaluate.py) (Test evaluation), [`training/train.py`](https://github.com/maharshith1910/final-year-project/blob/main/training/train.py) (Training loop), [`inference/predictor.py`](https://github.com/maharshith1910/final-year-project/blob/main/inference/predictor.py) (Audio predictor), [`models/cnn_lstm_model.py`](https://github.com/maharshith1910/final-year-project/blob/main/models/cnn_lstm_model.py) (CNN-LSTM)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_download["Dataset download"]
  node_manifest["Manifest and splits<br/>[data_prep.py]"]
  node_mel["Mel extraction"]
  node_features[("Mel feature files")]
end

subgraph group_learning["Model development"]
  node_dataset["PyTorch datasets<br/>[dataset.py]"]
  node_trainer["Training loop<br/>[train.py]"]
  node_cnn["Baseline CNN<br/>[cnn_model.py]"]
  node_cnnlstm["CNN-LSTM<br/>[cnn_lstm_model.py]"]
  node_evaluator["Test evaluation<br/>[evaluate.py]"]
  node_checkpoints[("Model checkpoints")]
end

subgraph group_runtime["Detection and review"]
  node_operatorui["Streamlit dashboard<br/>[app.py]"]
  node_predictor["Audio predictor<br/>[predictor.py]"]
  node_alerts["Alert logger<br/>[alert_logger.py]"]
end

subgraph group_records["Persisted outputs"]
  node_alertcsv[("Alert log<br/>[alert_log.csv]")]
  node_metrics[("Evaluation results")]
end

node_operator(("Security operator"))
node_sources[("Dataset sources")]

node_sources -->|"provides audio"| node_download
node_download -->|"supplies audio"| node_manifest
node_manifest -->|"indexes files"| node_mel
node_mel -->|"writes features"| node_features
node_features -->|"loads samples"| node_dataset
node_dataset -->|"feeds batches"| node_trainer
node_trainer -->|"trains model"| node_cnn
node_trainer -->|"trains model"| node_cnnlstm
node_cnnlstm -->|"extracts features"| node_cnn
node_trainer -.->|"saves weights"| node_checkpoints
node_dataset -->|"feeds test set"| node_evaluator
node_evaluator -->|"evaluates model"| node_cnn
node_evaluator -->|"evaluates model"| node_cnnlstm
node_evaluator -.->|"loads weights"| node_checkpoints
node_evaluator -.->|"writes metrics"| node_metrics
node_operator -->|"uses dashboard"| node_operatorui
node_operatorui -->|"runs detection"| node_predictor
node_predictor -->|"loads model"| node_cnn
node_predictor -->|"loads model"| node_cnnlstm
node_predictor -->|"logs alerts"| node_alerts
node_operatorui -->|"queries alerts"| node_alerts
node_alerts -->|"reads and writes"| node_alertcsv

click node_download "https://github.com/maharshith1910/final-year-project/blob/main/utils/download_datasets.py"
click node_manifest "https://github.com/maharshith1910/final-year-project/blob/main/utils/data_prep.py"
click node_mel "https://github.com/maharshith1910/final-year-project/blob/main/utils/feature_extraction.py"
click node_features "https://github.com/maharshith1910/final-year-project/blob/main/data/features_manifest.csv"
click node_dataset "https://github.com/maharshith1910/final-year-project/blob/main/training/dataset.py"
click node_trainer "https://github.com/maharshith1910/final-year-project/blob/main/training/train.py"
click node_cnn "https://github.com/maharshith1910/final-year-project/blob/main/models/cnn_model.py"
click node_cnnlstm "https://github.com/maharshith1910/final-year-project/blob/main/models/cnn_lstm_model.py"
click node_evaluator "https://github.com/maharshith1910/final-year-project/blob/main/training/evaluate.py"
click node_operatorui "https://github.com/maharshith1910/final-year-project/blob/main/dashboard/app.py"
click node_predictor "https://github.com/maharshith1910/final-year-project/blob/main/inference/predictor.py"
click node_alerts "https://github.com/maharshith1910/final-year-project/blob/main/inference/alert_logger.py"
click node_alertcsv "https://github.com/maharshith1910/final-year-project/blob/main/outputs/alerts/alert_log.csv"
click node_metrics "https://github.com/maharshith1910/final-year-project/tree/main/outputs/metrics"

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_download,node_manifest,node_mel,node_features toneBlue
class node_dataset,node_trainer,node_cnn,node_cnnlstm,node_evaluator,node_checkpoints,node_sources toneAmber
class node_operatorui,node_predictor,node_alerts toneMint
class node_alertcsv,node_metrics toneRose
class node_operator toneIndigo
```

## Components

### Data preparation

- [Dataset download](https://github.com/maharshith1910/final-year-project/blob/main/utils/download_datasets.py): `utils/download_datasets.py`
- [Manifest and splits](https://github.com/maharshith1910/final-year-project/blob/main/utils/data_prep.py): `utils/data_prep.py`
- [Mel extraction](https://github.com/maharshith1910/final-year-project/blob/main/utils/feature_extraction.py): `utils/feature_extraction.py`
- [Mel feature files](https://github.com/maharshith1910/final-year-project/blob/main/data/features_manifest.csv): `data/features_manifest.csv`

### Model development

- [PyTorch datasets](https://github.com/maharshith1910/final-year-project/blob/main/training/dataset.py): `training/dataset.py`
- [Training loop](https://github.com/maharshith1910/final-year-project/blob/main/training/train.py): `training/train.py`
- [Baseline CNN](https://github.com/maharshith1910/final-year-project/blob/main/models/cnn_model.py): `models/cnn_model.py`
- [CNN-LSTM](https://github.com/maharshith1910/final-year-project/blob/main/models/cnn_lstm_model.py): `models/cnn_lstm_model.py`
- [Test evaluation](https://github.com/maharshith1910/final-year-project/blob/main/training/evaluate.py): `training/evaluate.py`
- **Model checkpoints**

### Detection and review

- [Streamlit dashboard](https://github.com/maharshith1910/final-year-project/blob/main/dashboard/app.py): `dashboard/app.py`
- [Audio predictor](https://github.com/maharshith1910/final-year-project/blob/main/inference/predictor.py): `inference/predictor.py`
- [Alert logger](https://github.com/maharshith1910/final-year-project/blob/main/inference/alert_logger.py): `inference/alert_logger.py`

### Persisted outputs

- [Alert log](https://github.com/maharshith1910/final-year-project/blob/main/outputs/alerts/alert_log.csv): `outputs/alerts/alert_log.csv`
- [Evaluation results](https://github.com/maharshith1910/final-year-project/tree/main/outputs/metrics): `outputs/metrics`

### Other components

- **Security operator**
- **Dataset sources**

## Connections

- Dataset sources → Dataset download: provides audio (evidence: `README.md`)
- Dataset download → Manifest and splits: supplies audio (evidence: `README.md`)
- Manifest and splits → Mel extraction: indexes files (evidence: `README.md`)
- Mel extraction → Mel feature files: writes features (evidence: `README.md`)
- Mel feature files → PyTorch datasets: loads samples (evidence: `training/dataset.py`)
- PyTorch datasets → Training loop: feeds batches (evidence: `training/train.py`)
- Training loop → Baseline CNN: trains model (evidence: `training/train.py`)
- Training loop → CNN-LSTM: trains model (evidence: `training/train.py`)
- CNN-LSTM → Baseline CNN: extracts features (evidence: `models/cnn_lstm_model.py`)
- Training loop → Model checkpoints: saves weights
- PyTorch datasets → Test evaluation: feeds test set (evidence: `training/evaluate.py`)
- Test evaluation → Baseline CNN: evaluates model (evidence: `training/evaluate.py`)
- Test evaluation → CNN-LSTM: evaluates model (evidence: `training/evaluate.py`)
- Test evaluation → Model checkpoints: loads weights
- Test evaluation → Evaluation results: writes metrics
- Security operator → Streamlit dashboard: uses dashboard (evidence: `README.md`)
- Streamlit dashboard → Audio predictor: runs detection (evidence: `dashboard/app.py`)
- Audio predictor → Baseline CNN: loads model (evidence: `inference/predictor.py`)
- Audio predictor → CNN-LSTM: loads model (evidence: `inference/predictor.py`)
- Audio predictor → Alert logger: logs alerts (evidence: `inference/predictor.py`)
- Streamlit dashboard → Alert logger: queries alerts (evidence: `dashboard/app.py`)
- Alert logger → Alert log: reads and writes (evidence: `inference/alert_logger.py`)
