# tom-draper/log-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/tom-draper/log-analyzer
- Repository: https://github.com/tom-draper/log-analyzer

## Overview

Log Analyzer is a Go log-processing CLI that extracts typed fields from configured patterns, then serves a browser dashboard; it also supports export, format suggestions, and live-follow mode. The dashboard presents coverage, request summaries, per-token statistics, distributions, time trends, locations, and dependency views. The principal flow runs from CLI input through parsing and analysis into HTTP-served data consumed by the Svelte app. Several parser internals and dashboard components are unsampled, so their detailed internal links are omitted.

Main entry points: [`dashboard/src/App.svelte`](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/App.svelte) (Dashboard application), [`main.go`](https://github.com/tom-draper/log-analyzer/blob/main/main.go) (CLI workflow), [`pkg/analyze/analyze.go`](https://github.com/tom-draper/log-analyzer/blob/main/pkg/analyze/analyze.go) (Enrichment and run modes), [`dashboard/src/lib/Card.svelte`](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/Card.svelte) (Token analysis cards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["CLI and parsing"]
  node_cli["CLI workflow<br/>[main.go]"]
  node_config["Pattern configuration<br/>[config.go]"]
  node_extract["Log extraction<br/>[parse.go]"]
  node_follow["Stream following<br/>[follow.go]"]
  node_suggest["Format suggestion<br/>[main.go]"]
  node_similarity["Format similarity<br/>[similarity.go]"]
  node_clustering["Pattern clustering<br/>[kruskal.go]"]
end

subgraph group_analysis["Analysis and output"]
  node_analysis["Enrichment and run modes<br/>[analyze.go]"]
  node_geo["IP geolocation<br/>[location.go]"]
  node_export["Export formatting<br/>[export.go]"]
  node_display["Text display<br/>[display.go]"]
end

subgraph group_service["Dashboard service"]
  node_server["HTTP API<br/>[api.go]"]
  node_store[("Dashboard data store<br/>[store.go]")]
end

subgraph group_ui["Dashboard interface"]
  node_app["Dashboard application<br/>[App.svelte]"]
  node_cards["Token analysis cards<br/>[Card.svelte]"]
  node_dashboard_views["Dashboard summaries"]
  node_coverage["Pattern coverage"]
  node_funnel["Request funnel"]
  node_events["Event explorer"]
  node_type_warnings["Type warnings"]
  node_dependent_graph["Dependency frequency"]
  node_heatmap["Dependency heatmap"]
  node_time_series["Time trends"]
  node_time_breakdown["Time breakdown"]
  node_plot["Chart configuration<br/>[plot.ts]"]
  node_time_slots["Time slot utilities<br/>[timeSlots.ts]"]
  node_entry["Frontend entry<br/>[main.ts]"]
end

node_user(("Log analyst"))
node_browser(("Browser user"))

node_user -->|"runs"| node_cli
node_cli -.->|"loads config"| node_config
node_cli -->|"parses logs"| node_extract
node_cli -->|"starts dashboard"| node_analysis
node_cli -->|"starts follow"| node_follow
node_cli -.->|"exports records"| node_export
node_cli -.->|"prints records"| node_display
node_cli -->|"suggests patterns"| node_suggest
node_suggest -->|"groups formats"| node_similarity
node_similarity -.->|"uses clustering"| node_clustering
node_analysis -->|"accepts extractions"| node_extract
node_analysis -->|"resolves IPs"| node_geo
node_analysis -->|"updates store"| node_store
node_analysis -->|"starts server"| node_server
node_server -->|"reads and subscribes"| node_store
node_browser -->|"opens dashboard"| node_entry
node_entry -->|"mounts"| node_app
node_app -->|"fetches data"| node_server
node_app -->|"subscribes updates"| node_server
node_app -->|"renders cards"| node_cards
node_app -->|"renders metrics"| node_dashboard_views
node_app -->|"renders coverage"| node_coverage
node_app -->|"renders funnel"| node_funnel
node_app -->|"renders explorer"| node_events
node_app -->|"renders warnings"| node_type_warnings
node_cards -->|"renders dependencies"| node_dependent_graph
node_cards -->|"renders heatmap"| node_heatmap
node_cards -->|"renders trends"| node_time_series
node_cards -->|"renders breakdown"| node_time_breakdown
node_time_breakdown -->|"uses layout"| node_plot
node_time_series -->|"uses slots"| node_time_slots

click node_cli "https://github.com/tom-draper/log-analyzer/blob/main/main.go"
click node_config "https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/config.go"
click node_extract "https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/parse.go"
click node_follow "https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/follow.go"
click node_suggest "https://github.com/tom-draper/log-analyzer/blob/main/main.go"
click node_similarity "https://github.com/tom-draper/log-analyzer/blob/main/pkg/similarity/similarity.go"
click node_clustering "https://github.com/tom-draper/log-analyzer/blob/main/pkg/similarity/kruskal.go"
click node_analysis "https://github.com/tom-draper/log-analyzer/blob/main/pkg/analyze/analyze.go"
click node_geo "https://github.com/tom-draper/log-analyzer/blob/main/internal/location/location.go"
click node_export "https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/export.go"
click node_display "https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/display.go"
click node_server "https://github.com/tom-draper/log-analyzer/blob/main/internal/server/api.go"
click node_store "https://github.com/tom-draper/log-analyzer/blob/main/internal/server/store.go"
click node_app "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/App.svelte"
click node_cards "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/Card.svelte"
click node_dashboard_views "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/DashboardMetrics.svelte"
click node_coverage "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/PatternCoverage.svelte"
click node_funnel "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/RequestFunnel.svelte"
click node_events "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/EventExplorer.svelte"
click node_type_warnings "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/TypeWarnings.svelte"
click node_dependent_graph "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/ValueFreqGraphDependent.svelte"
click node_heatmap "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/DependencyHeatmap.svelte"
click node_time_series "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/OverTimeGraph.svelte"
click node_time_breakdown "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/TimeBreakdown.svelte"
click node_plot "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/plot.ts"
click node_time_slots "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/timeSlots.ts"
click node_entry "https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/main.ts"

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_cli,node_config,node_extract,node_follow,node_suggest,node_similarity,node_clustering,node_browser toneBlue
class node_analysis,node_geo,node_export,node_display toneAmber
class node_server,node_store toneMint
class node_app,node_cards,node_dashboard_views,node_coverage,node_funnel,node_events,node_type_warnings,node_dependent_graph,node_heatmap,node_time_series,node_time_breakdown,node_plot,node_time_slots,node_entry toneRose
class node_user toneIndigo
```

## Components

### CLI and parsing

- [CLI workflow](https://github.com/tom-draper/log-analyzer/blob/main/main.go): `main.go`
- [Pattern configuration](https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/config.go): `pkg/parse/config.go`
- [Log extraction](https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/parse.go): `pkg/parse/parse.go`
- [Stream following](https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/follow.go): `pkg/parse/follow.go`
- [Format suggestion](https://github.com/tom-draper/log-analyzer/blob/main/main.go): `main.go`
- [Format similarity](https://github.com/tom-draper/log-analyzer/blob/main/pkg/similarity/similarity.go): `pkg/similarity/similarity.go`
- [Pattern clustering](https://github.com/tom-draper/log-analyzer/blob/main/pkg/similarity/kruskal.go): `pkg/similarity/kruskal.go`

### Analysis and output

- [Enrichment and run modes](https://github.com/tom-draper/log-analyzer/blob/main/pkg/analyze/analyze.go): `pkg/analyze/analyze.go`
- [IP geolocation](https://github.com/tom-draper/log-analyzer/blob/main/internal/location/location.go): `internal/location/location.go`
- [Export formatting](https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/export.go): `pkg/parse/export.go`
- [Text display](https://github.com/tom-draper/log-analyzer/blob/main/pkg/parse/display.go): `pkg/parse/display.go`

### Dashboard service

- [HTTP API](https://github.com/tom-draper/log-analyzer/blob/main/internal/server/api.go): `internal/server/api.go`
- [Dashboard data store](https://github.com/tom-draper/log-analyzer/blob/main/internal/server/store.go): `internal/server/store.go`

### Dashboard interface

- [Dashboard application](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/App.svelte): `dashboard/src/App.svelte`
- [Token analysis cards](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/Card.svelte): `dashboard/src/lib/Card.svelte`
- [Dashboard summaries](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/DashboardMetrics.svelte): `dashboard/src/lib/DashboardMetrics.svelte`
- [Pattern coverage](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/PatternCoverage.svelte): `dashboard/src/lib/PatternCoverage.svelte`
- [Request funnel](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/RequestFunnel.svelte): `dashboard/src/lib/RequestFunnel.svelte`
- [Event explorer](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/EventExplorer.svelte): `dashboard/src/lib/EventExplorer.svelte`
- [Type warnings](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/TypeWarnings.svelte): `dashboard/src/lib/TypeWarnings.svelte`
- [Dependency frequency](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/ValueFreqGraphDependent.svelte): `dashboard/src/lib/ValueFreqGraphDependent.svelte`
- [Dependency heatmap](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/DependencyHeatmap.svelte): `dashboard/src/lib/DependencyHeatmap.svelte`
- [Time trends](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/OverTimeGraph.svelte): `dashboard/src/lib/OverTimeGraph.svelte`
- [Time breakdown](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/TimeBreakdown.svelte): `dashboard/src/lib/TimeBreakdown.svelte`
- [Chart configuration](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/plot.ts): `dashboard/src/lib/plot.ts`
- [Time slot utilities](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/lib/timeSlots.ts): `dashboard/src/lib/timeSlots.ts`
- [Frontend entry](https://github.com/tom-draper/log-analyzer/blob/main/dashboard/src/main.ts): `dashboard/src/main.ts`

### Other components

- **Log analyst**
- **Browser user**

## Connections

- Log analyst → CLI workflow: runs
- CLI workflow → Pattern configuration: loads config
- CLI workflow → Log extraction: parses logs (evidence: `main.go`)
- CLI workflow → Enrichment and run modes: starts dashboard (evidence: `main.go`)
- CLI workflow → Stream following: starts follow (evidence: `main.go`)
- CLI workflow → Export formatting: exports records
- CLI workflow → Text display: prints records
- CLI workflow → Format suggestion: suggests patterns (evidence: `main.go`)
- Format suggestion → Format similarity: groups formats (evidence: `main.go`)
- Format similarity → Pattern clustering: uses clustering
- Enrichment and run modes → Log extraction: accepts extractions (evidence: `pkg/analyze/analyze.go`)
- Enrichment and run modes → IP geolocation: resolves IPs (evidence: `pkg/analyze/analyze.go`)
- Enrichment and run modes → Dashboard data store: updates store (evidence: `pkg/analyze/analyze.go`)
- Enrichment and run modes → HTTP API: starts server (evidence: `pkg/analyze/analyze.go`)
- HTTP API → Dashboard data store: reads and subscribes (evidence: `internal/server/api.go`)
- Browser user → Frontend entry: opens dashboard
- Frontend entry → Dashboard application: mounts (evidence: `dashboard/src/main.ts`)
- Dashboard application → HTTP API: fetches data (evidence: `dashboard/src/App.svelte`)
- Dashboard application → HTTP API: subscribes updates (evidence: `dashboard/src/App.svelte`)
- Dashboard application → Token analysis cards: renders cards (evidence: `dashboard/src/App.svelte`)
- Dashboard application → Dashboard summaries: renders metrics (evidence: `dashboard/src/App.svelte`)
- Dashboard application → Pattern coverage: renders coverage (evidence: `dashboard/src/App.svelte`)
- Dashboard application → Request funnel: renders funnel (evidence: `dashboard/src/App.svelte`)
- Dashboard application → Event explorer: renders explorer (evidence: `dashboard/src/App.svelte`)
- Dashboard application → Type warnings: renders warnings (evidence: `dashboard/src/App.svelte`)
- Token analysis cards → Dependency frequency: renders dependencies (evidence: `dashboard/src/lib/Card.svelte`)
- Token analysis cards → Dependency heatmap: renders heatmap (evidence: `dashboard/src/lib/Card.svelte`)
- Token analysis cards → Time trends: renders trends (evidence: `dashboard/src/lib/Card.svelte`)
- Token analysis cards → Time breakdown: renders breakdown (evidence: `dashboard/src/lib/Card.svelte`)
- Time breakdown → Chart configuration: uses layout (evidence: `dashboard/src/lib/TimeBreakdown.svelte`)
- Time trends → Time slot utilities: uses slots (evidence: `dashboard/src/lib/OverTimeGraph.svelte`)
