# jeyprabu/systemlogs-anomaly-detection architecture

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

- Interactive diagram: https://gitdiagram.com/jeyprabu/systemlogs-anomaly-detection
- Repository: https://github.com/jeyprabu/systemlogs-anomaly-detection

## Overview

This platform accepts system metrics through a Spring REST API, delegates inference to a Python Isolation Forest service, persists the combined metrics and prediction, and returns the prediction to the caller. The ML service scales inputs, scores anomalies, assigns severity, and identifies contributing metrics. The README also describes Docker Compose deployment; deployment machinery is omitted here. Relationships are based on the sampled controller, client, model service, and README; unsampled configuration and persistence wiring are not inferred.

Main entry points: [`ml-anomaly-service/ml_service.py`](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py) (Inference Endpoint), [`spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java`](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java) (Log Controller), [`spring-anomaly-api/src/main/java/com/anomaly/endpoint/service/MlClientService.java`](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/service/MlClientService.java) (ML Client), [`spring-anomaly-api/src/main/java/com/anomaly/endpoint/repository/SystemLogRepository.java`](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/repository/SystemLogRepository.java) (Log Repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Spring API"]
  node_controller["Log Controller<br/>[LogController.java]"]
  node_request["Metrics Request<br/>[LogRequest.java]"]
  node_mlclient["ML Client"]
  node_prediction["Prediction DTO"]
end

subgraph group_ml["ML Inference"]
  node_mlservice["Inference Endpoint<br/>[ml_service.py]"]
  node_mlinput["ML Input Schema<br/>[ml_service.py]"]
  node_scaler["Feature Scaling<br/>[ml_service.py]"]
  node_model["Isolation Forest<br/>[ml_service.py]"]
  node_severity["Severity Scoring<br/>[ml_service.py]"]
  node_causes["Cause Ranking<br/>[ml_service.py]"]
end

subgraph group_storage["Prediction Storage"]
  node_systemlog["Stored Log<br/>[SystemLog.java]"]
  node_repository["Log Repository"]
  node_mongo[("MongoDB Atlas")]
end

node_caller(("API Client"))

node_caller -->|"submits metrics"| node_controller
node_controller -->|"accepts body"| node_request
node_controller -->|"requests prediction"| node_mlclient
node_mlclient -->|"POST /predict"| node_mlservice
node_mlservice -->|"parses input"| node_mlinput
node_mlservice -->|"scales features"| node_scaler
node_mlservice -->|"predicts and scores"| node_model
node_mlservice -->|"assigns severity"| node_severity
node_mlservice -->|"ranks metrics"| node_causes
node_mlservice -->|"returns prediction"| node_prediction
node_controller -->|"builds record"| node_systemlog
node_controller -->|"saves record"| node_repository
node_repository -->|"persists logs"| node_mongo
node_controller -->|"returns prediction"| node_caller

click node_controller "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java"
click node_request "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/dto/LogRequest.java"
click node_mlclient "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/service/MlClientService.java"
click node_prediction "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/dto/MlPredictionResponse.java"
click node_mlservice "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py"
click node_mlinput "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py"
click node_scaler "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py"
click node_model "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py"
click node_severity "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py"
click node_causes "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py"
click node_systemlog "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/model/SystemLog.java"
click node_repository "https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/repository/SystemLogRepository.java"

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_controller,node_request,node_mlclient,node_prediction,node_caller toneBlue
class node_mlservice,node_mlinput,node_scaler,node_model,node_severity,node_causes toneAmber
class node_systemlog,node_repository,node_mongo toneMint
```

## Components

### Spring API

- [Log Controller](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java): `spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java`
- [Metrics Request](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/dto/LogRequest.java): `spring-anomaly-api/src/main/java/com/anomaly/endpoint/dto/LogRequest.java`
- [ML Client](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/service/MlClientService.java): `spring-anomaly-api/src/main/java/com/anomaly/endpoint/service/MlClientService.java`
- [Prediction DTO](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/dto/MlPredictionResponse.java): `spring-anomaly-api/src/main/java/com/anomaly/endpoint/dto/MlPredictionResponse.java`

### ML Inference

- [Inference Endpoint](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py): `ml-anomaly-service/ml_service.py`
- [ML Input Schema](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py): `ml-anomaly-service/ml_service.py`
- [Feature Scaling](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py): `ml-anomaly-service/ml_service.py`
- [Isolation Forest](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py): `ml-anomaly-service/ml_service.py`
- [Severity Scoring](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py): `ml-anomaly-service/ml_service.py`
- [Cause Ranking](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/ml-anomaly-service/ml_service.py): `ml-anomaly-service/ml_service.py`

### Prediction Storage

- [Stored Log](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/model/SystemLog.java): `spring-anomaly-api/src/main/java/com/anomaly/endpoint/model/SystemLog.java`
- [Log Repository](https://github.com/jeyprabu/systemlogs-anomaly-detection/blob/main/spring-anomaly-api/src/main/java/com/anomaly/endpoint/repository/SystemLogRepository.java): `spring-anomaly-api/src/main/java/com/anomaly/endpoint/repository/SystemLogRepository.java`
- **MongoDB Atlas**

### Other components

- **API Client**

## Connections

- API Client → Log Controller: submits metrics (evidence: `README.md`)
- Log Controller → Metrics Request: accepts body (evidence: `spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java`)
- Log Controller → ML Client: requests prediction (evidence: `spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java`)
- ML Client → Inference Endpoint: POST /predict (evidence: `spring-anomaly-api/src/main/java/com/anomaly/endpoint/service/MlClientService.java`)
- Inference Endpoint → ML Input Schema: parses input (evidence: `ml-anomaly-service/ml_service.py`)
- Inference Endpoint → Feature Scaling: scales features (evidence: `ml-anomaly-service/ml_service.py`)
- Inference Endpoint → Isolation Forest: predicts and scores (evidence: `ml-anomaly-service/ml_service.py`)
- Inference Endpoint → Severity Scoring: assigns severity (evidence: `ml-anomaly-service/ml_service.py`)
- Inference Endpoint → Cause Ranking: ranks metrics (evidence: `ml-anomaly-service/ml_service.py`)
- Inference Endpoint → Prediction DTO: returns prediction (evidence: `README.md`)
- Log Controller → Stored Log: builds record (evidence: `spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java`)
- Log Controller → Log Repository: saves record (evidence: `spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java`)
- Log Repository → MongoDB Atlas: persists logs (evidence: `README.md`)
- Log Controller → API Client: returns prediction (evidence: `spring-anomaly-api/src/main/java/com/anomaly/endpoint/controller/LogController.java`)
