diff --git a/README.md b/README.md index 7fcad4d..b7b24e3 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,76 @@ # shadcn-admin -[Vercel's Next.js & shadcn/ui Admin Dashboard](https://github.com/arhamkhnz/next-shadcn-admin-dashboard) on -**Cloudflare Workers**, deployed by [Orun](https://github.com/sourceplane/orun) to stage -and prod on every merge, and then packaged as an Orun baseline. - -This commit is the repository's frame: `intent.yaml` (with the placeholder -workspace `ws_CHANGE_ME`, so CI plans nothing until it is linked), the Orun -CI workflow, the shared TypeScript and ESLint configuration, and the spec -index. The work is tracked as an epic under [`specs/epics`](specs/epics/README.md). +Vercel's [Next.js & shadcn/ui Admin Dashboard](https://vercel.com/templates/next.js/next-js-and-shadcn-ui-admin-dashboard) +template — [Studio Admin](https://github.com/arhamkhnz/next-shadcn-admin-dashboard), +its dashboards, auth screens, chat, mail, kanban, calendar, data tables and +charts over mock data, with theme presets and layout controls — running on +**Cloudflare Workers + Static Assets** through +[`@opennextjs/cloudflare`](https://opennext.js.org/cloudflare), deployed by +[Orun](https://github.com/sourceplane/orun) to stage and prod on every merge. +Packaging it as an Orun baseline is the next milestone (SA2). + +The template's code is the code. What the port adds is the Workers build, +the monorepo wrapper, a test package, a health route and the deploy +contract; what it swaps is Google-hosted fonts (for self-hosted ones), the +hard-coded site origin (for an environment variable) and the template +author's analytics tag (gone). See [`specs/epics/shadcn-admin`](specs/epics/shadcn-admin/README.md) +for the design, the milestones and the as-built status. + +## What is here (the site) + +| Surface | Where | +|---|---| +| The site's name and source link | `apps/web/src/config/site.ts` (read by `apps/web/src/config/app-config.ts`) | +| The landing page | `apps/web/src/app/(external)` | +| The dashboards (default, CRM, finance, analytics, e-commerce, logistics, …), auth screens, chat, mail | `apps/web/src/app/(main)` | +| Mock data | each screen's `_components/*data*`, `apps/web/src/data` | +| Theme presets, fonts, layout preferences | `apps/web/src/styles/presets`, `apps/web/src/lib/fonts/registry.ts`, `apps/web/src/lib/preferences` | +| Sitemap, robots, health | `apps/web/src/app/sitemap.ts`, `apps/web/src/app/robots.txt/route.ts`, `apps/web/src/app/api/health/route.ts` | +| Workers build and deploy contract | `apps/web/next.config.mjs`, `open-next.config.ts`, `wrangler.jsonc`, `component.yaml` | +| Tests | `tests/web` (vitest) | + +## Getting started + +```bash +pnpm install +pnpm typecheck +pnpm lint +pnpm test +pnpm build # next build + opennextjs-cloudflare build → apps/web/.open-next +``` + +```bash +pnpm --filter @app/web dev # http://localhost:3000 +pnpm --filter @app/web preview # wrangler dev over the built Worker +``` + +One optional build-time variable (`apps/web/.env.example`): + +| Variable | What it does | +|---|---| +| `NEXT_PUBLIC_SITE_URL` | The site's public origin for the sitemap, robots, Open Graph and JSON-LD links. The Orun build sets it to the environment's `SITE_URL` (intent.yaml), else its Worker URL. Defaults to `http://localhost:3000`. | + +The data is the template's mock data, kept as it is: wire a screen to your +own source in its `_components`. The sign-in and sign-up screens are the +template's design screens: they sign nobody in. + +## How it maps to Vercel + +| Vercel | Here | +|---|---| +| Next.js hosting | One Cloudflare Worker (`.open-next/worker.js`) + Static Assets; the dashboards render per request (they read layout cookies), the static pages and assets come from the static-assets cache | +| Next.js build (Turbopack) | `next build --webpack`: Turbopack's per-route server chunks put the Worker at 3.32 MiB gzipped, over Workers Free's 3 MiB; webpack's shared chunks make it 2.25 MiB | +| `next/font/google` (17 families, fetched at build) | `next/font/local` over each family's variable font from its `@fontsource-variable` package (and `geist`), the same CSS variables | +| `opengraph-image.png` / `twitter-image.png` file convention | One static `public/opengraph-image.png`, named in the metadata (the convention compiled two copies of the PNG into the Worker) | +| Static `robots.txt` naming the demo's domain | `robots.txt/route.ts`: upstream's rules, the environment's own sitemap URL | +| The star count revalidated hourly (`next: { revalidate: 3600 }`) | Fetched once by the build (`cache: "force-cache"`), for the site's own repository | +| Google Analytics (the template author's tag) | Removed | +| Hard-coded demo origin | `NEXT_PUBLIC_SITE_URL` | +| Deploy on push | Orun deploys `-web-{stage,prod}` on merge to `main` (`apps/web/component.yaml`) | +| "Deploy with Vercel" (clone the template) | `orun new --blueprint repo-blueprint.yaml` — a new repository, branded, deployed | + +## CI + +| Workflow | What it runs | Ships to a site | +|---|---|---| +| `ci.yml` | the Orun pipeline, and the only workflow a site carries: `orun plan --changed`, then one job per lane. A pull request runs the verify lanes (the site built and dry-deployed per environment; the tests' `quick-check` lane installs and checks the package, it does not run them), except the bootstrap's own landings (`orun/BASE-*`), where `plan` alone is the check; a merge deploys stage → prod. It plans nothing while `intent.yaml` names the placeholder workspace `ws_CHANGE_ME`, as this repository does. A manual run (Orunbase's Deploy button, or Run workflow on `main`) plans the environment and components it names under the push-to-main trigger, so they deploy as a merge deploys them | yes | diff --git a/apps/web/.env.example b/apps/web/.env.example new file mode 100644 index 0000000..0fe434a --- /dev/null +++ b/apps/web/.env.example @@ -0,0 +1,3 @@ +# Optional. The site's public origin (the sitemap, robots, Open Graph and +# JSON-LD links); the Orun build sets it to the environment's Worker URL. +NEXT_PUBLIC_SITE_URL=http://localhost:3000 diff --git a/apps/web/.gitignore b/apps/web/.gitignore new file mode 100644 index 0000000..41cc630 --- /dev/null +++ b/apps/web/.gitignore @@ -0,0 +1,37 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js +.yarn/install-state.gz + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem +*.sh + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md new file mode 100644 index 0000000..beee1bb --- /dev/null +++ b/apps/web/AGENTS.md @@ -0,0 +1,98 @@ +# AGENTS.md + +## Project overview + +Studio Admin is a responsive admin dashboard built with Next.js 16, React 19, TypeScript, Tailwind CSS v4, and shadcn/ui. + +This repository uses the shadcn `radix-nova` style. The shadcn CLI reports `base: "radix"`, which refers to Radix UI. Always inspect the local components in `src/components/ui/` because individual wrappers may use different primitives. + + + +# This is NOT the Next.js you know + +This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` (resolved from this file's directory; in monorepos the `next` package may not be visible from the repo root) before writing any code. Heed deprecation notices. + +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. + + + +## shadcn skill + +Use the shadcn skill for all work involving shadcn/ui components, styling, composition, registries, presets, or `components.json`. + +If the skill is not available, install it with: + +```bash +npx skills add shadcn/ui +``` + +The skill contains the component, styling, composition, accessibility, and CLI rules. Do not duplicate those rules here. Always inspect the local component source before using it. + +Do not modify files inside `src/components/ui/` or `src/components/calendar/`. Keep these components intact and apply styling or customization where they are used. + +## Setup + +This project uses npm. + +```bash +npm install +npm run dev +``` + +Available commands: + +```bash +npm run build +npm run lint +npm run format +npm run check +npm run check:fix +npm run generate:presets +``` + +There is currently no automated test command. Run build, lint, check, or other validation commands only when the user explicitly requests that validation. + +## Co-location-based structure + +Keep feature code close to the route that owns it. + +- Dashboard routes: `src/app/(main)/dashboard//page.tsx` +- Screen-specific components, data, and schemas: `src/app/(main)/dashboard//_components/` +- Shared dashboard components: `src/app/(main)/dashboard/_components/` +- Shared application components: `src/components/` +- Local shadcn components: `src/components/ui/` +- Shared hooks and utilities: `src/hooks/` and `src/lib/` +- Theme presets: `src/styles/presets/` + +Keep a component inside its route until it is reused by another feature. Do not move screen-specific code into a shared directory preemptively. + +## Creating or extending a screen + +1. Inspect the closest current screen before writing code. Finance, Infrastructure, CRM, and Analytics are useful references. Do not use routes under `(legacy)` as references for new screens unless maintaining a legacy route. +2. When reproducing a UI from a screenshot or image, follow its visual direction closely, including layout, hierarchy, spacing, component structure, and important details. Implement it with the project's existing components and semantic theme tokens rather than copying raw color values. If the design needs a color that is not available through the existing theme tokens, or the user explicitly requests a non-theme color, use a named color from Tailwind's default palette. Do not use arbitrary hex, RGB, HSL, or OKLCH values. +3. Reuse the existing dashboard shell, local components, layout controls, and theme tokens. +4. Break each new page into focused components inside the route's `_components/` directory. Keep `page.tsx` small and focused on composing those pieces. +5. Keep `page.tsx` as a Server Component by default. Move interactive or browser-dependent code into a dedicated Client Component. +6. Add the screen to `src/navigation/sidebar/sidebar-items.ts` when it should appear in the dashboard navigation. +7. Decide the information hierarchy before choosing widgets. Let the content determine the page structure. +8. Keep the established visual rhythm where it fits: compact spacing, clear typography hierarchy, responsive action rows, and grids that collapse cleanly on smaller screens. +9. Widget selection is not a fixed formula. Try different arrangements of cards, resource rows, meters, charts, tabs, empty states, and actions, then keep the version that communicates the content clearly and feels consistent with the project. +10. Match nearby screens in card density, borders, radius, spacing, content width, and responsive behavior. +11. Use semantic theme tokens so new screens work with light mode, dark mode, and the existing theme presets. +12. Handle relevant loading, empty, error, disabled, and overflow states. +13. Keep screens accessible with semantic HTML, keyboard support, visible focus states, labels, and appropriate ARIA attributes. + +## Code conventions + +- TypeScript strict mode is enabled. Use precise types and avoid `any`. +- Use the existing `@/` import aliases. +- Follow the Biome configuration: double quotes, semicolons, two-space indentation, sorted imports, and a 120-character line width. +- Avoid unnecessary dependencies. +- Keep changes focused and do not refactor unrelated files. + +## Contributions + +- Use conventional commit prefixes such as `feat:`, `fix:`, `refactor:`, `docs:`, and `chore:`. +- Include screenshots for new screens and material visual changes. Include mobile and dark-theme states when relevant. +- Explain new reusable patterns or dependencies in the pull request. +- Follow `CONTRIBUTING.md` for the contribution workflow. diff --git a/apps/web/LICENSE.md b/apps/web/LICENSE.md new file mode 100644 index 0000000..9022b24 --- /dev/null +++ b/apps/web/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Mohammed Arham Khan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/apps/web/README.md b/apps/web/README.md new file mode 100644 index 0000000..901dc5e --- /dev/null +++ b/apps/web/README.md @@ -0,0 +1,29 @@ +# apps/web — the site + +Studio Admin, the admin dashboard from Vercel's +[Next.js & shadcn/ui Admin Dashboard](https://github.com/arhamkhnz/next-shadcn-admin-dashboard) +template (MIT), running on Cloudflare Workers + Static Assets: + +- Two dozen screens (`src/app/(main)`): the dashboards default, CRM, finance, + analytics, e-commerce, products, academy, logistics, infrastructure, file + manager, patient monitoring, productivity, calendar, kanban, tasks, users, + roles, invoice and profile, and chat and mail — over the template's mock data +- Auth screens (`/auth/v1`, `/auth/v2`): design only, they sign nobody in +- Theme presets, fonts and layout preferences (`src/styles/presets`, + `src/lib/fonts`, `src/lib/preferences`), kept in cookies +- A landing page (`src/app/(external)`), sitemap, robots and `/api/health` +- Next.js 16, React 19, Tailwind CSS v4, shadcn/ui, Biome + +The site's name and the repository its landing page links to are in +`src/config/site.ts`. The fonts are self-hosted from `@fontsource-variable` +packages (`src/lib/fonts/registry.ts`). + +```bash +pnpm dev # next dev on http://localhost:3000 +pnpm build # next build --webpack + opennextjs-cloudflare build → .open-next/ +pnpm preview # wrangler dev over the built Worker +pnpm check # biome +``` + +How it is deployed — per environment, on merge to `main` — is the +repository's README and `component.yaml` beside this file. diff --git a/apps/web/biome.json b/apps/web/biome.json new file mode 100644 index 0000000..a984a92 --- /dev/null +++ b/apps/web/biome.json @@ -0,0 +1,131 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.6.3/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": true + }, + "assist": { + "enabled": true, + "actions": { + "source": { + "organizeImports": { + "level": "on", + "options": { + "groups": [ + "react", + "react/**", + ":BLANK_LINE:", + "next/**", + ":BLANK_LINE:", + ":PACKAGE:", + ":BLANK_LINE:", + ":ALIAS:", + ":BLANK_LINE:", + ":PATH:" + ] + } + } + } + } + }, + "files": { + "ignoreUnknown": true, + "includes": [ + "**", + "!**/*.md", + "!.github", + "!.husky", + "!node_modules", + "!.next", + "!dist", + "!out", + "!src/components/ui", + "!src/components/calendar" + ] + }, + "formatter": { + "enabled": true, + "formatWithErrors": false, + "indentStyle": "space", + "indentWidth": 2, + "lineEnding": "lf", + "lineWidth": 120, + "attributePosition": "auto", + "bracketSameLine": false, + "bracketSpacing": true, + "expand": "auto", + "useEditorconfig": true + }, + "linter": { + "enabled": true, + "rules": { + "preset": "recommended", + "correctness": { + "noUndeclaredVariables": "error", + "noNestedComponentDefinitions": "error", + "noUndeclaredDependencies": "error" + }, + "nursery": { + "useTailwindSortedClasses": "on", + "useNullishCoalescing": "error", + "noFloatingPromises": "error", + "noMisusedPromises": "error" + }, + "performance": { + "noImgElement": "warn" + }, + "style": { + "noCommonJs": "error", + "noHeadElement": "warn", + "noNamespace": "error", + "useAsConstAssertion": "error", + "useSelfClosingElements": "error", + "noNestedTernary": "warn", + "noParameterAssign": "error", + "noInferrableTypes": "error", + "noUselessElse": "error", + "useFilenamingConvention": "error" + }, + "suspicious": { + "noArrayIndexKey": "warn", + "noConstantBinaryExpressions": "error", + "noEmptyBlockStatements": "error", + "noUnknownAtRules": "off", + "noImportCycles": "error", + "noUnnecessaryConditions": "warn" + }, + "complexity": { + "noImportantStyles": "off" + } + }, + "domains": { + "next": "recommended", + "react": "recommended" + } + }, + "css": { + "parser": { + "tailwindDirectives": true + } + }, + "javascript": { + "formatter": { + "jsxQuoteStyle": "double", + "quoteProperties": "asNeeded", + "trailingCommas": "all", + "semicolons": "always", + "arrowParentheses": "always", + "bracketSameLine": false, + "quoteStyle": "double", + "attributePosition": "auto", + "bracketSpacing": true + } + }, + "html": { + "formatter": { + "indentScriptAndStyle": false, + "selfCloseVoidElements": "always" + } + } +} diff --git a/apps/web/component.yaml b/apps/web/component.yaml new file mode 100644 index 0000000..da15997 --- /dev/null +++ b/apps/web/component.yaml @@ -0,0 +1,84 @@ +apiVersion: sourceplane.io/v1 +kind: Component +metadata: + name: web + description: The admin dashboard (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) +spec: + type: cloudflare-workers-assets-turbo + lifecycle: production + owner: platform + # Its pages, attached to it in the workspace's catalog: what the Docs + # library shows for it, and what the catalog's docs and runbook checks read. + # Generated from what this manifest and its sources declare. + docs: + overview: docs/overview.md + pages: + - { path: docs/architecture.md, role: architecture, title: Architecture } + - { path: docs/runbook.md, role: runbook, title: Runbook } + # `app`, not `web`: a domain and a component share one name space in the + # catalog, and a domain called `web` hid this component from it. + domain: app + path: apps/web + # Its own lane per environment: the Next.js build is the longest job in the + # plan, and a shared lane would wait on it. + lane: isolated + subscribe: + environments: + - name: dev + profile: verify + - name: stage + profile: verify + profileRules: + - profile: deploy + when: + triggerRef: github-push-main + - name: prod + profile: verify + profileRules: + - profile: deploy + when: + triggerRef: github-push-main + parameters: + nodeVersion: "22" + pnpmVersion: "10.12.1" + + workspaceDir: ../.. + appDir: . + + turboFilter: "@app/web" + wranglerConfig: wrangler.jsonc + + # @opennextjs/cloudflare emits a Worker entrypoint plus a static-assets + # directory bound via ASSETS — both deploy in one `wrangler deploy`. + workerEntrypoint: .open-next/worker.js + assetsDir: .open-next/assets + + # Per-env worker name: shadcn-admin-web-{dev,stage,prod}. + workerName: shadcn-admin-web + environmentAwareWorkerName: true + + # The account's workers.dev subdomain; exported to the smoke step as + # ${WORKERS_DEV_SUBDOMAIN} and used to build ${DEPLOYED_URL}. + workersDevSubdomain: your-workers-subdomain + + installCommand: pnpm install --frozen-lockfile + # The site's public origin (the sitemap, robots, Open Graph and JSON-LD links are + # absolute): the environment's SITE_URL when intent.yaml sets one (a custom + # domain), else its workers.dev URL. The subdomain is written out rather + # than read from ${WORKERS_DEV_SUBDOMAIN}: the composition exports that to + # the smoke step only, so the build saw it empty and baked + # `https://-..workers.dev` into every absolute link. + # ${ORUN_ENVIRONMENT} the runner sets for every step. + buildCommand: NEXT_PUBLIC_SITE_URL="${SITE_URL:-https://shadcn-admin-web-${ORUN_ENVIRONMENT}.your-workers-subdomain.workers.dev}" pnpm exec turbo run build --filter=@app/web + + # Smoke: the landing page renders the site (its "Live demo" link into the + # dashboard — not the site's name, which is the owner's to change and + # HTML-escaped when it carries an `&` or `'`), the default dashboard + # renders, and the Worker's health route answers. Each response is + # buffered before grep so an early match cannot SIGPIPE curl. + smokeCommand: "html=$(curl -sfL \"${DEPLOYED_URL}/\") && echo \"${html}\" | grep -q 'href=\"/dashboard/default\"' && dash=$(curl -sfL \"${DEPLOYED_URL}/dashboard/default\") && echo \"${dash}\" | grep -q 'data-sidebar' && health=$(curl -sfL \"${DEPLOYED_URL}/api/health\") && echo \"${health}\" | grep -q '\"ok\":true'" + labels: + team: platform + layer: delivery + surface: web + runtime: cloudflare diff --git a/apps/web/components.json b/apps/web/components.json new file mode 100644 index 0000000..2a42785 --- /dev/null +++ b/apps/web/components.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://ui.shadcn.com/schema.json", + "style": "radix-nova", + "rsc": true, + "tsx": true, + "tailwind": { + "config": "", + "css": "src/app/globals.css", + "baseColor": "neutral", + "cssVariables": true, + "prefix": "" + }, + "iconLibrary": "lucide", + "rtl": false, + "aliases": { + "components": "@/components", + "utils": "@/lib/utils", + "ui": "@/components/ui", + "lib": "@/lib", + "hooks": "@/hooks" + }, + "menuColor": "default", + "menuAccent": "subtle", + "registries": {} +} diff --git a/apps/web/docs/architecture.md b/apps/web/docs/architecture.md new file mode 100644 index 0000000..eb30077 --- /dev/null +++ b/apps/web/docs/architecture.md @@ -0,0 +1,16 @@ +# web — architecture + +Built by the turbo pipeline from `apps/web` and deployed with wrangler. + +| | | +| ------------------- | ----------------------------------------------- | +| Worker config | `apps/web/wrangler.jsonc` | +| Entry | `.open-next/worker.js` | +| Compatibility date | `2026-10-01` | +| Compatibility flags | `nodejs_compat`, `global_fetch_strictly_public` | + +## Bindings + +| Binding | Kind | Source | +| -------- | ------------- | ------------------- | +| `ASSETS` | Static assets | `.open-next/assets` | diff --git a/apps/web/docs/overview.md b/apps/web/docs/overview.md new file mode 100644 index 0000000..37f3511 --- /dev/null +++ b/apps/web/docs/overview.md @@ -0,0 +1,20 @@ +# web + +The admin dashboard (Next.js on Cloudflare Workers + Static Assets via @opennextjs/cloudflare, per environment) + +A Cloudflare Worker with Static Assets (server rendering plus static files), deployed per environment by its CI lane. + +| | | +| ------------ | ------------------------------------------------------------------------------------------------------------------ | +| Type | `cloudflare-workers-assets-turbo` | +| Source | `apps/web` | +| Package | `@app/web` | +| Environments | `dev`: `verify` · `stage`: `verify`, `deploy` on a push to `main` · `prod`: `verify`, `deploy` on a push to `main` | + +## Depends on + +- (none) + +## Depended on by + +- (none) diff --git a/apps/web/docs/runbook.md b/apps/web/docs/runbook.md new file mode 100644 index 0000000..c6725a0 --- /dev/null +++ b/apps/web/docs/runbook.md @@ -0,0 +1,37 @@ +# web — runbook + +## How it runs + +Pull requests verify it; a merge to `main` deploys it to `stage`, `prod`. +CI plans what changed (`orun plan --changed`) and runs each lane with `orun run`; +the plan orders a component after everything it depends on. + +## Local commands + +```bash +pnpm --filter @app/web dev +pnpm --filter @app/web build +pnpm --filter @app/web typecheck +pnpm --filter @app/web lint +pnpm --filter @app/web preview +``` + +## Verify + +After a deploy the lane runs this smoke against the environment it +deployed (`ORUN_ENVIRONMENT`); `DEPLOYED_URL` overrides the URL: + +```bash +html=$(curl -sfL "${DEPLOYED_URL}/") && echo "${html}" | grep -q 'href="/dashboard/default"' && dash=$(curl -sfL "${DEPLOYED_URL}/dashboard/default") && echo "${dash}" | grep -q 'data-sidebar' && health=$(curl -sfL "${DEPLOYED_URL}/api/health") && echo "${health}" | grep -q '"ok":true' +``` + +## Rollback + +Revert the commit on `main`. The next convergence applies the previous desired +state; nothing was changed out of band, so there is nothing else to undo. + +## Common failures + +- **The smoke fails right after a first deploy**: a new workers.dev route can + answer 4xx for a few seconds and the lane retries. A failure that persists + is a regression in the deployed code. diff --git a/apps/web/media/default/default-dark.webp b/apps/web/media/default/default-dark.webp new file mode 100644 index 0000000..f03ac8a Binary files /dev/null and b/apps/web/media/default/default-dark.webp differ diff --git a/apps/web/media/default/default-light.webp b/apps/web/media/default/default-light.webp new file mode 100644 index 0000000..9464d6e Binary files /dev/null and b/apps/web/media/default/default-light.webp differ diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs new file mode 100644 index 0000000..48e2e51 --- /dev/null +++ b/apps/web/next.config.mjs @@ -0,0 +1,34 @@ +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const root = path.join(__dirname, "../.."); + +/** @type {import('next').NextConfig} */ +const nextConfig = { + // Required by @opennextjs/cloudflare, which bundles `.next/standalone/**` + // into the Worker. Trace from the monorepo root so workspace dependencies + // resolve from the root node_modules. + output: "standalone", + outputFileTracingRoot: root, + turbopack: { root }, + // Workers has no image optimizer: next/image serves the source file. + images: { unoptimized: true }, + + // The template's own settings, unchanged. + reactCompiler: true, + compiler: { + removeConsole: process.env.NODE_ENV === "production", + }, + async redirects() { + return [ + { + source: "/dashboard", + destination: "/dashboard/default", + permanent: false, + }, + ]; + }, +}; + +export default nextConfig; diff --git a/apps/web/open-next.config.ts b/apps/web/open-next.config.ts new file mode 100644 index 0000000..d528f10 --- /dev/null +++ b/apps/web/open-next.config.ts @@ -0,0 +1,14 @@ +// OpenNext Cloudflare adapter config. +// +// The template is statically generated: every page is pre-rendered at build +// time and nothing revalidates. The static-assets incremental cache serves +// those pre-rendered pages straight from the Worker's static assets (read +// only, no R2/KV/D1 to provision), which is exactly the shape of a content +// site. A template that revalidates (ISR, `revalidateTag`) swaps this for the +// R2 incremental cache plus a tag cache. +import { defineCloudflareConfig } from "@opennextjs/cloudflare/config"; +import staticAssetsIncrementalCache from "@opennextjs/cloudflare/overrides/incremental-cache/static-assets-incremental-cache"; + +export default defineCloudflareConfig({ + incrementalCache: staticAssetsIncrementalCache, +}); diff --git a/apps/web/package.json b/apps/web/package.json new file mode 100644 index 0000000..fd37dc3 --- /dev/null +++ b/apps/web/package.json @@ -0,0 +1,86 @@ +{ + "name": "@app/web", + "version": "2.2.0", + "private": true, + "scripts": { + "dev": "next dev -p 3000", + "build": "next build --webpack && opennextjs-cloudflare build --skipBuild --skipWranglerConfigCheck && opennextjs-cloudflare populateCache local", + "start": "next start -p 3000", + "preview": "opennextjs-cloudflare preview", + "typecheck": "tsc --noEmit", + "lint": "biome lint", + "format": "biome format --write", + "check": "biome check", + "check:fix": "biome check --write", + "generate:presets": "ts-node -P tsconfig.scripts.json src/scripts/generate-theme-presets.ts" + }, + "dependencies": { + "@base-ui/react": "1.9.0", + "@dnd-kit/abstract": "0.5.1", + "@dnd-kit/helpers": "0.5.1", + "@dnd-kit/react": "0.5.1", + "@fontsource-variable/dm-sans": "5.3.0", + "@fontsource-variable/figtree": "5.3.0", + "@fontsource-variable/inter": "5.3.0", + "@fontsource-variable/jetbrains-mono": "5.3.0", + "@fontsource-variable/lora": "5.3.0", + "@fontsource-variable/merriweather": "5.3.0", + "@fontsource-variable/noto-sans": "5.3.0", + "@fontsource-variable/noto-serif": "5.3.0", + "@fontsource-variable/nunito-sans": "5.3.0", + "@fontsource-variable/outfit": "5.3.0", + "@fontsource-variable/playfair-display": "5.3.0", + "@fontsource-variable/public-sans": "5.3.0", + "@fontsource-variable/raleway": "5.3.0", + "@fontsource-variable/roboto": "5.3.0", + "@fontsource-variable/roboto-slab": "5.3.0", + "@fullcalendar/react": "7.1.3", + "@hookform/resolvers": "5.9.2", + "@opennextjs/cloudflare": "1.20.11", + "@shadcn/react": "0.3.1", + "@tanstack/react-table": "9.3.1", + "class-variance-authority": "0.7.1", + "cmdk": "1.1.1", + "cn": "0.5.0", + "d3-geo": "3.1.1", + "date-fns": "4.4.0", + "embla-carousel-react": "8.6.0", + "geist": "1.8.2", + "input-otp": "1.5.0", + "lucide-react": "1.62.0", + "next": "16.3.8", + "next-themes": "0.4.6", + "radix-ui": "1.8.1", + "react": "19.3.1", + "react-day-picker": "10.0.2", + "react-dom": "19.3.1", + "react-hook-form": "7.91.0", + "react-resizable-panels": "4.15.0", + "recharts": "3.8.0", + "shadcn": "4.22.2", + "shiki": "4.5.0", + "simple-icons": "16.36.0", + "sonner": "2.0.8", + "temporal-polyfill": "1.0.6", + "topojson-client": "3.1.0", + "vaul": "1.1.2", + "zod": "4.6.7", + "zustand": "5.0.16" + }, + "devDependencies": { + "@biomejs/biome": "2.6.3", + "@tailwindcss/postcss": "4.3.3", + "@types/d3-geo": "3.1.1", + "@types/node": "22.20.5", + "@types/react": "19.3.0", + "@types/react-dom": "19.3.0", + "@types/topojson-client": "3.1.5", + "babel-plugin-react-compiler": "1.0.0", + "postcss": "8.5.32", + "tailwindcss": "4.3.3", + "ts-node": "10.9.2", + "tw-animate-css": "1.4.0", + "typescript": "5.9.3", + "wrangler": "^4.151.0" + } +} diff --git a/apps/web/postcss.config.mjs b/apps/web/postcss.config.mjs new file mode 100644 index 0000000..79bcf13 --- /dev/null +++ b/apps/web/postcss.config.mjs @@ -0,0 +1,8 @@ +/** @type {import('postcss-load-config').Config} */ +const config = { + plugins: { + "@tailwindcss/postcss": {}, + }, +}; + +export default config; diff --git a/apps/web/public/opengraph-image.png b/apps/web/public/opengraph-image.png new file mode 100644 index 0000000..64d3e75 Binary files /dev/null and b/apps/web/public/opengraph-image.png differ diff --git a/apps/web/src/app/(external)/_components/footer.tsx b/apps/web/src/app/(external)/_components/footer.tsx new file mode 100644 index 0000000..3875476 --- /dev/null +++ b/apps/web/src/app/(external)/_components/footer.tsx @@ -0,0 +1,41 @@ +import { siGithub, siX } from "simple-icons"; + +import { SimpleIcon } from "@/components/simple-icon"; +import { Button } from "@/components/ui/button"; + +export function Footer() { + return ( + + ); +} diff --git a/apps/web/src/app/(external)/_components/github-star-button.tsx b/apps/web/src/app/(external)/_components/github-star-button.tsx new file mode 100644 index 0000000..94d403b --- /dev/null +++ b/apps/web/src/app/(external)/_components/github-star-button.tsx @@ -0,0 +1,31 @@ +"use client"; + +import { StarIcon } from "lucide-react"; + +import { Button } from "@/components/ui/button"; + +import { useGitHubStarCount } from "../_hooks/use-github-star-count"; + +type GitHubStarButtonProps = { + initialCount: number | null; + repositoryUrl: string; +}; + +export function GitHubStarButton({ initialCount, repositoryUrl }: GitHubStarButtonProps) { + const starCount = useGitHubStarCount(initialCount); + + return ( + + ); +} diff --git a/apps/web/src/app/(external)/_components/intro.tsx b/apps/web/src/app/(external)/_components/intro.tsx new file mode 100644 index 0000000..d530cc2 --- /dev/null +++ b/apps/web/src/app/(external)/_components/intro.tsx @@ -0,0 +1,64 @@ +import Link from "next/link"; + +import { ArrowUpRight } from "lucide-react"; + +import { Button } from "@/components/ui/button"; + +import { APP_CONFIG } from "@/config/app-config"; + +import { starCountUrl } from "../_hooks/star-count-url"; +import { GitHubStarButton } from "./github-star-button"; + +const repositoryUrl = APP_CONFIG.repository; +const repositoryStarsUrl = starCountUrl(repositoryUrl); + +type GitHubStarsResponse = { + count: number; +}; + +async function getGitHubStarCount() { + try { + const response = await fetch(repositoryStarsUrl, { + headers: { + Accept: "application/vnd.github+json", + "User-Agent": repositoryUrl.split("/").pop() ?? "admin", + "X-GitHub-Api-Version": "2026-03-10", + }, + cache: "force-cache", + }); + + if (!response.ok) return null; + + const data = (await response.json()) as GitHubStarsResponse; + return Number.isFinite(data.count) ? data.count : null; + } catch { + return null; + } +} + +export async function Intro() { + const starCount = await getGitHubStarCount(); + + return ( +
+
+

+ A polished admin dashboard built to fit your stack and the way you work. +

+

+ Choose Radix UI, Base UI, React Aria, or TanStack Start, all with the same polished experience. +

+
+ +
+ + +
+
+ ); +} diff --git a/apps/web/src/app/(external)/_components/landing-theme-switcher.tsx b/apps/web/src/app/(external)/_components/landing-theme-switcher.tsx new file mode 100644 index 0000000..ea11eb9 --- /dev/null +++ b/apps/web/src/app/(external)/_components/landing-theme-switcher.tsx @@ -0,0 +1,44 @@ +"use client"; + +import { Monitor, Moon, Sun } from "lucide-react"; +import { useShallow } from "zustand/react/shallow"; + +import { Button } from "@/components/ui/button"; +import { usePreferencesStore } from "@/stores/preferences/preferences-provider"; + +const THEME_CYCLE = ["light", "dark", "system"] as const; + +export function LandingThemeSwitcher() { + const { themeMode, setPreference } = usePreferencesStore( + useShallow((state) => ({ + themeMode: state.values.theme_mode, + setPreference: state.setPreference, + })), + ); + + const cycleTheme = () => { + const currentIndex = THEME_CYCLE.indexOf(themeMode); + const nextTheme = THEME_CYCLE[(currentIndex + 1) % THEME_CYCLE.length]; + const updateTheme = () => setPreference("theme_mode", nextTheme); + + if (!document.startViewTransition || window.matchMedia("(prefers-reduced-motion: reduce)").matches) { + updateTheme(); + return; + } + + document.startViewTransition(updateTheme); + }; + + return ( + + ); +} diff --git a/apps/web/src/app/(external)/_components/overview.tsx b/apps/web/src/app/(external)/_components/overview.tsx new file mode 100644 index 0000000..684d82f --- /dev/null +++ b/apps/web/src/app/(external)/_components/overview.tsx @@ -0,0 +1,111 @@ +import Link from "next/link"; + +import { APP_CONFIG } from "@/config/app-config"; + +const includedScreens = [ + { name: "Analytics", href: "/dashboard/analytics" }, + { name: "CRM", href: "/dashboard/crm" }, + { name: "Finance", href: "/dashboard/finance" }, + { name: "E-commerce", href: "/dashboard/ecommerce" }, + { name: "Productivity", href: "/dashboard/productivity" }, + { name: "File manager", href: "/dashboard/file-manager" }, + { name: "Calendar", href: "/dashboard/calendar" }, +]; + +const editions = [ + { + name: "Radix UI", + repository: "https://github.com/arhamkhnz/next-shadcn-admin-dashboard", + }, + { + name: "Base UI", + repository: "https://github.com/arhamkhnz/next-shadcn-admin-dashboard-baseui", + }, + { + name: "React Aria", + repository: "https://github.com/arhamkhnz/next-shadcn-admin-dashboard-aria", + }, + { + name: "TanStack Start", + repository: "https://github.com/arhamkhnz/tanstack-shadcn-admin-dashboard", + }, +]; + +export function Overview() { + return ( +
+
+
+
+

About

+

+ An open source shadcn/ui admin dashboard with 25+ screens, ready to make your own. +

+
+ +
+

Make it yours

+

+ Customize the fonts, themes, content width, navbar, and sidebar layout. Each edition stays native to its + foundation while keeping the design consistent. +

+

+ For setup instructions, refer to the{" "} + + setup guide on GitHub + + . +

+

+ If you're looking for individual blocks, please refer to{" "} + + Studio Blocks + + . +

+
+
+ +
+
+

Featured screens

+
    + {includedScreens.map((screen) => ( +
  • + + {screen.name} + +
  • + ))} +
+
+ +
+

Editions

+ +
+
+
+
+ ); +} diff --git a/apps/web/src/app/(external)/_components/showcase.tsx b/apps/web/src/app/(external)/_components/showcase.tsx new file mode 100644 index 0000000..e791898 --- /dev/null +++ b/apps/web/src/app/(external)/_components/showcase.tsx @@ -0,0 +1,30 @@ +import { Card } from "@/components/ui/card"; + +import defaultDarkImage from "../../../../media/default/default-dark.webp"; +import defaultLightImage from "../../../../media/default/default-light.webp"; +import { APP_CONFIG } from "@/config/app-config"; + +export function Showcase() { + return ( +
+ + {/* biome-ignore lint/performance/noImgElement: These landing images are optimized separately. */} + {`${APP_CONFIG.name} + {/* biome-ignore lint/performance/noImgElement: These landing images are optimized separately. */} + {`${APP_CONFIG.name} + +
+ ); +} diff --git a/apps/web/src/app/(external)/_hooks/star-count-url.ts b/apps/web/src/app/(external)/_hooks/star-count-url.ts new file mode 100644 index 0000000..7ceaf2b --- /dev/null +++ b/apps/web/src/app/(external)/_hooks/star-count-url.ts @@ -0,0 +1,4 @@ +// GitHub's star count for a repository link (https://github.com//). +export function starCountUrl(repositoryUrl: string): string { + return `${repositoryUrl.replace("https://github.com/", "https://api.github.com/repos/")}/stargazers/count`; +} diff --git a/apps/web/src/app/(external)/_hooks/use-github-star-count.ts b/apps/web/src/app/(external)/_hooks/use-github-star-count.ts new file mode 100644 index 0000000..1027931 --- /dev/null +++ b/apps/web/src/app/(external)/_hooks/use-github-star-count.ts @@ -0,0 +1,51 @@ +"use client"; + +import { useEffect, useState } from "react"; + +import { APP_CONFIG } from "@/config/app-config"; + +import { starCountUrl } from "./star-count-url"; + +const repositoryStarsUrl = starCountUrl(APP_CONFIG.repository); + +type GitHubStarsResponse = { + count: number; +}; + +export function useGitHubStarCount(initialCount: number | null) { + const [starCount, setStarCount] = useState(initialCount); + + useEffect(() => { + if (initialCount !== null) return; + + const controller = new AbortController(); + + async function loadStarCount() { + try { + const response = await fetch(repositoryStarsUrl, { + headers: { + Accept: "application/vnd.github+json", + "X-GitHub-Api-Version": "2026-03-10", + }, + signal: controller.signal, + }); + + if (!response.ok) return; + + const data = (await response.json()) as GitHubStarsResponse; + + if (Number.isFinite(data.count)) { + setStarCount(data.count); + } + } catch { + return; + } + } + + void loadStarCount(); + + return () => controller.abort(); + }, [initialCount]); + + return starCount; +} diff --git a/apps/web/src/app/(external)/landing.module.css b/apps/web/src/app/(external)/landing.module.css new file mode 100644 index 0000000..8e68526 --- /dev/null +++ b/apps/web/src/app/(external)/landing.module.css @@ -0,0 +1,69 @@ +.landing { + --radius: 0.625rem; + --background: oklch(1 0 0); + --foreground: oklch(0.145 0 0); + --card: oklch(1 0 0); + --card-foreground: oklch(0.145 0 0); + --popover: oklch(1 0 0); + --popover-foreground: oklch(0.145 0 0); + --primary: oklch(0.205 0 0); + --primary-foreground: oklch(0.985 0 0); + --secondary: oklch(0.97 0 0); + --secondary-foreground: oklch(0.205 0 0); + --muted: oklch(0.97 0 0); + --muted-foreground: oklch(0.556 0 0); + --accent: oklch(0.97 0 0); + --accent-foreground: oklch(0.205 0 0); + --destructive: oklch(0.577 0.245 27.325); + --border: oklch(0.922 0 0); + --input: oklch(0.922 0 0); + --ring: oklch(0.708 0 0); + --chart-1: oklch(0.87 0 0); + --chart-2: oklch(0.556 0 0); + --chart-3: oklch(0.439 0 0); + --chart-4: oklch(0.371 0 0); + --chart-5: oklch(0.269 0 0); + --sidebar: oklch(0.985 0 0); + --sidebar-foreground: oklch(0.145 0 0); + --sidebar-primary: oklch(0.205 0 0); + --sidebar-primary-foreground: oklch(0.985 0 0); + --sidebar-accent: oklch(0.97 0 0); + --sidebar-accent-foreground: oklch(0.205 0 0); + --sidebar-border: oklch(0.922 0 0); + --sidebar-ring: oklch(0.708 0 0); +} + +/* biome-ignore lint/correctness/noUnknownPseudoClass: CSS Modules global selector. */ +:global(.dark) .landing { + --background: oklch(0.145 0 0); + --foreground: oklch(0.985 0 0); + --card: oklch(0.205 0 0); + --card-foreground: oklch(0.985 0 0); + --popover: oklch(0.205 0 0); + --popover-foreground: oklch(0.985 0 0); + --primary: oklch(0.922 0 0); + --primary-foreground: oklch(0.205 0 0); + --secondary: oklch(0.269 0 0); + --secondary-foreground: oklch(0.985 0 0); + --muted: oklch(0.269 0 0); + --muted-foreground: oklch(0.708 0 0); + --accent: oklch(0.269 0 0); + --accent-foreground: oklch(0.985 0 0); + --destructive: oklch(0.704 0.191 22.216); + --border: oklch(1 0 0 / 10%); + --input: oklch(1 0 0 / 15%); + --ring: oklch(0.556 0 0); + --chart-1: oklch(0.87 0 0); + --chart-2: oklch(0.556 0 0); + --chart-3: oklch(0.439 0 0); + --chart-4: oklch(0.371 0 0); + --chart-5: oklch(0.269 0 0); + --sidebar: oklch(0.205 0 0); + --sidebar-foreground: oklch(0.985 0 0); + --sidebar-primary: oklch(0.488 0.243 264.376); + --sidebar-primary-foreground: oklch(0.985 0 0); + --sidebar-accent: oklch(0.269 0 0); + --sidebar-accent-foreground: oklch(0.985 0 0); + --sidebar-border: oklch(1 0 0 / 10%); + --sidebar-ring: oklch(0.556 0 0); +} diff --git a/apps/web/src/app/(external)/page.tsx b/apps/web/src/app/(external)/page.tsx new file mode 100644 index 0000000..1318be5 --- /dev/null +++ b/apps/web/src/app/(external)/page.tsx @@ -0,0 +1,71 @@ +import Link from "next/link"; + +import type { Metadata } from "next"; + +import { Separator } from "@/components/ui/separator"; +import { APP_CONFIG, SOCIAL_IMAGE } from "@/config/app-config"; + +import { Footer } from "./_components/footer"; +import { Intro } from "./_components/intro"; +import { LandingThemeSwitcher } from "./_components/landing-theme-switcher"; +import { Overview } from "./_components/overview"; +import { Showcase } from "./_components/showcase"; +import styles from "./landing.module.css"; + +export const metadata: Metadata = { + title: APP_CONFIG.meta.title, + description: APP_CONFIG.meta.description, + alternates: { + canonical: "/", + }, + openGraph: { + type: "website", + siteName: APP_CONFIG.name, + locale: "en_US", + url: "/", + title: APP_CONFIG.meta.title, + description: APP_CONFIG.meta.description, + images: [SOCIAL_IMAGE], + }, +}; + +export default function Home() { + const websiteJsonLd = { + "@context": "https://schema.org", + "@type": "WebSite", + name: APP_CONFIG.name, + url: new URL("/", APP_CONFIG.url).href, + }; + + // Keeps landing-page colors independent from saved dashboard theme presets. + return ( +
+