|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is the BetterNow API Developer Documentation site (`developers.betternow.org`), a static documentation site that uses **schema-driven documentation generation**. API documentation is automatically generated from YAML schema definitions using PRMD, then combined with custom content and built into a static site using Middleman. |
| 8 | + |
| 9 | +## Development Commands |
| 10 | + |
| 11 | +### Local Development |
| 12 | +```bash |
| 13 | +# Start local development server with live reload |
| 14 | +docker compose up |
| 15 | + |
| 16 | +# Access at http://localhost:4567 or http://bndocs.test (if puma-dev configured) |
| 17 | + |
| 18 | +# Build inside running container |
| 19 | +docker compose exec web bin/build |
| 20 | +``` |
| 21 | + |
| 22 | +### Build Process |
| 23 | +```bash |
| 24 | +# Full build (schema compilation → docs generation → static site) |
| 25 | +bin/build |
| 26 | + |
| 27 | +# Or step by step: |
| 28 | +bundle exec rake schema:combine # Combine YAML schemas → source/schema.json |
| 29 | +bundle exec rake schema:verify # Validate compiled schema |
| 30 | +bundle exec rake schema:doc # Generate source/includes/resources.md |
| 31 | +bundle exec middleman build # Build static site → build/ |
| 32 | +``` |
| 33 | + |
| 34 | +### Rake Tasks |
| 35 | +```bash |
| 36 | +rake # Default: combine, verify, doc |
| 37 | +rake schema:combine # Combine schema YAML files into source/schema.json |
| 38 | +rake schema:verify # Validate the compiled schema |
| 39 | +rake schema:doc # Generate Markdown docs from schema |
| 40 | +``` |
| 41 | + |
| 42 | +### Deployment |
| 43 | +- Automatic deployment via GitHub Actions on push to master branch |
| 44 | +- Deploys to AWS S3 using OIDC authentication (no hardcoded credentials) |
| 45 | +- Manual deploy: `bin/deploy` (requires AWS credentials) |
| 46 | + |
| 47 | +## Architecture |
| 48 | + |
| 49 | +### Schema-Driven Documentation Flow |
| 50 | +``` |
| 51 | +schema/schemata/*.yml → [rake schema:combine] → source/schema.json |
| 52 | + ↓ |
| 53 | + [rake schema:doc] |
| 54 | + ↓ |
| 55 | +source/index.html.md + source/includes/resources.md → [middleman build] → build/ |
| 56 | +``` |
| 57 | + |
| 58 | +### Key Directories |
| 59 | + |
| 60 | +- **`schema/schemata/`** - YAML schema definitions for each API resource (16 total resources) |
| 61 | + - `common.yml` - Shared field definitions referenced by other schemas |
| 62 | + - Individual resource schemas: `fundraiser.yml`, `donation.yml`, `person.yml`, etc. |
| 63 | +- **`schema/meta.json`** - Schema metadata (API title, URL, description) |
| 64 | +- **`schema/preface.md`** - Content prepended to generated API docs |
| 65 | +- **`source/index.html.md`** - Main landing page (YAML frontmatter + Markdown) |
| 66 | +- **`source/includes/`** - Markdown sections included in final docs |
| 67 | + - `resources.md` - Generated API reference (DO NOT EDIT DIRECTLY) |
| 68 | + - `webhooks.md` - Webhook documentation (manually maintained) |
| 69 | +- **`source/schema.json`** - Compiled schema (generated, DO NOT EDIT) |
| 70 | + |
| 71 | +### Important Build Patterns |
| 72 | + |
| 73 | +1. **Generated Files** - These are auto-generated and should NOT be edited directly: |
| 74 | + - `source/schema.json` (from `rake schema:combine`) |
| 75 | + - `source/includes/resources.md` (from `rake schema:doc`) |
| 76 | + |
| 77 | +2. **To Modify API Documentation**: |
| 78 | + - Edit YAML files in `schema/schemata/` |
| 79 | + - Run `bin/build` to regenerate docs |
| 80 | + - The build process validates schemas automatically |
| 81 | + |
| 82 | +3. **To Modify Landing Page or Static Content**: |
| 83 | + - Edit `source/index.html.md` for main page |
| 84 | + - Edit `source/includes/webhooks.md` for webhook docs |
| 85 | + - Run `middleman build` or full `bin/build` |
| 86 | + |
| 87 | +4. **Schema References**: |
| 88 | + - Common fields defined in `schema/schemata/common.yml` are referenced via `$ref` |
| 89 | + - PRMD automatically resolves these references during `schema:combine` |
| 90 | + |
| 91 | +## Technology Stack |
| 92 | + |
| 93 | +- **Ruby 2.7.6** - Runtime (managed via Docker) |
| 94 | +- **Middleman** - Static site generator |
| 95 | +- **PRMD v0.12.0** - JSON Schema to Markdown converter for API docs |
| 96 | +- **Redcarpet** - Markdown processor with table/code block support |
| 97 | +- **Rouge** - Syntax highlighting (via `middleman-syntax`) |
| 98 | +- **Docker/Docker Compose** - Local development environment |
| 99 | + |
| 100 | +## API Specifications |
| 101 | + |
| 102 | +- **Base URL**: `https://api.betternow.org` |
| 103 | +- **HTTP Header**: `Accept: application/vnd.betternow+json; version=1` |
| 104 | +- **Authentication**: Publishable (read-only) and Secret (write) API keys |
| 105 | + |
| 106 | +## CI/CD |
| 107 | + |
| 108 | +GitHub Actions workflow (`.github/workflows/publish.yml`) automatically: |
| 109 | +1. Builds the site on push to master |
| 110 | +2. Deploys to AWS S3 bucket |
| 111 | +3. Uses AWS OIDC for secure authentication |
0 commit comments