# igordeoliveira/count-repo-lines architecture

> Architecture diagram of the GitHub repository igordeoliveira/count-repo-lines, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/igordeoliveira/count-repo-lines
- Repository: https://github.com/igordeoliveira/count-repo-lines

## Overview

This is an Express API that accepts a public GitHub repository URL and returns file line and byte totals grouped by extension. The workflow validates the URL, recursively reads GitHub’s repository listing and raw-file responses, then flattens and groups the results for the API response. HTTP requests use Redis-backed caching, concurrency limiting, and retries. The graph separates request handling, repository analysis, and external access; source excerpts show the main calls, while the README documents Redis caching. Tests and deployment files are excluded.

Main entry points: [`src/services/parseService.js`](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js) (Recursive file traversal), [`src/services/httpService.js`](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/httpService.js) (HTTP client), [`src/app.js`](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/app.js) (App configuration), [`src/api/index.js`](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/api/index.js) (API router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_request["API request handling"]
  node_server["Express server<br/>[index.js]"]
  node_app["App configuration<br/>[app.js]"]
  node_router["API router<br/>[index.js]"]
  node_validation["URL validation<br/>[middlewares.js]"]
  node_errors["Error handling<br/>[middlewares.js]"]
  node_repo_handler["Repository endpoint<br/>[index.js]"]
end

subgraph group_analysis["Repository analysis"]
  node_repo_service["Repository analysis<br/>[parseService.js]"]
  node_listing["Tree listing parser<br/>[parseService.js]"]
  node_tree["Recursive file traversal<br/>[parseService.js]"]
  node_file_metadata["File metadata parsing<br/>[parseService.js]"]
  node_aggregation["Extension aggregation<br/>[parseService.js]"]
end

subgraph group_access["External access"]
  node_http_client["HTTP client<br/>[httpService.js]"]
  node_redis[("Redis cache")]
end

node_caller(("API caller"))
node_github["GitHub"]

node_caller -->|"requests API"| node_server
node_server -->|"starts"| node_app
node_app -->|"mounts API"| node_router
node_app -->|"registers handlers"| node_errors
node_router -->|"validates route"| node_validation
node_router -->|"routes request"| node_repo_handler
node_repo_handler -->|"gets repository info"| node_repo_service
node_repo_service -->|"gets file tree"| node_tree
node_repo_service -->|"flattens and groups"| node_aggregation
node_tree -->|"parses listing"| node_listing
node_tree -->|"recurses folders"| node_tree
node_tree -->|"fetches listings"| node_http_client
node_tree -->|"fetches raw files"| node_http_client
node_tree -->|"parses response headers"| node_file_metadata
node_http_client -->|"caches responses"| node_redis
node_http_client -->|"requests repository data"| node_github

click node_server "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/index.js"
click node_app "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/app.js"
click node_router "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/api/index.js"
click node_validation "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/middlewares.js"
click node_errors "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/middlewares.js"
click node_repo_handler "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/api/index.js"
click node_repo_service "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js"
click node_listing "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js"
click node_tree "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js"
click node_file_metadata "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js"
click node_aggregation "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js"
click node_http_client "https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/httpService.js"

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_server,node_app,node_router,node_validation,node_errors,node_repo_handler toneBlue
class node_repo_service,node_listing,node_tree,node_file_metadata,node_aggregation toneAmber
class node_http_client,node_redis,node_caller toneMint
class node_github toneIndigo
```

## Components

### API request handling

- [Express server](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/index.js): `src/index.js`
- [App configuration](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/app.js): `src/app.js`
- [API router](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/api/index.js): `src/api/index.js`
- [URL validation](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/middlewares.js): `src/middlewares.js`
- [Error handling](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/middlewares.js): `src/middlewares.js`
- [Repository endpoint](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/api/index.js): `src/api/index.js`

### Repository analysis

- [Repository analysis](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js): `src/services/parseService.js`
- [Tree listing parser](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js): `src/services/parseService.js`
- [Recursive file traversal](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js): `src/services/parseService.js`
- [File metadata parsing](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js): `src/services/parseService.js`
- [Extension aggregation](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/parseService.js): `src/services/parseService.js`

### External access

- [HTTP client](https://github.com/igordeoliveira/count-repo-lines/blob/master/src/services/httpService.js): `src/services/httpService.js`
- **Redis cache**

### Other components

- **API caller**
- **GitHub**

## Connections

- API caller → Express server: requests API (evidence: `README.md`)
- Express server → App configuration: starts (evidence: `src/index.js`)
- App configuration → API router: mounts API (evidence: `src/app.js`)
- App configuration → Error handling: registers handlers (evidence: `src/app.js`)
- API router → URL validation: validates route (evidence: `src/api/index.js`)
- API router → Repository endpoint: routes request (evidence: `src/api/index.js`)
- Repository endpoint → Repository analysis: gets repository info (evidence: `src/api/index.js`)
- Repository analysis → Recursive file traversal: gets file tree (evidence: `src/services/parseService.js`)
- Repository analysis → Extension aggregation: flattens and groups (evidence: `src/services/parseService.js`)
- Recursive file traversal → Tree listing parser: parses listing (evidence: `src/services/parseService.js`)
- Recursive file traversal → Recursive file traversal: recurses folders (evidence: `src/services/parseService.js`)
- Recursive file traversal → HTTP client: fetches listings (evidence: `src/services/parseService.js`)
- Recursive file traversal → HTTP client: fetches raw files (evidence: `src/services/parseService.js`)
- Recursive file traversal → File metadata parsing: parses response headers (evidence: `src/services/parseService.js`)
- HTTP client → Redis cache: caches responses (evidence: `README.md`)
- HTTP client → GitHub: requests repository data (evidence: `src/services/httpService.js`)
