From 9d474405c3a4f042897494a778bdc0ec1f9f618e Mon Sep 17 00:00:00 2001 From: Abhishek Chatterjee Date: Sat, 21 Nov 2026 14:54:57 +0530 Subject: [PATCH 01/20] chore(platform): #227: add platform AGENTS.md and codebase rules --- AGENTS.md | 2 +- rocket/platform/AGENTS.md | 111 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 7e44b158..7fd9149c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -17,7 +17,7 @@ Commands can be run from the repository root via `./dev.sh` (which delegates to | `./dev.sh db` | Start redis and db Docker containers | | `./dev.sh csserve` | Serve coverage report via HTTP | -Run `./dev.sh check` after every change before committing. +Commits automatically run pre-commit hooks, so there is no need to manually run tests or `./dev.sh check` before committing. ## Testing diff --git a/rocket/platform/AGENTS.md b/rocket/platform/AGENTS.md index af3b7c84..eb54afd4 100644 --- a/rocket/platform/AGENTS.md +++ b/rocket/platform/AGENTS.md @@ -1,3 +1,7 @@ +# AGENTS.md — Rocket Platform + +Next.js frontend application for the Rocket platform (App Router, React 19, TypeScript, Tailwind CSS, Better Auth, Drizzle ORM). + ## This is NOT the Next.js you know @@ -7,3 +11,110 @@ This version has breaking changes — APIs, conventions, and file structure may This block is written and re-added by `next dev` — verify at `node_modules/next/dist/server/lib/generate-agent-files.js`. Removing it from a diff only re-creates the uncommitted change; committing it with your work keeps the tree clean. + +## Commands + +Run commands inside `rocket/platform/` (or via npm scripts): + +| Command | Action | +| ------------------------ | -------------------------------------------------------------- | +| `npm run dev` | Start Next.js development server | +| `npm run build` | Build production Next.js bundle | +| `npm run start` | Start production server | +| `npm run lint` | Run ESLint | +| `npm run prettier` | Check code formatting | +| `npm run prettier:write` | Format code with Prettier | +| `npm run format` | Alias for `npm run prettier:write` | +| `npm run auth:generate` | Generate Better Auth schema (`app/lib/db/schema/auth.ts`) | +| `npm run db:generate` | Generate new SQL migrations in `drizzle/` from schemas | +| `npm run db:migrate` | Apply pending migrations from `drizzle/` to PostgreSQL | +| `npm run db:push` | Push schema changes directly to the database (prototyping/dev) | + +Always ensure `npm run lint` and `npm run prettier:write` pass cleanly. + +## Database & Migrations + +- **ORM & Dialect:** Drizzle ORM with PostgreSQL (`pg` pool, `drizzle-orm`, `drizzle-kit`). +- **Configuration:** `drizzle.config.ts` reads `DATABASE_URL` and points to schema `app/lib/db/schema/index.ts` with output in `drizzle/`. +- **Database Client:** Initialized in `app/lib/db/index.ts` using connection pool in `app/lib/db/pool.ts`. +- **Schema Directory:** All schemas live in `app/lib/db/schema/` and are re-exported by `app/lib/db/schema/index.ts`. +- **Better Auth Schema:** Managed via Better Auth CLI. Run `npm run auth:generate` whenever `app/lib/auth/auth.ts` changes. +- **Migration Workflow:** + 1. Update or create schemas under `app/lib/db/schema/` (or update auth config and run `npm run auth:generate`). + 2. Generate a new migration with `npm run db:generate`. This creates versioned SQL files under `drizzle/` (e.g. `drizzle/0000_...sql`). + 3. Apply migrations to the database with `npm run db:migrate`. + 4. Always commit generated migration files in `drizzle/` along with the schema changes. + +## Codebase Architecture & Rules + +### 1. Component Hierarchy: `bits` and `items` (`app/components/`) + +Components are divided into two distinct tiers: + +- **`bits` (`app/components/bits/`)**: Small, simpler primitive components (e.g., `Button`, `Text`, `TextBox`, `Card`, `Badge`, `Table`). Bits are low-level atomic building blocks focused on single responsibilities. +- **`items` (`app/components/items/`)**: Complex, composite components (e.g., `Navbar`, `AppSidebar`, `Footer`, `AppShell`, `AppNavbar`). Items should ideally be constructed by composing multiple `bits`. + +### 2. Container Hierarchy (`app/container/`) + +- Containers are page-targeted components. +- Each page is decomposed into multiple distinct sections, where each section lives in a dedicated container folder under `app/container//` (e.g., `landing/`, `auth/`, `dashboard/`). +- Each section container is assembled using `bits` and `items` to build its layout and UI. + +### 3. Avoid Direct HTML Entities & Tags + +- Direct HTML tags and entities (` + + + ), +}; + +export const Loading: Story = { + args: { + variant: 'primary', + loading: true, + children: 'Deploying...', + }, +}; + +export const AllSizes: Story = { + render: () => ( +
+ + + + +
+ ), +}; diff --git a/rocket/platform/componentsV2/bits/Button/index.tsx b/rocket/platform/componentsV2/bits/Button/index.tsx new file mode 100644 index 00000000..aa1bc58d --- /dev/null +++ b/rocket/platform/componentsV2/bits/Button/index.tsx @@ -0,0 +1,117 @@ +'use client'; + +import Link from 'next/link'; +import React, {forwardRef} from 'react'; + +import styles from './styles.module.css'; + +export interface ButtonProps extends React.ButtonHTMLAttributes { + variant?: 'primary' | 'secondary' | 'ghost' | 'danger' | 'outline'; + size?: 'xs' | 'sm' | 'md' | 'lg'; + href?: string; + target?: string; + rel?: string; + leftIcon?: React.ReactNode; + rightIcon?: React.ReactNode; + loading?: boolean; + fullWidth?: boolean; + classNameOverride?: string; + children?: React.ReactNode; +} + +export const Button = forwardRef< + HTMLButtonElement | HTMLAnchorElement, + ButtonProps +>(function Button( + { + variant = 'primary', + size = 'md', + href, + target, + rel, + leftIcon, + rightIcon, + loading = false, + fullWidth = false, + classNameOverride, + children, + type = 'button', + disabled, + ...rest + }, + ref, +) { + const defaultClasses = [ + styles.button, + styles[variant], + styles[size], + fullWidth ? styles.fullWidth : '', + loading ? styles.loading : '', + disabled ? styles.disabled : '', + ] + .filter(Boolean) + .join(' '); + + const combinedClass = classNameOverride ?? defaultClasses; + + const content = ( + <> + {loading ? ( +