# sumanthkm06/opstrace architecture

> Architecture diagram of the GitHub repository sumanthkm06/opstrace, 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/sumanthkm06/opstrace
- Repository: https://github.com/sumanthkm06/opstrace

## Overview

OpsTrace is a Linux infrastructure monitor and incident-investigation platform. Its main workflow collects host telemetry and raw logs, submits them to a FastAPI backend for persistence and analysis, and presents fleet health, logs, incidents, and dependency impact in a React dashboard. The backend also supports change correlation, incident timelines, controlled remediation with audit records, failure simulation, and Prometheus self-monitoring. The README documents the system-level connections; sampled source and the SOURCE INDEX support selected internal links. Several unsampled routes and subsystem details are therefore shown only where documented.

Main entry points: [`backend/app/engines/incident_engine.py`](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/incident_engine.py) (Incident Engine), [`collector/main.py`](https://github.com/sumanthkm06/opstrace/blob/main/collector/main.py) (Collector Daemon), [`backend/app/models`](https://github.com/sumanthkm06/opstrace/tree/main/backend/app/models) (Relational Models), [`collector/app/clients/backend.py`](https://github.com/sumanthkm06/opstrace/blob/main/collector/app/clients/backend.py) (Backend Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Host Collection"]
  node_collector["Collector Daemon<br/>[main.py]"]
  node_host_metrics["Host Metrics<br/>[models.py]"]
  node_log_collection["Log Collection<br/>[log_file.py]"]
  node_log_parsing["Log Parsing<br/>[log_parser.py]"]
  node_backend_client["Backend Client<br/>[backend.py]"]
end

subgraph group_backend["Backend Ingestion"]
  node_api["Versioned API<br/>[router.py]"]
  node_telemetry_api["Telemetry API<br/>[telemetry.py]"]
  node_telemetry_ingest["Telemetry Ingest"]
  node_log_ingest["Log Ingest<br/>[log_ingest.py]"]
end

subgraph group_analysis["Incident Analysis"]
  node_log_analysis["Log Analysis<br/>[log_analyzer.py]"]
  node_incident_detection["Incident Detection"]
  node_incident_engine["Incident Engine<br/>[incident_engine.py]"]
  node_change_correlation["Change Correlation"]
  node_dependency_analysis["Dependency Impact"]
  node_timeline["Incident Timeline<br/>[timeline_engine.py]"]
  node_remediation["Remediation Review"]
  node_simulation["Failure Simulation"]
end

subgraph group_frontend["Investigation UI"]
  node_web_app["Dashboard Routes<br/>[App.tsx]"]
  node_dashboard_pages["Fleet &amp; Incident Views<br/>[OverviewPage.tsx]"]
  node_api_client["Frontend API Client<br/>[api.ts]"]
end

subgraph group_operations["Persistence &amp; Operations"]
  node_database[("PostgreSQL")]
  node_models["Relational Models"]
  node_metrics_endpoint["Metrics Endpoint<br/>[prometheus.py]"]
end

node_host(("Linux Host"))
node_prometheus["Prometheus"]
node_user(("Engineer"))

node_host -->|"provides telemetry"| node_collector
node_collector -->|"collects"| node_host_metrics
node_collector -->|"collects logs"| node_log_collection
node_log_collection -->|"parses"| node_log_parsing
node_collector -->|"submits data"| node_backend_client
node_backend_client -->|"sends telemetry"| node_telemetry_api
node_api -->|"routes to"| node_telemetry_api
node_telemetry_api -->|"delegates to"| node_telemetry_ingest
node_telemetry_ingest -->|"persists samples"| node_models
node_backend_client -->|"sends logs"| node_log_ingest
node_log_ingest -->|"persists logs"| node_models
node_models -->|"stored in"| node_database
node_models -->|"feeds analysis"| node_log_analysis
node_log_analysis -.->|"supports detection"| node_incident_detection
node_incident_detection -.->|"informs incidents"| node_incident_engine
node_incident_engine -->|"supports correlation"| node_change_correlation
node_incident_engine -->|"supports impact analysis"| node_dependency_analysis
node_incident_engine -->|"supports replay"| node_timeline
node_incident_engine -->|"supports remediation"| node_remediation
node_api -->|"routes simulations"| node_simulation
node_user -->|"investigates"| node_web_app
node_web_app -->|"routes views"| node_dashboard_pages
node_dashboard_pages -->|"requests data"| node_api_client
node_api_client -->|"calls backend"| node_api
node_prometheus -->|"scrapes"| node_metrics_endpoint

click node_collector "https://github.com/sumanthkm06/opstrace/blob/main/collector/main.py"
click node_host_metrics "https://github.com/sumanthkm06/opstrace/blob/main/collector/app/collectors/models.py"
click node_log_collection "https://github.com/sumanthkm06/opstrace/blob/main/collector/app/collectors/log_file.py"
click node_log_parsing "https://github.com/sumanthkm06/opstrace/blob/main/collector/app/collectors/log_parser.py"
click node_backend_client "https://github.com/sumanthkm06/opstrace/blob/main/collector/app/clients/backend.py"
click node_api "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/api/v1/router.py"
click node_telemetry_api "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/api/v1/telemetry.py"
click node_telemetry_ingest "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/services/telemetry_ingest.py"
click node_log_ingest "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/services/log_ingest.py"
click node_log_analysis "https://github.com/sumanthkm06/opstrace/blob/main/collector/app/analyzers/log_analyzer.py"
click node_incident_detection "https://github.com/sumanthkm06/opstrace/blob/main/collector/app/detectors/incident_detector.py"
click node_incident_engine "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/incident_engine.py"
click node_change_correlation "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/correlation_engine.py"
click node_dependency_analysis "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/dependency_engine.py"
click node_timeline "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/timeline_engine.py"
click node_remediation "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/remediation_engine.py"
click node_simulation "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/services/failure_simulation.py"
click node_web_app "https://github.com/sumanthkm06/opstrace/blob/main/frontend/src/App.tsx"
click node_dashboard_pages "https://github.com/sumanthkm06/opstrace/blob/main/frontend/src/pages/OverviewPage.tsx"
click node_api_client "https://github.com/sumanthkm06/opstrace/blob/main/frontend/src/services/api.ts"
click node_models "https://github.com/sumanthkm06/opstrace/tree/main/backend/app/models"
click node_metrics_endpoint "https://github.com/sumanthkm06/opstrace/blob/main/backend/app/observability/prometheus.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_collector,node_host_metrics,node_log_collection,node_log_parsing,node_backend_client toneBlue
class node_api,node_telemetry_api,node_telemetry_ingest,node_log_ingest toneAmber
class node_log_analysis,node_incident_detection,node_incident_engine,node_change_correlation,node_dependency_analysis,node_timeline,node_remediation,node_simulation toneMint
class node_web_app,node_dashboard_pages,node_api_client toneRose
class node_database,node_models,node_metrics_endpoint,node_host,node_prometheus,node_user toneIndigo
```

## Components

### Host Collection

- [Collector Daemon](https://github.com/sumanthkm06/opstrace/blob/main/collector/main.py): `collector/main.py`
- [Host Metrics](https://github.com/sumanthkm06/opstrace/blob/main/collector/app/collectors/models.py): `collector/app/collectors/models.py`
- [Log Collection](https://github.com/sumanthkm06/opstrace/blob/main/collector/app/collectors/log_file.py): `collector/app/collectors/log_file.py`
- [Log Parsing](https://github.com/sumanthkm06/opstrace/blob/main/collector/app/collectors/log_parser.py): `collector/app/collectors/log_parser.py`
- [Backend Client](https://github.com/sumanthkm06/opstrace/blob/main/collector/app/clients/backend.py): `collector/app/clients/backend.py`

### Backend Ingestion

- [Versioned API](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Telemetry API](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/api/v1/telemetry.py): `backend/app/api/v1/telemetry.py`
- [Telemetry Ingest](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/services/telemetry_ingest.py): `backend/app/services/telemetry_ingest.py`
- [Log Ingest](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/services/log_ingest.py): `backend/app/services/log_ingest.py`

### Incident Analysis

- [Log Analysis](https://github.com/sumanthkm06/opstrace/blob/main/collector/app/analyzers/log_analyzer.py): `collector/app/analyzers/log_analyzer.py`
- [Incident Detection](https://github.com/sumanthkm06/opstrace/blob/main/collector/app/detectors/incident_detector.py): `collector/app/detectors/incident_detector.py`
- [Incident Engine](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/incident_engine.py): `backend/app/engines/incident_engine.py`
- [Change Correlation](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/correlation_engine.py): `backend/app/engines/correlation_engine.py`
- [Dependency Impact](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/dependency_engine.py): `backend/app/engines/dependency_engine.py`
- [Incident Timeline](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/timeline_engine.py): `backend/app/engines/timeline_engine.py`
- [Remediation Review](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/engines/remediation_engine.py): `backend/app/engines/remediation_engine.py`
- [Failure Simulation](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/services/failure_simulation.py): `backend/app/services/failure_simulation.py`

### Investigation UI

- [Dashboard Routes](https://github.com/sumanthkm06/opstrace/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Fleet & Incident Views](https://github.com/sumanthkm06/opstrace/blob/main/frontend/src/pages/OverviewPage.tsx): `frontend/src/pages/OverviewPage.tsx`
- [Frontend API Client](https://github.com/sumanthkm06/opstrace/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### Persistence & Operations

- **PostgreSQL**
- [Relational Models](https://github.com/sumanthkm06/opstrace/tree/main/backend/app/models): `backend/app/models`
- [Metrics Endpoint](https://github.com/sumanthkm06/opstrace/blob/main/backend/app/observability/prometheus.py): `backend/app/observability/prometheus.py`

### Other components

- **Linux Host**
- **Prometheus**
- **Engineer**

## Connections

- Linux Host → Collector Daemon: provides telemetry
- Collector Daemon → Host Metrics: collects (evidence: `collector/main.py`)
- Collector Daemon → Log Collection: collects logs (evidence: `collector/main.py`)
- Log Collection → Log Parsing: parses (evidence: `collector/app/collectors/log_parser.py`)
- Collector Daemon → Backend Client: submits data (evidence: `collector/main.py`)
- Backend Client → Telemetry API: sends telemetry
- Versioned API → Telemetry API: routes to (evidence: `backend/app/api/v1/router.py`)
- Telemetry API → Telemetry Ingest: delegates to (evidence: `backend/app/api/v1/telemetry.py`)
- Telemetry Ingest → Relational Models: persists samples
- Backend Client → Log Ingest: sends logs
- Log Ingest → Relational Models: persists logs (evidence: `backend/app/services/log_ingest.py`)
- Relational Models → PostgreSQL: stored in
- Relational Models → Log Analysis: feeds analysis
- Log Analysis → Incident Detection: supports detection
- Incident Detection → Incident Engine: informs incidents
- Incident Engine → Change Correlation: supports correlation
- Incident Engine → Dependency Impact: supports impact analysis
- Incident Engine → Incident Timeline: supports replay
- Incident Engine → Remediation Review: supports remediation
- Versioned API → Failure Simulation: routes simulations (evidence: `backend/app/api/v1/router.py`)
- Engineer → Dashboard Routes: investigates
- Dashboard Routes → Fleet & Incident Views: routes views (evidence: `frontend/src/App.tsx`)
- Fleet & Incident Views → Frontend API Client: requests data
- Frontend API Client → Versioned API: calls backend
- Prometheus → Metrics Endpoint: scrapes
