# swastik2828/codescope architecture

> Architecture diagram of the GitHub repository swastik2828/codescope, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/swastik2828/codescope
- Repository: https://github.com/swastik2828/codescope

## Overview

CodeScope is a static-analysis CLI: a developer selects a local or GitHub repository, and the CLI resolves it, gathers file and Go-symbol data, derives dependency links and cycles, calculates health, and generates a report. The README also describes architecture mapping, structural metrics, and an interactive HTML dashboard; the sampled CLI and report code support these outputs. The CLI performs its own file walk, so the separate scanner package is not shown as part of this runtime path. Some report-generation details are omitted because the HTML source excerpt is partial.

Main entry points: [`cmd/codescope/main.go`](https://github.com/swastik2828/codescope/blob/main/cmd/codescope/main.go) (Analyze command), [`internal/source/github.go`](https://github.com/swastik2828/codescope/blob/main/internal/source/github.go) (GitHub resolver), [`internal/parser/go_parser.go`](https://github.com/swastik2828/codescope/blob/main/internal/parser/go_parser.go) (Go parser), [`internal/report/html.go`](https://github.com/swastik2828/codescope/blob/main/internal/report/html.go) (Report generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_cli["Analyze command<br/>[main.go]"]
  node_config["Configuration<br/>[config.go]"]
end

subgraph group_sources["Repository sources"]
  node_local["Local resolver<br/>[local.go]"]
  node_github["GitHub resolver<br/>[github.go]"]
  node_extractor["Archive extractor<br/>[archive.go]"]
end

subgraph group_analysis["Static analysis"]
  node_parser["Go parser<br/>[go_parser.go]"]
  node_graph["Dependency graph<br/>[graph.go]"]
  node_cycles["Cycle detection<br/>[scc.go]"]
  node_metrics["Health metrics<br/>[health.go]"]
end

subgraph group_outputs["Results and reports"]
  node_contract["Analysis report model<br/>[schema.go]"]
  node_report["Report generator<br/>[html.go]"]
end

node_developer(("Developer"))
node_github_service["GitHub"]
node_report_reader(("Report reader"))

node_developer -->|"runs analysis"| node_cli
node_cli -->|"resolves local"| node_local
node_cli -->|"resolves remote"| node_github
node_github -->|"clones or downloads"| node_github_service
node_github -->|"extracts archive"| node_extractor
node_cli -->|"loads settings"| node_config
node_cli -->|"parses Go files"| node_parser
node_parser -->|"returns symbols"| node_cli
node_cli -->|"adds dependencies"| node_graph
node_cli -->|"detects cycles"| node_cycles
node_cli -->|"calculates health"| node_metrics
node_cli -->|"builds report data"| node_contract
node_cli -->|"generates output"| node_report
node_report -->|"writes HTML report"| node_report_reader

click node_cli "https://github.com/swastik2828/codescope/blob/main/cmd/codescope/main.go"
click node_local "https://github.com/swastik2828/codescope/blob/main/internal/source/local.go"
click node_github "https://github.com/swastik2828/codescope/blob/main/internal/source/github.go"
click node_extractor "https://github.com/swastik2828/codescope/blob/main/internal/source/archive.go"
click node_config "https://github.com/swastik2828/codescope/blob/main/internal/config/config.go"
click node_parser "https://github.com/swastik2828/codescope/blob/main/internal/parser/go_parser.go"
click node_graph "https://github.com/swastik2828/codescope/blob/main/internal/graph/graph.go"
click node_cycles "https://github.com/swastik2828/codescope/blob/main/internal/graph/scc.go"
click node_metrics "https://github.com/swastik2828/codescope/blob/main/internal/metrics/health.go"
click node_contract "https://github.com/swastik2828/codescope/blob/main/internal/model/schema.go"
click node_report "https://github.com/swastik2828/codescope/blob/main/internal/report/html.go"

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 toneBlue
class node_local,node_github,node_extractor toneAmber
class node_parser,node_graph,node_cycles,node_metrics toneMint
class node_contract,node_report toneRose
class node_developer,node_github_service,node_report_reader toneIndigo
```

## Components

### CLI workflow

- [Analyze command](https://github.com/swastik2828/codescope/blob/main/cmd/codescope/main.go): `cmd/codescope/main.go`
- [Configuration](https://github.com/swastik2828/codescope/blob/main/internal/config/config.go): `internal/config/config.go`

### Repository sources

- [Local resolver](https://github.com/swastik2828/codescope/blob/main/internal/source/local.go): `internal/source/local.go`
- [GitHub resolver](https://github.com/swastik2828/codescope/blob/main/internal/source/github.go): `internal/source/github.go`
- [Archive extractor](https://github.com/swastik2828/codescope/blob/main/internal/source/archive.go): `internal/source/archive.go`

### Static analysis

- [Go parser](https://github.com/swastik2828/codescope/blob/main/internal/parser/go_parser.go): `internal/parser/go_parser.go`
- [Dependency graph](https://github.com/swastik2828/codescope/blob/main/internal/graph/graph.go): `internal/graph/graph.go`
- [Cycle detection](https://github.com/swastik2828/codescope/blob/main/internal/graph/scc.go): `internal/graph/scc.go`
- [Health metrics](https://github.com/swastik2828/codescope/blob/main/internal/metrics/health.go): `internal/metrics/health.go`

### Results and reports

- [Analysis report model](https://github.com/swastik2828/codescope/blob/main/internal/model/schema.go): `internal/model/schema.go`
- [Report generator](https://github.com/swastik2828/codescope/blob/main/internal/report/html.go): `internal/report/html.go`

### Other components

- **Developer**
- **GitHub**
- **Report reader**

## Connections

- Developer → Analyze command: runs analysis
- Analyze command → Local resolver: resolves local
- Analyze command → GitHub resolver: resolves remote
- GitHub resolver → GitHub: clones or downloads
- GitHub resolver → Archive extractor: extracts archive
- Analyze command → Configuration: loads settings
- Analyze command → Go parser: parses Go files
- Go parser → Analyze command: returns symbols
- Analyze command → Dependency graph: adds dependencies
- Analyze command → Cycle detection: detects cycles
- Analyze command → Health metrics: calculates health
- Analyze command → Analysis report model: builds report data
- Analyze command → Report generator: generates output
- Report generator → Report reader: writes HTML report
