# mahdidada/log-anomaly-system architecture

> Architecture diagram of the GitHub repository mahdidada/log-anomaly-system, 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/mahdidada/log-anomaly-system
- Repository: https://github.com/mahdidada/log-anomaly-system

## Overview

This is a web-based log anomaly detection system. Users upload log files through the dashboard/API; the upload handler validates and saves the file, creates a batch, then parses and persists its records. Separate APIs retrieve and filter logs, report batch summaries and anomalies, and run model analysis; the dashboard presents these results. The graph preserves the documented feature, training, statistics, and reporting capabilities. Edges reflect shown calls or README relationships; the dashboard-to-API link is documented, while unsampled internals are represented only where their paths are supported.

Main entry points: [`app/main.py`](https://github.com/mahdidada/log-anomaly-system/blob/master/app/main.py) (FastAPI application), [`app/db/crud.py`](https://github.com/mahdidada/log-anomaly-system/blob/master/app/db/crud.py) (Log and batch operations), [`static/js/dashboard.js`](https://github.com/mahdidada/log-anomaly-system/blob/master/static/js/dashboard.js) (Dashboard), [`app/api/v1/upload.py`](https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/upload.py) (Upload API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Log ingestion"]
  node_validator["File validator<br/>[validator.py]"]
  node_file_store["Uploaded files<br/>[uploader.py]"]
  node_processor["Log processor<br/>[processor.py]"]
  node_parser["Log parser<br/>[parser.py]"]
  node_line_parser["Regex parser<br/>[regex_parser.py]"]
  node_dataframe["Record dataframe<br/>[dataframe.py]"]
end

subgraph group_data["Logs and storage"]
  node_crud["Log and batch operations<br/>[crud.py]"]
  node_database[("SQLite database<br/>[database.py]")]
  node_models["Log and batch models<br/>[models.py]"]
end

subgraph group_intelligence["Anomaly intelligence"]
  node_analyzer["Log statistics<br/>[analyzer.py]"]
  node_features["Feature extraction<br/>[features.py]"]
  node_training["Model training<br/>[train.py]"]
  node_prediction["Anomaly prediction<br/>[predict.py]"]
  node_metrics["Anomaly metrics<br/>[metric.py]"]
  node_dataset["Training dataset<br/>[dataset.py]"]
end

subgraph group_interface["API and dashboard"]
  node_dashboard["Dashboard<br/>[dashboard.js]"]
  node_app["FastAPI application<br/>[main.py]"]
  node_upload_api["Upload API<br/>[upload.py]"]
  node_analysis_api["Statistics API"]
  node_logs_api["Logs API<br/>[logs.py]"]
  node_ai_api["AI API<br/>[ai.py]"]
  node_reports_api["Reports API<br/>[reports.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_dashboard
node_dashboard -->|"requests API"| node_app
node_app -->|"registers"| node_upload_api
node_app -->|"registers"| node_analysis_api
node_app -->|"registers"| node_logs_api
node_app -->|"registers"| node_ai_api
node_app -->|"registers"| node_reports_api
node_upload_api -->|"validates"| node_validator
node_upload_api -->|"saves file"| node_file_store
node_upload_api -->|"creates batch"| node_crud
node_upload_api -->|"processes file"| node_processor
node_processor -->|"parses file"| node_parser
node_processor -->|"converts records"| node_dataframe
node_processor -->|"stores records"| node_crud
node_parser -->|"parses lines"| node_line_parser
node_line_parser -.-> node_dataframe
node_crud -->|"persists entities"| node_models
node_models -->|"uses base"| node_database
node_analysis_api -->|"gets statistics"| node_analyzer
node_logs_api -->|"queries logs"| node_crud
node_reports_api -->|"queries batches"| node_crud
node_reports_api -->|"deletes file"| node_file_store
node_reports_api -->|"predicts anomalies"| node_prediction
node_ai_api -->|"loads logs"| node_crud
node_ai_api -->|"predicts anomalies"| node_prediction
node_ai_api -->|"calculates metrics"| node_metrics
node_prediction -->|"extracts features"| node_features
node_training -->|"extracts features"| node_features
node_dataset -->|"extracts features"| node_features
node_dashboard -.->|"views reports"| node_reports_api
node_dashboard -.->|"requests analysis"| node_ai_api
node_dashboard -.->|"searches logs"| node_logs_api
node_training -.->|"provides model"| node_prediction

click node_dashboard "https://github.com/mahdidada/log-anomaly-system/blob/master/static/js/dashboard.js"
click node_app "https://github.com/mahdidada/log-anomaly-system/blob/master/app/main.py"
click node_upload_api "https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/upload.py"
click node_analysis_api "https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/endpoints_analysis.py"
click node_logs_api "https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/logs.py"
click node_ai_api "https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/ai.py"
click node_reports_api "https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/reports.py"
click node_validator "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/file_manager/validator.py"
click node_file_store "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/file_manager/uploader.py"
click node_processor "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/log_processor/processor.py"
click node_parser "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/parser/parser.py"
click node_line_parser "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/parser/regex_parser.py"
click node_dataframe "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/parser/dataframe.py"
click node_crud "https://github.com/mahdidada/log-anomaly-system/blob/master/app/db/crud.py"
click node_database "https://github.com/mahdidada/log-anomaly-system/blob/master/app/db/database.py"
click node_models "https://github.com/mahdidada/log-anomaly-system/blob/master/app/db/models.py"
click node_analyzer "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/analyzer/analyzer.py"
click node_features "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/features.py"
click node_training "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/train.py"
click node_prediction "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/predict.py"
click node_metrics "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/metric.py"
click node_dataset "https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/dataset.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_validator,node_file_store,node_processor,node_parser,node_line_parser,node_dataframe,node_user toneBlue
class node_crud,node_database,node_models toneAmber
class node_analyzer,node_features,node_training,node_prediction,node_metrics,node_dataset toneMint
class node_dashboard,node_app,node_upload_api,node_analysis_api,node_logs_api,node_ai_api,node_reports_api toneRose
```

## Components

### Log ingestion

- [File validator](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/file_manager/validator.py): `app/modules/file_manager/validator.py`
- [Uploaded files](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/file_manager/uploader.py): `app/modules/file_manager/uploader.py`
- [Log processor](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/log_processor/processor.py): `app/modules/log_processor/processor.py`
- [Log parser](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/parser/parser.py): `app/modules/parser/parser.py`
- [Regex parser](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/parser/regex_parser.py): `app/modules/parser/regex_parser.py`
- [Record dataframe](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/parser/dataframe.py): `app/modules/parser/dataframe.py`

### Logs and storage

- [Log and batch operations](https://github.com/mahdidada/log-anomaly-system/blob/master/app/db/crud.py): `app/db/crud.py`
- [SQLite database](https://github.com/mahdidada/log-anomaly-system/blob/master/app/db/database.py): `app/db/database.py`
- [Log and batch models](https://github.com/mahdidada/log-anomaly-system/blob/master/app/db/models.py): `app/db/models.py`

### Anomaly intelligence

- [Log statistics](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/analyzer/analyzer.py): `app/modules/analyzer/analyzer.py`
- [Feature extraction](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/features.py): `app/modules/ai_engine/features.py`
- [Model training](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/train.py): `app/modules/ai_engine/train.py`
- [Anomaly prediction](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/predict.py): `app/modules/ai_engine/predict.py`
- [Anomaly metrics](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/metric.py): `app/modules/ai_engine/metric.py`
- [Training dataset](https://github.com/mahdidada/log-anomaly-system/blob/master/app/modules/ai_engine/dataset.py): `app/modules/ai_engine/dataset.py`

### API and dashboard

- [Dashboard](https://github.com/mahdidada/log-anomaly-system/blob/master/static/js/dashboard.js): `static/js/dashboard.js`
- [FastAPI application](https://github.com/mahdidada/log-anomaly-system/blob/master/app/main.py): `app/main.py`
- [Upload API](https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/upload.py): `app/api/v1/upload.py`
- [Statistics API](https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/endpoints_analysis.py): `app/api/v1/endpoints_analysis.py`
- [Logs API](https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/logs.py): `app/api/v1/logs.py`
- [AI API](https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/ai.py): `app/api/v1/ai.py`
- [Reports API](https://github.com/mahdidada/log-anomaly-system/blob/master/app/api/v1/reports.py): `app/api/v1/reports.py`

### Other components

- **User**

## Connections

- User → Dashboard: uses (evidence: `README.md`)
- Dashboard → FastAPI application: requests API (evidence: `README.md`)
- FastAPI application → Upload API: registers (evidence: `app/main.py`)
- FastAPI application → Statistics API: registers (evidence: `app/main.py`)
- FastAPI application → Logs API: registers (evidence: `app/main.py`)
- FastAPI application → AI API: registers (evidence: `app/main.py`)
- FastAPI application → Reports API: registers (evidence: `app/main.py`)
- Upload API → File validator: validates (evidence: `app/api/v1/upload.py`)
- Upload API → Uploaded files: saves file (evidence: `app/api/v1/upload.py`)
- Upload API → Log and batch operations: creates batch (evidence: `app/api/v1/upload.py`)
- Upload API → Log processor: processes file (evidence: `app/api/v1/upload.py`)
- Log processor → Log parser: parses file (evidence: `app/modules/log_processor/processor.py`)
- Log processor → Record dataframe: converts records (evidence: `app/modules/log_processor/processor.py`)
- Log processor → Log and batch operations: stores records (evidence: `app/modules/log_processor/processor.py`)
- Log parser → Regex parser: parses lines (evidence: `app/modules/parser/parser.py`)
- Regex parser → Record dataframe
- Log and batch operations → Log and batch models: persists entities (evidence: `app/db/crud.py`)
- Log and batch models → SQLite database: uses base (evidence: `app/db/models.py`)
- Statistics API → Log statistics: gets statistics (evidence: `app/api/v1/endpoints_analysis.py`)
- Logs API → Log and batch operations: queries logs (evidence: `app/api/v1/logs.py`)
- Reports API → Log and batch operations: queries batches (evidence: `app/api/v1/reports.py`)
- Reports API → Uploaded files: deletes file (evidence: `app/api/v1/reports.py`)
- Reports API → Anomaly prediction: predicts anomalies (evidence: `app/api/v1/reports.py`)
- AI API → Log and batch operations: loads logs (evidence: `app/api/v1/ai.py`)
- AI API → Anomaly prediction: predicts anomalies (evidence: `app/api/v1/ai.py`)
- AI API → Anomaly metrics: calculates metrics (evidence: `app/api/v1/ai.py`)
- Anomaly prediction → Feature extraction: extracts features (evidence: `app/modules/ai_engine/predict.py`)
- Model training → Feature extraction: extracts features (evidence: `app/modules/ai_engine/train.py`)
- Training dataset → Feature extraction: extracts features (evidence: `app/modules/ai_engine/dataset.py`)
- Dashboard → Reports API: views reports
- Dashboard → AI API: requests analysis
- Dashboard → Logs API: searches logs
- Model training → Anomaly prediction: provides model
