How mandrillxx/cursor-ninja works
Project Type and Purpose
• This is a full‑stack, single‑page web application built with Next.js (App Router) and React + TypeScript.
• Purpose: Provide a visual, node‑based editor for creating, managing, and sharing coding‑standards rules.
File Structure
• Top‑level config files: package.json, pnpm‑lock.yaml, tsconfig.json, eslint.config.mjs, next.config.ts, postcss.config.mjs
• “src/app”: Next.js App Router directories (server components, layout, global CSS)
• “src/components”: UI building blocks (buttons, dialogs, node renderers, selectors)
• “src/actions”: server‑side or API actions (rule generation, AI integration)
• “src/hooks”: custom React hooks (use‑mobile)
• “src/lib”: shared utilities and state management (Zustand store, type definitions, safe action wrappers)
Key Insights from README
• Core features: visual graph editor, multiple rule node types, import/export (JSON, natural‑language).
• Uses AI to convert text into graph nodes.
• Next.js handles both server and client logic; React Query is mentioned in example but not directly visible—likely a placeholder.
Main System Components
a. Client (Browser)
• React UI (pages in src/app, components in src/components)
• State Management (Zustand store in src/lib/store.ts)
• Routing and Layout (Next.js App Router)
• Custom Hooks (e.g., use‑mobile)
b. Server (Next.js)
• Server Components & API Routes (src/actions/generate-rules.ts)
• File import/export endpoints (JSON, .cursorrule)
• AI Integration (calls to external AI service for NL→graph conversion)
c. Data Storage & Management
• In‑memory or client‑side store for active editing
• Export to JSON files / download
• Optionally persist to remote storage (not in code, but could be an extension)
d. External Services
• AI/LLM endpoint (e.g., OpenAI)
• Potential static hosting/CDN for public assets
Relationships and Interactions
• User interacts with React UI → triggers state changes in the store.
• UI dispatches server actions (via server components or API routes) to:
• Generate rules from NL text
• Import/export JSON
• Server action calls out to the AI service → returns structured rule data.
• Server returns data to client → client updates graph and renders nodes.
• User can download/export a .json file.
Architectural Patterns & Design Principles
• Component‑based UI architecture (atomic UI primitives + composed dialogs + node renderers)
• Unidirectional data flow: UI → store → server actions → store → UI
• Next.js App Router pattern: separation between server and client components
• Modular code organization: “actions” for side‑effects, “lib” for shared logic, “components” for pure UI.
Essential Elements
• Client layer: React pages, components tree, store
• Server layer: generate-rules action, import/export routes
• Data stores: in‑memory store, file system export
• External: AI/LLM service
Detail
• Don’t stop at “frontend” and “backend” only—identify sub‑systems (graph engine, dialog management, project management).