refactor: replace chromedp with browser native print for PDF export

Remove chromedp dependency, use window.print() instead. Docker image no longer needs Chromium (~200MB smaller).

- Delete services/pdf.go and templates/reports/review.html

- Remove PDF API route POST /api/repos/:id/review/pdf

- Add @media print CSS to review page

- Remove chromium from Dockerfile
This commit is contained in:
2026-06-20 22:26:46 +08:00
parent 37aa9c0a33
commit 6c60b767df
10 changed files with 88 additions and 510 deletions
+4 -5
View File
@@ -8,10 +8,10 @@ PR-Helper is a self-hosted web service that auto-generates PR descriptions from
## Tech Stack
- **Backend**: Go + Gin + SQLite (go-sqlite3) + go-git + chromedp (PDF generation)
- **Backend**: Go + Gin + SQLite (go-sqlite3) + go-git
- **Frontend**: Go html/template + HTMX + D3.js + diff2html + Tailwind CSS
- **LLM**: OpenAI-compatible API (SSE streaming)
- **Deploy**: Docker (includes Chromium for PDF)
- **Deploy**: Docker
## Build & Run
@@ -35,18 +35,17 @@ services/ → Business logic (git ops, LLM calls, PDF gen, cache management)
models/ → Data models (repository, settings, analysis)
database/ → SQLite init and migrations
config/ → Configuration loading
templates/ → Go HTML templates (layouts/, pages/, partials/, reports/)
templates/ → Go HTML templates (layouts/, pages/, partials/)
static/ → CSS (Tailwind output), JS (graph, diff-viewer, sse), vendor libs
```
**Data flow**: Browser ↔ Gin handlers → services (git/llm/pdf) → SQLite + filesystem (`data/`)
**Data flow**: Browser ↔ Gin handlers → services (git/llm) → SQLite + filesystem (`data/`)
**Key service layer responsibilities**:
- `services/git.go` — clone, diff, graph data extraction via go-git
- `services/llm.go` — OpenAI-compatible API calls with SSE streaming
- `services/generate.go` — PR description generation (commits + diff → LLM → structured output)
- `services/review.go` — AI code review (per-file analysis + summary, Top-N strategy for large diffs)
- `services/pdf.go` — chromedp HTML→PDF conversion
- `services/cache.go` — repository cache lifecycle (clone, expiry cleanup)
## Key Patterns