Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ lerna-debug.log*
node_modules
dist
dist-ssr
.next
*.tsbuildinfo
*.local

# Editor directories and files
Expand All @@ -28,4 +30,4 @@ dist-ssr


# AI
.codex
.codex
43 changes: 25 additions & 18 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
## Project Overview

This is ycms (Yearn CMS), a content management system built as a monorepo with two main packages:
- `packages/app` - React-based frontend with Bun API backend
- `packages/app` - Next.js application with App Router pages and API route handlers
- `packages/cdn` - Static JSON data files for vaults and strategies across multiple blockchain networks

## Development Commands
Expand All @@ -16,29 +16,29 @@ This is ycms (Yearn CMS), a content management system built as a monorepo with t
- `bun clean --lockfiles` - Also remove bun.lock files

### App Package (`packages/app`)
- `bun dev` - Start all services (API server, Vite dev server)
- `bun dev:client` - Start only Vite frontend dev server
- `bun dev:server` - Start only Bun API server (port 3001)
- `bun build` - Build for production (TypeScript compilation + Vite build)
- `bun dev` - Start the Next.js development server on port 3000
- `bun dev:client` - Alias for the Next.js development server
- `bun build` - Create a production Next.js build
- `bun lint` - Run Biome linter
- `bun lint:fix` - Run Biome linter with auto-fix
- `bun preview` - Preview production build
- `bun tslint` - Run TypeScript without emitting files
- `bun preview` - Start the production build with `next start`

## Architecture

### Frontend (React + Vite)
### Frontend (Next.js App Router)
- React 19 with TypeScript
- Router: React Router DOM v7 with nested routes
- Native App Router pages under `packages/app/app`
- State: Zustand for client state, TanStack Query for server state
- Styling: Tailwind CSS v4
- UI Components: Custom components with Radix UI primitives
- Build: Vite with React plugin
- Build: Next.js with the Tailwind PostCSS adapter

### Backend (Bun Server)
- Simple HTTP server using Bun's native `serve()` API (port 3001)
### Backend (Next.js Route Handlers)
- API handlers run on the same port as the frontend under `packages/app/app/api`
- Routes: `/api/ping`, `/api/auth/github/callback`, `/api/pr`, `/api/cdn/*`
- GitHub OAuth integration for authentication
- CDN proxy endpoints for accessing vault/strategy metadata
- Local development reads metadata from `packages/cdn`; production proxies commit-pinned files through jsDelivr

### Data Management
- **Schemas**: Zod schemas for VaultMetadata and StrategyMetadata validation
Expand Down Expand Up @@ -75,19 +75,26 @@ GitHub OAuth is required for write operations (creating PRs, editing metadata).
3. Copy the client ID and secret into your `.env`

Then configure your `.env`:
- `VITE_GITHUB_CLIENT_ID` — your OAuth app's client ID
- `NEXT_PUBLIC_CDN_URL` — optional public CMS data URL; leave empty to use the same-origin `/cdn` route
- `NEXT_PUBLIC_ASSETS_CDN_URL` — public token and chain asset CDN URL
- `NEXT_PUBLIC_GITHUB_CLIENT_ID` — your OAuth app's client ID
- `GITHUB_CLIENT_SECRET` — your OAuth app's client secret
- `VITE_GITHUB_REDIRECT_URI` — set to `http://127.0.0.1:3001/api/auth/github/callback` for local dev
- `NEXT_PUBLIC_GITHUB_REDIRECT_URI` — set to `http://127.0.0.1:3000/api/auth/github/callback` for local dev
- `URL` — set to `http://127.0.0.1:3000` for local dev

The `VITE_GITHUB_REDIRECT_URI` tells GitHub to redirect to your local API server port. GitHub allows any port on loopback addresses (`127.0.0.1`) as long as the registered callback URL uses the same host. Leave `VITE_GITHUB_REDIRECT_URI` unset in production to use the registered callback URL directly.
The public GitHub redirect setting tells GitHub to return to the callback route on the same Next.js server. GitHub
allows any port on loopback addresses (`127.0.0.1`) as long as the registered callback URL uses the same host.
Leave it unset in production to use the OAuth application's registered callback URL directly.

### CDN Access
- Public CDN: `https://cdn.jsdelivr.net/gh/yearn/cms@main/packages/cdn`
- Local development proxies through `/api/cdn/*` endpoints
- Local development serves `packages/cdn` through `/api/cdn/*`
- Production proxies `/cdn/*` through the Node.js route handler to a commit-pinned jsDelivr URL

## Key Files
- `packages/app/api/server.ts` - Main API server setup
- `packages/app/app/layout.tsx` - Root layout and application providers
- `packages/app/app/[collection]/page.tsx` - Collection route entry point
- `packages/app/app/api/pr/route.ts` - Pull request API route
- `packages/app/app/api/cdn/[...path]/route.ts` - CDN proxy API route
- `packages/app/schemas/*` - Zod validation schemas
- `packages/app/src/main.tsx` - React app entry point and routing
- `packages/cdn/{vaults,strategies}/*.json` - Blockchain metadata by chain ID
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ bun dev

Open `http://127.0.0.1:3000` in your browser (use `127.0.0.1`, not `localhost` — required for GitHub OAuth).

To run on a custom port: `PORT=4000 bun dev`. The API server runs on PORT+1 automatically. Update `VITE_GITHUB_REDIRECT_URI` and `URL` in your `.env` to match.
To run on a custom port: `PORT=4000 bun dev`. Next.js serves the UI and API routes on the same port. Update
`NEXT_PUBLIC_GITHUB_REDIRECT_URI` and `URL` in your `.env` to match.

## GitHub OAuth Setup

Expand All @@ -34,13 +35,14 @@ Sign-in is required to edit metadata and create PRs. To set up OAuth for local d

Configure `packages/app/.env`:
```
VITE_GITHUB_CLIENT_ID = <your client id>
NEXT_PUBLIC_GITHUB_CLIENT_ID = <your client id>
GITHUB_CLIENT_SECRET = <your client secret>
VITE_GITHUB_REDIRECT_URI = http://127.0.0.1:3000/api/auth/github/callback
NEXT_PUBLIC_GITHUB_REDIRECT_URI = http://127.0.0.1:3000/api/auth/github/callback
URL = http://127.0.0.1:3000
```

`VITE_GITHUB_REDIRECT_URI` tells GitHub to redirect to your local dev server port. GitHub allows any port on `127.0.0.1` as long as the registered callback URL uses the same host. Leave it unset in production.
`NEXT_PUBLIC_GITHUB_REDIRECT_URI` tells GitHub to redirect to your local dev server port. GitHub allows any port
on `127.0.0.1` as long as the registered callback URL uses the same host. Leave it unset in production.

#### Manual vault and strategy sync
```bash
Expand All @@ -67,6 +69,9 @@ git push

### cdn url

During `bun dev`, same-origin `/cdn/*` requests read directly from `packages/cdn`, so local metadata edits are
available without publishing them. Production requests use the API proxy and a commit-pinned jsDelivr URL.

```url

https://cdn.jsdelivr.net/gh/yearn/cms@main/packages/cdn
Expand Down
22 changes: 19 additions & 3 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.3/schema.json",
"$schema": "https://biomejs.dev/schemas/2.4.16/schema.json",
"linter": {
"enabled": true,
"rules": {
Expand Down Expand Up @@ -40,15 +40,31 @@
"indentWidth": 2,
"lineWidth": 120
},
"overrides": [
{
"includes": [
"packages/app/src/components/eg/HoverCard/index.tsx",
"packages/app/src/components/eg/HoverSelect/index.tsx"
],
"linter": {
"rules": {
"a11y": {
"useSemanticElements": "off"
}
}
}
}
],
"files": {
"ignoreUnknown": true,
"includes": [
"**/*.{js,jsx,ts,tsx}"
"**/*.{js,jsx,ts,tsx}",
"!**/next-env.d.ts"
]
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
}
}
Loading