aboutsummaryrefslogtreecommitdiff
path: root/CLAUDE.md
blob: 1bf4d88ccfbe5a0cc5650bb2eae8bfa857208686 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
## Project Overview

cgithub is a lightweight GitHub alternative frontend that scrapes GitHub's server-rendered HTML instead of using the API. Data is usually extracted from embedded JSON data from `<script type="application/json">` tags that GitHub includes for hydration.

## Commands

```bash
# Development (watch mode with hot reload)
pnpm run dev

# Production build (bundles to dist/)
pnpm run build

# Run tests
pnpm test

# Cloudflare Workers: local dev and deploy
pnpm run dev:cf
pnpm run deploy:cf
```

## Architecture

**Stack:** Hono (web framework) + Eta (templating) + TypeScript, bundled with esbuild

**Source files:**
- `src/app.ts` - Hono routes, shared by both entry points
- `src/index.ts` - Node server entry (supports systemd socket activation via `LISTEN_FDS=1`)
- `src/worker.ts` - Cloudflare Workers entry (config in `wrangler.jsonc`)
- `src/scraper.ts` - GitHub HTML fetching and JSON extraction logic

**Templates:** `views/*.eta` - Eta templates with layout inheritance (`layout.eta` as base). On Workers, runtime code generation is disallowed, so `scripts/compile-views.ts` precompiles templates to `src/views.generated.ts` (gitignored, regenerated by the `dev:cf`/`deploy:cf` scripts).

**Static files:** `public/static/*`, served by `@hono/node-server` on Node and by Workers Static Assets on Cloudflare.

**Routes:**
- `GET /:owner` - User or organization profile with pinned repositories
- `GET /:owner/:repo` - Repository info with directory listing
- `GET /:owner/:repo/tree/:branch/:path*` - Directory listing
- `GET /:owner/:repo/blob/:branch/:path` - File content view

## Instructions

- Use `for (const ... of ...)` instead of `.forEach()`
- Update `scraper.test.ts`