This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Development (from repo root)
yarn dev # Start Next.js dev server (apps/web)
yarn build # Production build
yarn test # Run Jest in watch mode
yarn test:ci # Run Jest once (CI mode)
# Run commands directly in the web workspace
yarn workspace @oss-compass/web dev
yarn workspace @oss-compass/web build
yarn workspace @oss-compass/web lint
yarn workspace @oss-compass/web ts-lint # TypeScript type checking (watch)Node >= 16 required. Uses Yarn workspaces.
Monorepo: apps/web (Next.js 15, Pages Router) + shared packages (packages/*).
Pages (src/pages/) are thin shells that delegate to modules (src/modules/). A page typically imports and renders a single module component. Modules contain their own components, hooks, stores, types, and constants. When adding a feature, create a module under src/modules/<feature>/ and a corresponding page under src/pages/<feature>/.
components/— Reusable UI components (Layout, Header, Footer, Form primitives, ECharts wrappers, etc.)utils/— Pure utility functions (format, time, url, number, i18n helpers, etc.)hooks/— Shared React hooks (useBreakpoint, useImagePreview, etc.)lib/— Cross-cutting libs like Google Analytics (ga.tsx)monumentedStation/— Custom event tracking/monitoring systemtransform/— Data transformation utilities
Backend communication via graphql-request. The client is configured at src/common/gqlClient.ts and points to /api/graphql. Generated types live in packages/graphql/src/generated.ts. Use the @oss-compass/graphql package alias to import.
src/middleware.ts proxies /api/*, /services/*, /badge/*, /files/*, /users/* to the backend. In dev mode, hits a local dev proxy at /api/development/proxy. In production, uses API_URL env var. Nginx handles proxying in real production; the Next.js middleware handles Vercel preview environments.
Uses next-i18next v15 with en (default) and zh locales. Translation JSON files in apps/web/i18n/. Namespaces: common, plus module-specific ones like os-situation. Use useTranslation('<namespace>') in components.
- Tailwind CSS + daisyUI as primary styling (dark mode via
classstrategy) - Ant Design 5 (
antd) for complex widgets - MUI 5 (
@mui/material) for some components - ECharts (via
EChartXwrapper in common) and Highcharts for charting
- React Query (
@tanstack/react-query) for server state — configured in_app.tsxwithrefetchOnWindowFocus: false,retry: false - valtio for client-side global state (e.g., user info store)
Login via OAuth providers (GitHub, Gitee, AtomGit). Auth state flows through UserInfoFetcher → UserInfoStore (valtio). AuthRequire component guards pages that need authentication.
| Alias | Path |
|---|---|
@oss-compass/graphql |
packages/graphql/src |
@oss-compass/ui |
packages/ui/src |
@common/* |
src/common/* |
@modules/* |
src/modules/* |
@graphql/* |
src/graphql/* |
@public/* |
public/* |
@styles/* |
src/styles/* |
Jest has matching moduleNameMapper entries in jest.config.js.
Husky + lint-staged run Prettier and ESLint on staged files. Configuration in .lintstagedrc.js.