feat: rewrite the backend in Rust

Replaces the Go server with a Rust one (axum, tokio, sqlx, feed-rs,
ammonia, reqwest) serving the same REST/WebSocket API, so the React
frontend is unchanged.

- Same database: migrations keep the schema_migrations table and file
  names, Argon2id hashes and hashed session tokens created by the Go
  server keep working (users stay logged in), and feed item GUIDs are
  computed the same way, so existing articles are not re-ingested.
- Same security model: SSRF-safe fetching (public addresses only,
  checked at resolution time and on every redirect), HTML sanitization,
  CSP and security headers, same-origin guard, WebSocket origin check,
  per-IP / per-user rate limits, trusted-proxy aware client IPs.
- Fix: articles whose publication date lies in the future (ingested
  before the clamp existed) pinned the top of the list. The maintenance
  job now pulls such dates back at startup and daily.
- Relative links and images in feed content are resolved against the
  article URL instead of being dropped.
- Deploy: static musl binary in an Alpine image; the Unraid compose file
  uses pull_policy: always so the new image is applied on the next
  `docker compose up -d`. CI runs fmt, clippy and tests (including a
  PostgreSQL integration test) before building the image.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fc1UFpB4V1MGWLxHAu3BMK
This commit is contained in:
Claude committed 2026-10-13 10:56:18 +00:00
1 parent 5a16769eb9
commit f3816f4d78
70 files changed
+8127 -5283

No files matched your search

+16 -35
View File
@@ -1,26 +1,28 @@
.PHONY: dev build run test lint clean docker-up docker-down migrate-up migrate-down migrate-create
.PHONY: dev build run test lint fmt clean web docker-up docker-down docker-logs
# Development
# Development (expects a PostgreSQL reachable through DATABASE_URL)
dev:
go run ./cmd/server
cargo run
build:
go build -o bin/server ./cmd/server
cargo build --release
run: build
./bin/server
./target/release/flowreader
# Testing
web:
cd web && npm ci && npm run build
# Testing. Set TEST_DATABASE_URL to also run the database integration test.
test:
go test -v ./...
cargo test
test-coverage:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
# Linting
lint:
golangci-lint run
cargo fmt --check
cargo clippy --all-targets -- -D warnings
fmt:
cargo fmt
# Docker
docker-up:
@@ -32,27 +34,6 @@ docker-down:
docker-logs:
docker-compose logs -f
# Database migrations
# Requires: go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
DB_URL ?= postgres://flowreader:flowreader@localhost:5432/flowreader?sslmode=disable
migrate-up:
migrate -path ./migrations -database "$(DB_URL)" up
migrate-down:
migrate -path ./migrations -database "$(DB_URL)" down 1
migrate-drop:
migrate -path ./migrations -database "$(DB_URL)" drop -f
migrate-create:
@read -p "Migration name: " name; \
migrate create -ext sql -dir ./migrations -seq $$name
migrate-version:
migrate -path ./migrations -database "$(DB_URL)" version
# Cleanup
clean:
rm -rf bin/
rm -f coverage.out coverage.html
cargo clean