···11# Claude Code
22-CLAUDE.md
32.claude/
4354# Git worktrees
+77
AGENTS.md
···11+# Barazo API -- AppView Backend
22+33+<!-- Auto-generated from barazo-workspace. To propose changes, edit the source:
44+ https://github.com/barazo-forum/barazo-workspace/tree/main/agents-md -->
55+66+AGPL-3.0 | Part of [github.com/barazo-forum](https://github.com/barazo-forum)
77+88+The AppView backend for Barazo. Subscribes to AT Protocol firehose, indexes `forum.barazo.*` records in PostgreSQL, and exposes a REST API for all forum operations.
99+1010+## Tech Stack
1111+1212+| Component | Technology |
1313+|-----------|-----------|
1414+| Runtime | Node.js 24 LTS / TypeScript (strict) |
1515+| Framework | Fastify |
1616+| Protocol | @atproto/api, @atproto/oauth-client-node, @atproto/tap |
1717+| Database | PostgreSQL 16 (Drizzle ORM, Drizzle Kit migrations) |
1818+| Cache | Valkey |
1919+| Testing | Vitest + Supertest |
2020+| Logging | Pino (structured) |
2121+| Monitoring | GlitchTip (Sentry SDK-compatible) |
2222+| Security | Helmet + Zod + DOMPurify + rate limiting |
2323+2424+## What This Repo Does
2525+2626+- Subscribes to the AT Protocol firehose via Tap, filtering for `forum.barazo.*` collections
2727+- Indexes forum records (topics, replies, categories, reactions) in PostgreSQL
2828+- Exposes REST API routes: `/api/forum/*`, `/api/admin/*`
2929+- Runs in two modes: single-forum (one community) or global (all Barazo forums)
3030+- Handles AT Protocol OAuth authentication
3131+- Validates all firehose records before indexing (Zod)
3232+- Validates all API input (Zod), sanitizes all output (DOMPurify)
3333+3434+## API-Specific Standards
3535+3636+- Every API endpoint validates input with a Zod schema
3737+- Every firehose record validated before indexing
3838+- DOMPurify sanitization on all user-generated content output
3939+- Helmet + CSP + HSTS + rate limiting on all endpoints
4040+- GlitchTip error monitoring from first deployment
4141+- No raw SQL -- Drizzle ORM with parameterized queries only
4242+4343+---
4444+4545+## Project-Wide Standards
4646+4747+### About Barazo
4848+4949+Federated forum built on the [AT Protocol](https://atproto.com/). Portable identity, user-owned data, cross-community reputation.
5050+5151+- **Organization:** [github.com/barazo-forum](https://github.com/barazo-forum)
5252+- **License:** AGPL-3.0 (backend) / MIT (frontend, lexicons, deploy, website)
5353+- **Contributing:** See [CONTRIBUTING.md](https://github.com/barazo-forum/.github/blob/main/CONTRIBUTING.md)
5454+5555+### Coding Standards
5656+5757+1. **Test-Driven Development** -- write tests before implementation (Vitest).
5858+2. **Strict TypeScript** -- `strict: true`, no `any`, no `@ts-ignore`.
5959+3. **Conventional commits** -- `type(scope): description`.
6060+4. **CI must pass** -- lint, typecheck, tests, security scan on every PR.
6161+5. **Input validation** -- Zod schemas on all API inputs and firehose records.
6262+6. **Output sanitization** -- DOMPurify on all user-generated content.
6363+7. **No raw SQL** -- Drizzle ORM with parameterized queries only.
6464+8. **Structured logging** -- Pino logger, never `console.log`.
6565+9. **Accessibility** -- WCAG 2.2 AA, semantic HTML, keyboard navigable.
6666+6767+### Git Workflow
6868+6969+All changes go through Pull Requests -- never commit directly to `main`. Branch naming: `type/short-description` (e.g., `feat/add-reactions`, `fix/xss-sanitization`).
7070+7171+### AT Protocol Context
7272+7373+- Users own their data (stored on their Personal Data Server)
7474+- The AppView (barazo-api) indexes data from the AT Protocol firehose
7575+- Lexicons (`forum.barazo.*`) define the data schema contract
7676+- Identity is portable via DIDs -- no vendor lock-in
7777+- All record types are validated against lexicon schemas