diff options
| author | 2026-04-15 16:26:00 +0700 | |
|---|---|---|
| committer | 2026-04-15 16:26:00 +0700 | |
| commit | 129e48683f6fc0615b606a737f2afcd50538bb2e (patch) | |
| tree | 4c9481f725bef512ca58cb6daaef467f9ca1de2c /CLAUDE.md | |
| parent | d3b9bd54cc3e13b5a9d16404717551238eab18c6 (diff) | |
| download | articlator-129e48683f6fc0615b606a737f2afcd50538bb2e.tar.gz articlator-129e48683f6fc0615b606a737f2afcd50538bb2e.zip | |
feat: s3 storage client
feat: claude.md
Diffstat (limited to 'CLAUDE.md')
| -rw-r--r-- | CLAUDE.md | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..f96e149 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,38 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +Go service that extracts YAML frontmatter metadata from markdown files stored in cloud object storage (Backblaze B2 or AWS S3), then writes that metadata back as object attributes/metadata. Supports draft/prod workflow where draft files (`.draft.md`) are compared against prod (`.md`) and skipped if unchanged. + +## Commands + +```bash +# Build +go build -o metadata-extractor main.go + +# Run (requires B2_KEY_ID and B2_APPLICATION_KEY env vars, see .envrc) +go run main.go -c config/config.json + +# No tests or linter configured yet +``` + +## Architecture + +Three-layer pipeline: **Config → Storage → Frontmatter parsing** + +- `main.go` — Entry point. Loads config, scans bucket, fans out goroutines (semaphore-bounded) to process each file: read → parse frontmatter → write metadata back as object attributes. +- `config/config.go` — Loads JSON config with `os.ExpandEnv()` for credential injection. Validates via `validator/v10` struct tags. Storage type (`"b2"` or `"s3"`) selects which config struct and client to use. +- `internal/storage/storage_interface.go` — `StorageClient` interface (`Scan`, `GetReader`, `WriteMetadata`, `CompareDraftAndProd`). Factory map registers all backends. +- `internal/storage/b2.go` — Backblaze B2 implementation. Uses SHA1 for draft/prod change tracking. Writes metadata to B2 object `Info` map. +- `internal/storage/s3.go` — AWS S3 implementation (AWS SDK v2). Uses ETag for draft/prod change tracking. Writes metadata as S3 user metadata. Supports custom `Endpoint` + `UsePathStyle` for S3-compatible stores (MinIO, etc). +- `internal/frontmatter/parser.go` — Extracts content between `---` delimiters, unmarshals YAML into `Metadata` struct. + +## Key Conventions + +- Metadata keys use kebab-case (e.g., `short-description`, `action-date`) — stored in B2 `Info` map or S3 user metadata +- Geolocation format: `"{x} {y}"` or `"{x} {y} {areaError}"` — space-separated floats, validated in both storage backends +- Change tracking: B2 uses SHA1 (`metadata-last-update-sha1`), S3 uses ETag (`metadata-last-update-etag`) +- Semantic commit messages: `feat:`, `fix:`, `refactor:` +- Structured logging via `log/slog` |