You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cooldown requires publish timestamps in metadata. Registries without a "Yes" in the cooldown column either don't expose timestamps or haven't been wired up yet.
52
54
53
55
## Quick Start
54
56
@@ -465,9 +467,10 @@ Recently cached:
465
467
466
468
| Endpoint | Description |
467
469
|----------|-------------|
468
-
|`GET /`|Welcome message and endpoint list|
470
+
|`GET /`|Dashboard (web UI)|
469
471
|`GET /health`| Health check (returns "ok" if healthy) |
470
472
|`GET /stats`| Cache statistics (JSON) |
473
+
|`GET /metrics`| Prometheus metrics |
471
474
|`GET /npm/*`| npm registry protocol |
472
475
|`GET /cargo/*`| Cargo sparse index protocol |
473
476
|`GET /gem/*`| RubyGems protocol |
@@ -667,6 +670,46 @@ Response:
667
670
└─────────┘
668
671
```
669
672
673
+
## Web Interface
674
+
675
+
The proxy serves a web UI at the root URL. No separate frontend build is needed -- templates and assets are embedded in the binary.
676
+
677
+
-**Dashboard** (`/`) -- cache stats, popular packages, recently cached artifacts, and vulnerability overview.
678
+
-**Install guide** (`/install`) -- per-ecosystem configuration instructions, so you don't have to look them up here.
679
+
-**Package browser** (`/packages`) -- browse all cached packages with filtering by ecosystem and sorting by hits, size, name, or vulnerability count.
680
+
-**Search** (`/search?q=...`) -- search cached packages by name.
681
+
-**Package detail** (`/package/{ecosystem}/{name}`) -- metadata, license, vulnerabilities, and version list for a package. You can select two versions to compare.
682
+
-**Version detail** (`/package/{ecosystem}/{name}/{version}`) -- per-version metadata, integrity hash, artifact cache status, and hit counts.
683
+
-**Source browser** (`/package/{ecosystem}/{name}/{version}/browse`) -- browse files inside cached archives with syntax highlighting for text files and image previews.
684
+
-**Version diff** (`/package/{ecosystem}/{name}/compare/{v1}...{v2}`) -- side-by-side diff of two cached versions showing added, removed, and changed files.
685
+
686
+
## Monitoring
687
+
688
+
The proxy exposes Prometheus metrics at `GET /metrics`. All metric names are prefixed with `proxy_`.
@@ -7,29 +7,24 @@ This document describes the internal architecture of the git-pkgs proxy.
7
7
The proxy is a caching HTTP server that sits between package manager clients and upstream registries. It intercepts requests, checks a local cache, and either serves cached content or fetches from upstream.
@@ -91,36 +86,95 @@ Metadata is not cached - always fetched fresh. This ensures clients see new vers
91
86
92
87
### `internal/database`
93
88
94
-
SQLite database for cache metadata. Uses `modernc.org/sqlite` (pure Go, no CGO).
89
+
SQLite or PostgreSQL database for cache metadata. SQLite uses `modernc.org/sqlite` (pure Go, no CGO). PostgreSQL uses `lib/pq`.
90
+
91
+
The schema is compatible with [git-pkgs](https://github.com/git-pkgs) databases. The proxy adds the `artifacts` and `vulnerabilities` tables on top of the shared `packages` and `versions` tables, so both tools can point at the same database.
On PostgreSQL, `INTEGER PRIMARY KEY` becomes `SERIAL`, `DATETIME` becomes `TIMESTAMP`, `INTEGER DEFAULT 0` booleans become `BOOLEAN DEFAULT FALSE`, and size/count columns use `BIGINT`.
167
+
168
+
The `MigrateSchema()` function handles backward compatibility with older git-pkgs databases by adding missing columns via `ALTER TABLE` as needed.
169
+
117
170
**Key operations:**
118
171
-`GetPackageByPURL()` - Look up package by PURL
119
172
-`GetVersionByPURL()` - Look up version by PURL
120
173
-`GetArtifact()` - Look up artifact by version + filename
121
174
-`UpsertPackage/Version/Artifact()` - Insert or update records
122
175
-`RecordArtifactHit()` - Increment hit counter, update access time
123
176
-`GetLeastRecentlyUsedArtifacts()` - For cache eviction
177
+
-`SearchPackages()` - Full-text search across cached packages
124
178
125
179
### `internal/storage`
126
180
@@ -201,12 +255,27 @@ HTTP protocol handlers for each registry type.
201
255
202
256
### `internal/server`
203
257
204
-
HTTP server setup.
258
+
HTTP server setup, web UI, and API handlers.
205
259
206
260
- Creates and wires together all components
207
-
- Mounts handlers at appropriate paths
208
-
- Adds logging middleware
209
-
- Health and stats endpoints
261
+
- Mounts protocol handlers at ecosystem-specific paths
262
+
- Middleware: request ID, real IP, logging, panic recovery, active request tracking
263
+
- Web UI: dashboard, package browser, source browser, version comparison
264
+
- Templates are embedded in the binary via `//go:embed`
265
+
- Enrichment API for package metadata, vulnerability scanning, and outdated detection
266
+
- Health, stats, and Prometheus metrics endpoints
267
+
268
+
### `internal/metrics`
269
+
270
+
Prometheus metrics for cache performance, upstream latency, storage operations, and active requests. See the Monitoring section of the README for the full metric list.
271
+
272
+
### `internal/cooldown`
273
+
274
+
Version age filtering for supply chain attack mitigation. Configurable at global, ecosystem, and per-package levels. Supported by npm, PyPI, pub.dev, and Composer handlers.
275
+
276
+
### `internal/enrichment`
277
+
278
+
Package metadata enrichment. Fetches license, description, homepage, repository URL, and vulnerability data from upstream registries. Powers the `/api/` endpoints and the web UI's package detail pages.
0 commit comments