|
1 | 1 | # CLAUDE.md |
2 | 2 |
|
3 | | -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 3 | +Documentation-only repo (no application code): OpenAPI spec (YAML) + Mintlify docs (MDX). |
| 4 | +Grid is an API for global payments across fiat, stablecoins, and Bitcoin. |
4 | 5 |
|
5 | | -## Project Overview |
| 6 | +## Critical Rules |
6 | 7 |
|
7 | | -This is the **Grid API** documentation repository. Grid is an API that enables modern financial institutions to send and receive global payments across fiat, stablecoins, and Bitcoin. The repository contains: |
| 8 | +- **Edit OpenAPI in `openapi/`** — never edit the root `openapi.yaml` directly (it's generated by bundling) |
| 9 | +- Run `make build` after any OpenAPI changes to rebundle |
| 10 | +- Run `make lint` before committing |
| 11 | +- **Mintlify CLI must be version 4.2.284** — newer versions (e.g., 4.2.312) have a bug where API reference pages render blank. Install with `npm install -g mintlify@4.2.284 --force` |
| 12 | +- **Requires Node.js v20 or v22** — Mintlify does not support Node 25+. If needed: `export PATH="/opt/homebrew/opt/node@22/bin:$PATH"` |
| 13 | +- Use snippets from `mintlify/snippets/` instead of duplicating content across use cases |
| 14 | +- Follow writing standards in `mintlify/CLAUDE.md` for all documentation content |
| 15 | +- MDX files require frontmatter with `title` and `description` |
| 16 | +- Do not use `React.useEffect` in MDX — it breaks Mintlify's acorn parser. `React.useState` is fine. |
8 | 17 |
|
9 | | -1. **OpenAPI specification** (split into modular YAML files) |
10 | | -2. **Mintlify documentation** (MDX files with guides, tutorials, and API reference) |
11 | | - |
12 | | -This is a documentation-only repository - there is no application code. |
13 | | - |
14 | | -## Common Commands |
15 | | - |
16 | | -### Building and Linting |
17 | | - |
18 | | -```bash |
19 | | -# Install dependencies |
20 | | -npm install |
21 | | -# or |
22 | | -make install |
23 | | - |
24 | | -# Build OpenAPI schema (bundles split files into single openapi.yaml) |
25 | | -npm run build:openapi |
26 | | -# or |
27 | | -make build |
28 | | - |
29 | | -# Lint OpenAPI schema and markdown files |
30 | | -npm run lint |
31 | | -# or |
32 | | -make lint |
33 | | - |
34 | | -# Lint only OpenAPI |
35 | | -npm run lint:openapi |
36 | | -# or |
37 | | -make lint-openapi |
38 | | - |
39 | | -# Lint only markdown |
40 | | -npm run lint:markdown |
41 | | -# or |
42 | | -make lint-markdown |
43 | | -``` |
44 | | - |
45 | | -### Documentation Development |
| 18 | +## Commands |
46 | 19 |
|
47 | 20 | ```bash |
48 | | -# Serve Mintlify documentation locally (requires mint CLI installed globally) |
49 | | -cd mintlify && mint dev |
50 | | -# or |
51 | | -make mint |
| 21 | +make install # Install dependencies |
| 22 | +make build # Bundle OpenAPI spec (openapi/ → openapi.yaml + mintlify/openapi.yaml) |
| 23 | +make lint # Lint OpenAPI + markdown + run mint openapi-check |
| 24 | +make lint-openapi # Lint OpenAPI only |
| 25 | +make lint-markdown # Lint markdown only |
| 26 | +make mint # Serve docs locally (cd mintlify && mint dev) |
52 | 27 | ``` |
53 | 28 |
|
54 | | -## Architecture |
55 | | - |
56 | | -### OpenAPI Schema Structure |
57 | | - |
58 | | -The OpenAPI specification uses a **split-file architecture** managed by Redocly: |
59 | | - |
60 | | -- **Source files**: `openapi/` directory contains modular YAML files |
61 | | - - `openapi/openapi.yaml` - Root specification with references |
62 | | - - `openapi/paths/` - Endpoint definitions organized by domain |
63 | | - - `openapi/components/schemas/` - Reusable schema definitions |
64 | | - - `openapi/webhooks/` - Webhook event definitions |
65 | | - |
66 | | -- **Built file**: `openapi.yaml` - Bundled specification at repository root (also copied to `mintlify/openapi.yaml`) |
67 | | - |
68 | | -**Important**: When editing OpenAPI specs, edit files in `openapi/` directory, then run `npm run build:openapi` to bundle. The root `openapi.yaml` is generated and should not be edited directly. |
69 | | - |
70 | | -### Domain Organization |
71 | | - |
72 | | -The API is organized into four main use cases, reflected in both the OpenAPI paths and Mintlify docs: |
73 | | - |
74 | | -1. **Payouts** - Send value instantly across currencies and borders |
75 | | - - Customer management (`/customers`) |
76 | | - - Internal accounts (`/customers/internal-accounts`, `/platform/internal-accounts`) |
77 | | - - External accounts (`/customers/external-accounts`, `/platform/external-accounts`) |
78 | | - - Quotes and transactions |
79 | | - |
80 | | -2. **Ramps** - Convert between crypto and fiat |
81 | | - - Customer onboarding with KYC |
82 | | - - Plaid integration for bank account linking |
83 | | - - Fiat-to-crypto and crypto-to-fiat conversion flows |
84 | | - - Self-custody wallet support |
85 | | - |
86 | | -3. **Rewards & Cashback** - Deliver micro-payouts at scale |
87 | | - - Similar structure to Payouts |
88 | | - - Optimized for high-volume, low-value transactions |
89 | | - |
90 | | -4. **Global P2P (Remittances)** - Accept funds via bank transfers, wallets, or UMAs |
91 | | - - User management with UMA addresses (`/users` endpoints in actual API) |
92 | | - - UMA address resolution (`/receiver/uma/{receiverUmaAddress}`) |
93 | | - - Payment approval/rejection flows |
94 | | - - Invitations system (`/invitations`) |
95 | | - |
96 | | -### Key Concepts |
97 | | - |
98 | | -- **Customers**: End users of the platform (used in Payouts, Ramps, Rewards) |
99 | | -- **Users**: Distinction unclear from docs, but appears related to UMA-based flows |
100 | | -- **Internal Accounts**: Platform-managed accounts for holding funds |
101 | | -- **External Accounts**: Bank accounts connected for deposits/withdrawals |
102 | | -- **Quotes**: Time-limited exchange rate locks for cross-currency transactions |
103 | | -- **Transactions**: Payment records (incoming/outgoing) |
104 | | -- **UMA Addresses**: Universal Money Addresses (e.g., `$alice@example.com`) for P2P payments |
105 | | - |
106 | | -### Mintlify Documentation Structure |
107 | | - |
108 | | -- `mintlify/docs.json` - Navigation configuration with tabs for each use case |
109 | | -- `mintlify/index.mdx` - Landing page |
110 | | -- `mintlify/{use-case}/` - Use case-specific documentation |
111 | | - - `index.mdx` - Use case overview |
112 | | - - `quickstart.mdx` - Quick start guide |
113 | | - - `onboarding/` or `developer-guides/` - Implementation guides |
114 | | - - `accounts/`, `payment-flow/`, etc. - Topic-specific guides |
115 | | -- `mintlify/snippets/` - Reusable MDX snippets (imported into multiple docs) |
116 | | -- `mintlify/api-reference/` - API authentication and environment docs |
117 | | -- `mintlify/developer-resources/` - SDKs, tools, Postman collections |
118 | | -- `mintlify/changelog.mdx` - API changelog |
119 | | - |
120 | | -### Shared Documentation Patterns |
121 | | - |
122 | | -The repository uses **MDX snippets** to avoid duplication across use cases. Common snippets in `mintlify/snippets/`: |
123 | | - |
124 | | -- `platform-config-currency-api-webhooks.mdx` - Platform configuration |
125 | | -- `internal-accounts.mdx` - Internal account management |
126 | | -- `external-accounts.mdx` - External account management |
127 | | -- `webhooks.mdx` - Webhook setup and verification |
128 | | -- `kyc-onboarding.mdx` - KYC onboarding process |
129 | | -- `plaid-integration.mdx` - Plaid integration |
130 | | -- `terminology.mdx` - Terminology definitions |
131 | | - |
132 | | -Import these snippets rather than duplicating content. |
133 | | - |
134 | | -## Authentication |
135 | | - |
136 | | -The API uses HTTP Basic Authentication with format `<api token id>:<api client secret>` (Base64 encoded). All endpoints require authentication except the webhook endpoints (which use signature verification instead). |
| 29 | +## File Structure |
137 | 30 |
|
138 | | -Webhooks use **P-256 ECDSA signatures** in the `X-Grid-Signature` header for verification. |
139 | | - |
140 | | -## Important Notes |
141 | | - |
142 | | -### OpenAPI Development |
143 | | - |
144 | | -- Use Redocly for bundling and linting: `@redocly/cli` |
145 | | -- Configuration in `.redocly.yaml` |
146 | | -- Lint rules include operation descriptions, operation IDs, security definitions |
147 | | -- Always run `npm run lint:openapi` before committing OpenAPI changes |
148 | | - |
149 | | -### Mintlify Development |
150 | | - |
151 | | -- MDX files must include frontmatter with `title` and `description` |
152 | | -- Follow the writing standards in `mintlify/CLAUDE.md` |
153 | | -- Use second-person voice ("you") |
154 | | -- Test all code examples |
155 | | -- Use relative paths for internal links |
156 | | -- The mintlify subdirectory has its own CLAUDE.md with additional guidance |
157 | | - |
158 | | -### Mintlify CLI Version (Important) |
159 | | - |
160 | | -**Use Mintlify CLI version 4.2.284** for local development. Newer versions (e.g., 4.2.312) have a bug where the API reference pages render blank when using the palm theme with OpenAPI auto-generation. |
161 | | - |
162 | | -**Requires Node.js LTS (v20 or v22)** - Mintlify does not support Node 25+. If you have a newer Node version installed, use Node 22 LTS: |
163 | | - |
164 | | -```bash |
165 | | -# Install Node 22 via Homebrew (if needed) |
166 | | -brew install node@22 |
167 | | - |
168 | | -# Run mint dev with Node 22 |
169 | | -export PATH="/opt/homebrew/opt/node@22/bin:$PATH" |
170 | | -cd mintlify && mint dev |
171 | | - |
172 | | -# Or add to ~/.zshrc to make permanent: |
173 | | -# export PATH="/opt/homebrew/opt/node@22/bin:$PATH" |
174 | 31 | ``` |
175 | | - |
176 | | -```bash |
177 | | -# Check current version |
178 | | -mintlify --version |
179 | | - |
180 | | -# If needed, install the working version |
181 | | -npm install -g mintlify@4.2.284 --force |
| 32 | +openapi/ # Source OpenAPI YAML (edit here) |
| 33 | + openapi.yaml # Root spec with $ref references |
| 34 | + paths/ # Endpoint definitions by domain |
| 35 | + components/schemas/ # Reusable schema definitions |
| 36 | + webhooks/ # Webhook event definitions |
| 37 | +openapi.yaml # Generated bundle (don't edit) |
| 38 | +mintlify/ # Mintlify documentation (MDX) |
| 39 | + docs.json # Navigation and theme config |
| 40 | + snippets/ # Shared MDX snippets (use these to avoid duplication) |
| 41 | + styles/base.css # CSS overrides |
| 42 | +.redocly.yaml # Redocly bundler/linter config |
182 | 43 | ``` |
183 | 44 |
|
184 | | -### Troubleshooting: API Reference Not Showing |
185 | | - |
186 | | -If the API reference pages appear blank (only showing title and navigation, no endpoint details): |
187 | | - |
188 | | -1. **Restart the dev server** - hot reload sometimes fails: |
189 | | - ```bash |
190 | | - pkill -f "mint.*dev" |
191 | | - cd mintlify && mint dev |
192 | | - ``` |
193 | | - |
194 | | -2. **Check CLI version** - ensure you're on 4.2.284 (see above) |
195 | | - |
196 | | -3. **Verify OpenAPI spec** - run `mint openapi-check openapi.yaml` in the mintlify folder |
197 | | - |
198 | | -### Documentation Philosophy |
199 | | - |
200 | | -- **Document just enough** for user success - balance between too much and too little |
201 | | -- **Avoid duplication** - use snippets for shared content across use cases |
202 | | -- **Make content evergreen** when possible |
203 | | -- **Check existing patterns** for consistency before making changes |
204 | | -- **Search before adding** - look for existing information before creating new content |
205 | | - |
206 | | -### CSS Styling Tips (Mintlify Overrides) |
207 | | - |
208 | | -When overriding Mintlify's default styles in `mintlify/styles/base.css`: |
209 | | - |
210 | | -- **Tailwind utility classes are hard to override directly** - Classes like `mb-3.5` have high specificity. Even with `!important` and complex selectors, they often won't budge. |
211 | | - |
212 | | -- **Workaround: Use negative margins on sibling elements** - Instead of reducing `margin-bottom` on an element, add negative `margin-top` to the following sibling. This achieves the same visual effect. |
213 | | - |
214 | | -- **Test selectors with visible properties first** - If a style isn't applying, add `border: 2px solid red !important;` to confirm the selector is matching. If the border shows, the selector works but something else is overriding your property. |
215 | | - |
216 | | -- **HeadlessUI portal elements** - Mobile nav and modals render inside `#headlessui-portal-root`. Use this in selectors for higher specificity: `#headlessui-portal-root #mobile-nav ...` |
217 | | - |
218 | | -- **Mobile nav lives in `#mobile-nav`** - Target mobile-specific styles with `#mobile-nav` or `div#mobile-nav` selectors to avoid affecting desktop sidebar. |
219 | | - |
220 | | -- **Negative margins for edge-to-edge layouts** - To break out of parent padding (e.g., make nav items edge-to-edge), use negative margins equal to the parent's padding, then add your own padding inside. |
221 | | - |
222 | | -### MDX Component Limitations |
223 | | - |
224 | | -- **`React.useEffect` breaks the MDX parser** - Mintlify uses acorn to parse MDX, and it chokes on `useEffect`. Avoid using hooks that require cleanup or side effects. |
225 | | - |
226 | | -- **`React.useState` works fine** - Simple state management is supported. |
| 45 | +## OpenAPI |
227 | 46 |
|
228 | | -- **Keep components simple** - If you need complex interactivity, consider using CSS-only solutions or restructuring to avoid problematic hooks. |
| 47 | +Bundled and linted with Redocly (`@redocly/cli`), configured in `.redocly.yaml`. Lint rules enforce operation descriptions, operation IDs, and security definitions. |
229 | 48 |
|
230 | | -## Environments |
| 49 | +## CSS Overrides (mintlify/styles/base.css) |
231 | 50 |
|
232 | | -- **Production**: `https://api.lightspark.com/grid/2025-10-13` |
233 | | -- **Sandbox**: Available for testing (see sandbox endpoints `/sandbox/send`, `/sandbox/receive`) |
| 51 | +- Tailwind utility classes (e.g., `mb-3.5`) are hard to override even with `!important` — use negative margins on sibling elements as a workaround |
| 52 | +- Test selectors with `border: 2px solid red !important` to confirm they match before debugging property conflicts |
| 53 | +- Mobile nav is in `#mobile-nav`; modals/portals are in `#headlessui-portal-root` |
234 | 54 |
|
235 | | -## Support |
| 55 | +## Troubleshooting: Blank API Reference Pages |
236 | 56 |
|
237 | | -For questions or issues: support@lightspark.com |
| 57 | +1. Restart dev server: `pkill -f "mint.*dev" && cd mintlify && mint dev` |
| 58 | +2. Verify CLI version is 4.2.284 |
| 59 | +3. Run `cd mintlify && mint openapi-check openapi.yaml` |
0 commit comments