|
1 | | -# CLAUDE.md |
| 1 | +# JS Monorepo |
2 | 2 |
|
3 | | -This file provides guidance to Claude Code when working in the js/ directory. |
| 3 | +TypeScript monorepo for Lightning Network SDKs and internal applications. Yarn workspaces + Turbo. |
4 | 4 |
|
5 | | -## Overview |
| 5 | +## Quick Reference |
6 | 6 |
|
7 | | -JavaScript/TypeScript monorepo for Lightspark's Lightning Network and UMA services. Public SDKs, internal applications, and shared packages using Yarn workspaces + Turbo. |
| 7 | +| Action | Command | |
| 8 | +|--------|---------| |
| 9 | +| Install | `yarn` | |
| 10 | +| Start apps | `yarn start site uma-bridge ops` | |
| 11 | +| Build | `yarn build` | |
| 12 | +| Test | `yarn test` | |
| 13 | +| Lint + format | `yarn lint && yarn format` | |
| 14 | +| Full checks | `yarn checks` | |
| 15 | +| GraphQL regen | `yarn gql-codegen` | |
| 16 | +| Clean all | `yarn clean-all` | |
8 | 17 |
|
9 | 18 | ## Structure |
10 | 19 |
|
11 | | -- **packages/** - Shared libraries |
12 | | - - **core/** - Auth, utilities |
13 | | - - **lightspark-sdk/** - Public Lightning SDK |
14 | | - - **ui/** - React components, design system |
15 | | - - **private/** - Internal utilities, GraphQL clients |
16 | | -- **apps/examples/** - Public examples and CLI tools |
17 | | -- **apps/private/** - Internal apps (site, ops, uma-bridge) |
18 | | - |
19 | | -## Essential Commands |
20 | | - |
21 | | -### Setup |
22 | | -```bash |
23 | | -nvm use || nvm install # Match Node version |
24 | | -corepack enable && corepack prepare --activate # Enable Yarn |
25 | | -yarn # Install all workspace dependencies |
26 | 20 | ``` |
27 | | - |
28 | | -### Development Workflow |
29 | | -```bash |
30 | | -# Start applications |
31 | | -yarn start site uma-bridge ops # Specific apps (@lightsparkdev/ prefix implied) |
32 | | -yarn start private # All private apps |
33 | | -yarn start examples # All examples |
34 | | - |
35 | | -# Code quality |
36 | | -yarn lint && yarn format # Lint + Prettier |
37 | | -yarn checks # Full validation: deps, lint, format, test, circular-deps |
38 | | - |
39 | | -# Building |
40 | | -yarn build # Build all workspaces with Turbo caching |
41 | | -yarn build --force # Rebuild without cache |
42 | | - |
43 | | -# Testing |
44 | | -yarn test # Run all tests |
45 | | -yarn workspace @lightsparkdev/ui test # Test specific workspace |
46 | | - |
47 | | -# GraphQL codegen |
48 | | -yarn gql-codegen # Regenerate TypeScript types from schemas |
| 21 | +packages/ |
| 22 | + core/ # Auth, utilities |
| 23 | + lightspark-sdk/ # Public Lightning SDK |
| 24 | + ui/ # React components |
| 25 | + private/ # Internal utilities |
| 26 | +apps/ |
| 27 | + examples/ # Public examples |
| 28 | + private/ # Internal apps (site, ops, uma-bridge) |
49 | 29 | ``` |
50 | 30 |
|
51 | | -### Workspace Targeting |
| 31 | +## Workspace Commands |
| 32 | + |
52 | 33 | ```bash |
53 | | -# From repo root |
| 34 | +# Target specific workspace |
54 | 35 | yarn workspace @lightsparkdev/<name> <command> |
55 | 36 |
|
56 | | -# From workspace directory |
57 | | -cd apps/private/uma-bridge && yarn start |
| 37 | +# Examples |
| 38 | +yarn workspace @lightsparkdev/uma-bridge start |
| 39 | +yarn workspace @lightsparkdev/ui test |
58 | 40 | ``` |
59 | 41 |
|
60 | | -## Architecture & Patterns |
| 42 | +## Code Patterns |
61 | 43 |
|
62 | | -### Monorepo Management |
63 | | -- **Yarn workspaces** with workspace protocol (`"@lightsparkdev/ui": "*"`) |
64 | | -- **Turbo** orchestrates builds with caching and parallelization |
| 44 | +### Dependencies |
| 45 | +- Use workspace protocol for internal deps: `"@lightsparkdev/ui": "*"` |
65 | 46 | - Shared configs: `@lightsparkdev/{tsconfig,eslint-config}` |
66 | | -- Build artifacts in `dist/`, ignored by git |
67 | 47 |
|
68 | 48 | ### GraphQL |
69 | | -- TypeScript types auto-generated via GraphQL Code Generator |
70 | | -- Schema variants per API surface (internal, third-party) |
71 | | -- Fragments/operations defined per app |
72 | | -- Real-time subscriptions for transaction updates |
73 | | -- **After Python schema changes**: run `yarn gql-codegen` from root |
74 | | - |
75 | | -### React Stack |
76 | | -- **Vite** - Dev server and bundler |
77 | | -- **Emotion** - CSS-in-JS styling |
78 | | -- **React Router** - Navigation |
79 | | -- **React Query** - Server state |
80 | | -- **Zustand** - Client state |
81 | | - |
82 | | -### Testing |
83 | | -- **Jest** - Unit/integration tests |
84 | | -- **React Testing Library** - Component tests |
85 | | -- **Cypress** - E2E tests |
86 | | -- Tests colocated with source (`.test.ts`, `.spec.ts`) |
87 | | - |
88 | | -## Configuration Files |
89 | | - |
90 | | -- **turbo.json** - Build pipeline, task dependencies, caching |
91 | | -- **package.json** (root) - Workspace definitions, scripts |
92 | | -- **packages/eslint-config/** - Shared linting rules |
93 | | -- **packages/tsconfig/** - TypeScript presets |
94 | | - |
95 | | -## Code Standards |
96 | | - |
97 | | -- **TypeScript strict mode** enabled |
98 | | -- **ESLint** extends shared configs |
99 | | -- **Prettier** with import organization |
100 | | -- **Circular dependency detection** via madge |
101 | | -- **Prefer Edit tool** over inline rewrites for existing code |
102 | | - |
103 | | -## Common Task Workflows |
104 | | - |
105 | | -### Adding New Package |
106 | | -1. Create directory in `packages/` or `apps/` |
107 | | -2. Add workspace reference in root `package.json` |
108 | | -3. Create `package.json` with dependencies (use workspace protocol for internal deps) |
109 | | -4. Add build config to `turbo.json` if needed |
110 | | -5. Run `yarn` to link workspace |
111 | | - |
112 | | -### GraphQL Type Updates |
113 | | -After Python backend schema changes: |
114 | | -```bash |
115 | | -yarn gql-codegen # All workspaces |
116 | | -yarn workspace @lightsparkdev/uma-bridge gql-codegen # Specific app |
117 | | -``` |
118 | | - |
119 | | -### Debugging Build Issues |
120 | | -```bash |
121 | | -yarn clean-all # Remove dist/ and caches |
122 | | -yarn build --force # Bypass Turbo cache |
123 | | -yarn clean-resolve # Nuclear option: reset lockfile |
124 | | -``` |
125 | | - |
126 | | -### UMA Bridge Development |
| 49 | +After Python schema changes: |
127 | 50 | ```bash |
128 | | -# Lint bridge + UI package |
129 | | -yarn run lint --filter=@lightsparkdev/ui --filter=@lightsparkdev/uma-bridge |
130 | | - |
131 | | -# Start with Vite dev server (proxy configured for backend) |
132 | | -yarn workspace @lightsparkdev/uma-bridge start |
| 51 | +yarn gql-codegen # All workspaces |
| 52 | +yarn workspace @lightsparkdev/uma-bridge gql-codegen # Specific |
133 | 53 | ``` |
134 | 54 |
|
135 | | -Integrates with: Plaid, Tazapay, Striga, other payment providers |
136 | | - |
137 | 55 | ### Adding Dependencies |
138 | 56 | ```bash |
139 | | -# Workspace-specific |
140 | | -yarn workspace @lightsparkdev/<name> add <package> |
141 | | - |
142 | | -# Root-level (affects all workspaces) |
143 | | -yarn add -W <package> |
| 57 | +yarn workspace @lightsparkdev/<name> add <package> # To workspace |
| 58 | +yarn add -W <package> # Root level |
144 | 59 | ``` |
145 | 60 |
|
146 | | -## Release Process |
147 | | - |
148 | | -**Public packages** (SDK, core utilities): |
149 | | -- Changesets for version management |
150 | | -- Copybara syncs to public repo on main merge |
151 | | -- Release PR auto-created |
152 | | -- Merge Release PR → npm publish |
153 | | - |
154 | | -**Private packages** (`packages/private/`, `apps/private/`): |
155 | | -- Not published to npm |
156 | | -- Versioned internally only |
157 | | - |
158 | 61 | ## Troubleshooting |
159 | 62 |
|
160 | | -**Import errors**: Check workspace dependencies use `"*"` not version numbers |
161 | | -**Type errors after GraphQL changes**: Run `yarn gql-codegen` |
162 | | -**Stale build artifacts**: `yarn clean-all && yarn build` |
163 | | -**Turbo cache issues**: Add `--force` flag to bypass cache |
| 63 | +| Issue | Fix | |
| 64 | +|-------|-----| |
| 65 | +| Import errors | Check deps use `"*"` not versions | |
| 66 | +| Type errors after GraphQL | `yarn gql-codegen` | |
| 67 | +| Stale builds | `yarn clean-all && yarn build` | |
| 68 | +| Cache issues | `yarn build --force` | |
0 commit comments