commit 2b1d2152c4d89d509a91ee01523b28ae9a87d41c Author: Jose Selesan Date: Thu Oct 15 15:24:34 2026 -0300 chore: scaffold turbo monorepo with hono api and react admin web diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..aedf635 --- /dev/null +++ b/.env.example @@ -0,0 +1,17 @@ +# --- apps/api --- +# Postgres connection string used by Prisma +DATABASE_URL="postgresql://postgres:postgres@localhost:5432/superlist?schema=public" +# Port the Hono server listens on +PORT=3000 +# Comma separated list of origins allowed by CORS (the web dev server) +CORS_ORIGIN="http://localhost:5173" +# Secret used by BetterAuth to sign sessions +BETTER_AUTH_SECRET="change-me-with-openssl-rand-base64-32" +# Public URL of the API, used by BetterAuth +BETTER_AUTH_URL="http://localhost:3000" +# "development" enables pretty logs, "production" emits JSON +NODE_ENV="development" + +# --- apps/web --- +# Public URL of the API consumed by the frontend +VITE_API_URL="http://localhost:3000" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..869b83b --- /dev/null +++ b/.gitignore @@ -0,0 +1,25 @@ +node_modules/ +dist/ +build/ +.turbo/ +coverage/ +*.tsbuildinfo + +# env +.env +.env.local +.env.*.local + +# logs +*.log +logs/ + +# editors / os +.vscode/* +!.vscode/extensions.json +.idea/ +.DS_Store + +# generated +apps/web/src/routeTree.gen.ts +apps/api/src/generated/ diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..ec573b6 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +node_modules +dist +coverage +.turbo +bun.lock +apps/web/src/routeTree.gen.ts diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..c03d068 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,7 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "all", + "printWidth": 100, + "tabWidth": 2 +} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..8f0b063 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,134 @@ +# AGENTS.md + +## Status + +Scaffold is in place: Turborepo monorepo with `apps/api`, `apps/web` and `packages/shared`. +No CI, no database migrations and no product features yet. + +## Stack (source of truth: `STACK.md`) + +- Monorepo orchestrated with **Turborepo** +- Backend: **Bun** + **Hono**, **Prisma** against **Postgres**, **Zod** for validation, **Pino** for logging +- Frontend: **React + Vite + TypeScript**, UI components from **shadcn/ui** +- Auth: **BetterAuth** + +## Conventions + +- **Package manager: Bun** — `bun install`, `bun run + + diff --git a/apps/web/package.json b/apps/web/package.json new file mode 100644 index 0000000..94b92bd --- /dev/null +++ b/apps/web/package.json @@ -0,0 +1,55 @@ +{ + "name": "@superlist/web", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "routes:generate": "tsr generate", + "dev": "tsr generate && vite", + "build": "tsr generate && tsc -b && vite build", + "preview": "vite preview", + "lint": "oxlint", + "typecheck": "tsr generate && tsc -b", + "test": "vitest run --passWithNoTests" + }, + "dependencies": { + "@fontsource-variable/geist": "^5.3.0", + "@hookform/resolvers": "^5.9.1", + "@superlist/shared": "workspace:*", + "@tanstack/react-query": "^5.104.2", + "@tanstack/react-query-devtools": "^5.104.2", + "@tanstack/react-router": "^1.170.42", + "@tanstack/react-table": "^9.3.1", + "better-auth": "^1.7.7", + "class-variance-authority": "^0.7.1", + "clsx": "^2.1.1", + "cn": "^0.4.0", + "lucide-react": "^1.55.0", + "next-themes": "^0.4.6", + "radix-ui": "^1.8.0", + "react": "^19.2.8", + "react-dom": "^19.2.8", + "react-hook-form": "^7.90.0", + "recharts": "^3.10.1", + "sonner": "^2.0.8", + "tailwind-merge": "^3.7.0", + "zod": "^4.6.7" + }, + "devDependencies": { + "@tailwindcss/vite": "^4.3.3", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-cli": "^1.167.41", + "@tanstack/router-plugin": "^1.168.43", + "@types/node": "^24.13.3", + "@types/react": "^19.2.18", + "@types/react-dom": "^19.2.7", + "@vitejs/plugin-react": "^6.1.1", + "oxlint": "^1.81.0", + "shadcn": "^4.21.4", + "tailwindcss": "^4.3.3", + "tw-animate-css": "^1.4.0", + "typescript": "~6.0.2", + "vite": "^8.3.0", + "vitest": "^5.0.4" + } +} diff --git a/apps/web/src/components/layout/app-header.tsx b/apps/web/src/components/layout/app-header.tsx new file mode 100644 index 0000000..708bebf --- /dev/null +++ b/apps/web/src/components/layout/app-header.tsx @@ -0,0 +1,42 @@ +import { useRouterState } from '@tanstack/react-router' +import { SearchIcon } from 'lucide-react' + +import { Separator } from '@/components/ui/separator' +import { SidebarTrigger } from '@/components/ui/sidebar' +import { ThemeToggle } from '@/components/theme-toggle' + +function usePageTitle() { + const pathname = useRouterState({ select: (state) => state.location.pathname }) + + if (pathname === '/') return 'Dashboard' + + const segment = pathname.split('/').filter(Boolean).at(0) ?? '' + return segment.charAt(0).toUpperCase() + segment.slice(1) +} + +export function AppHeader() { + const title = usePageTitle() + + return ( +
+
+ + +

{title}

+
+ + +
+
+
+ ) +} diff --git a/apps/web/src/components/layout/app-sidebar.tsx b/apps/web/src/components/layout/app-sidebar.tsx new file mode 100644 index 0000000..562dfbd --- /dev/null +++ b/apps/web/src/components/layout/app-sidebar.tsx @@ -0,0 +1,78 @@ +import { Link, useRouterState } from '@tanstack/react-router' +import { LayoutDashboardIcon, ListTodoIcon, SettingsIcon } from 'lucide-react' +import type { LucideIcon } from 'lucide-react' + +import { NavUser } from '@/components/layout/nav-user' +import { + Sidebar, + SidebarContent, + SidebarFooter, + SidebarGroup, + SidebarGroupLabel, + SidebarHeader, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, + SidebarRail, +} from '@/components/ui/sidebar' + +type NavItem = { + title: string + to: string + icon: LucideIcon +} + +const NAV_ITEMS: NavItem[] = [ + { title: 'Dashboard', to: '/', icon: LayoutDashboardIcon }, + { title: 'Tasks', to: '/tasks', icon: ListTodoIcon }, + { title: 'Settings', to: '/settings', icon: SettingsIcon }, +] + +export function AppSidebar() { + const pathname = useRouterState({ select: (state) => state.location.pathname }) + + return ( + + + + + + +
+ SL +
+
+ Superlist + Admin +
+ +
+
+
+
+ + + + Platform + + {NAV_ITEMS.map((item) => ( + + + + + {item.title} + + + + ))} + + + + + + + + +
+ ) +} diff --git a/apps/web/src/components/layout/nav-user.tsx b/apps/web/src/components/layout/nav-user.tsx new file mode 100644 index 0000000..f8df1c5 --- /dev/null +++ b/apps/web/src/components/layout/nav-user.tsx @@ -0,0 +1,100 @@ +import { useNavigate } from '@tanstack/react-router' +import { ChevronsUpDownIcon, LogOutIcon, UserIcon } from 'lucide-react' + +import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu' +import { + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, + useSidebar, +} from '@/components/ui/sidebar' +import { signOut, useSession } from '@/lib/auth-client' + +function initials(name: string) { + return name + .split(' ') + .map((part) => part[0]) + .filter(Boolean) + .slice(0, 2) + .join('') + .toUpperCase() +} + +export function NavUser() { + const { isMobile } = useSidebar() + const { data: session } = useSession() + const navigate = useNavigate() + + const user = session?.user + const name = user?.name ?? 'Signed out' + const email = user?.email ?? '' + + return ( + + + + + + + + {initials(name) || '?'} + +
+ {name} + {email} +
+ +
+
+ + +
+ + {initials(name) || '?'} + +
+ {name} + {email} +
+
+
+ + + void navigate({ to: '/settings' })}> + + Account + + + + { + await signOut() + await navigate({ to: '/sign-in' }) + }} + > + + Sign out + +
+
+
+
+ ) +} diff --git a/apps/web/src/components/theme-provider.tsx b/apps/web/src/components/theme-provider.tsx new file mode 100644 index 0000000..1028b06 --- /dev/null +++ b/apps/web/src/components/theme-provider.tsx @@ -0,0 +1,11 @@ +import { ThemeProvider as NextThemesProvider } from 'next-themes' +import type { ComponentProps } from 'react' + +/** Wraps `next-themes` so the theme is toggled by a class on ``. */ +export function ThemeProvider({ children, ...props }: ComponentProps) { + return ( + + {children} + + ) +} diff --git a/apps/web/src/components/theme-toggle.tsx b/apps/web/src/components/theme-toggle.tsx new file mode 100644 index 0000000..5e8d8ab --- /dev/null +++ b/apps/web/src/components/theme-toggle.tsx @@ -0,0 +1,39 @@ +import { MonitorIcon, MoonIcon, SunIcon } from 'lucide-react' +import { useTheme } from 'next-themes' + +import { Button } from '@/components/ui/button' +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from '@/components/ui/dropdown-menu' + +const OPTIONS = [ + { value: 'light', label: 'Light', icon: SunIcon }, + { value: 'dark', label: 'Dark', icon: MoonIcon }, + { value: 'system', label: 'System', icon: MonitorIcon }, +] as const + +export function ThemeToggle() { + const { setTheme } = useTheme() + + return ( + + + + + + {OPTIONS.map(({ value, label, icon: Icon }) => ( + setTheme(value)}> + + {label} + + ))} + + + ) +} diff --git a/apps/web/src/components/ui/alert.tsx b/apps/web/src/components/ui/alert.tsx new file mode 100644 index 0000000..17ba728 --- /dev/null +++ b/apps/web/src/components/ui/alert.tsx @@ -0,0 +1,75 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "cn" + +const alertVariants = cva( + "group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4", + { + variants: { + variant: { + default: "bg-card text-card-foreground", + destructive: + "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Alert({ + className, + variant, + ...props +}: React.ComponentProps<"div"> & VariantProps) { + return ( +
+ ) +} + +function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { + return ( +
svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground", + className + )} + {...props} + /> + ) +} + +function AlertDescription({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AlertAction({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +export { Alert, AlertTitle, AlertDescription, AlertAction } diff --git a/apps/web/src/components/ui/avatar.tsx b/apps/web/src/components/ui/avatar.tsx new file mode 100644 index 0000000..89328b4 --- /dev/null +++ b/apps/web/src/components/ui/avatar.tsx @@ -0,0 +1,109 @@ +import * as React from "react" +import { cn } from "cn" +import { Avatar as AvatarPrimitive } from "radix-ui" + +function Avatar({ + className, + size = "default", + ...props +}: React.ComponentProps & { + size?: "default" | "sm" | "lg" +}) { + return ( + + ) +} + +function AvatarImage({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AvatarFallback({ + className, + ...props +}: React.ComponentProps) { + return ( + + ) +} + +function AvatarBadge({ className, ...props }: React.ComponentProps<"span">) { + return ( + svg]:hidden", + "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2", + "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2", + className + )} + {...props} + /> + ) +} + +function AvatarGroup({ className, ...props }: React.ComponentProps<"div">) { + return ( +
+ ) +} + +function AvatarGroupCount({ + className, + ...props +}: React.ComponentProps<"div">) { + return ( +
svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3", + className + )} + {...props} + /> + ) +} + +export { + Avatar, + AvatarImage, + AvatarFallback, + AvatarGroup, + AvatarGroupCount, + AvatarBadge, +} diff --git a/apps/web/src/components/ui/badge.tsx b/apps/web/src/components/ui/badge.tsx new file mode 100644 index 0000000..837196c --- /dev/null +++ b/apps/web/src/components/ui/badge.tsx @@ -0,0 +1,48 @@ +import * as React from "react" +import { cva, type VariantProps } from "class-variance-authority" +import { cn } from "cn" +import { Slot } from "radix-ui" + +const badgeVariants = cva( + "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!", + { + variants: { + variant: { + default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80", + secondary: + "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80", + destructive: + "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20", + outline: + "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground", + ghost: + "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50", + link: "text-primary underline-offset-4 hover:underline", + }, + }, + defaultVariants: { + variant: "default", + }, + } +) + +function Badge({ + className, + variant = "default", + asChild = false, + ...props +}: React.ComponentProps<"span"> & + VariantProps & { asChild?: boolean }) { + const Comp = asChild ? Slot.Root : "span" + + return ( + + ) +} + +export { Badge, badgeVariants } diff --git a/apps/web/src/components/ui/breadcrumb.tsx b/apps/web/src/components/ui/breadcrumb.tsx new file mode 100644 index 0000000..a522888 --- /dev/null +++ b/apps/web/src/components/ui/breadcrumb.tsx @@ -0,0 +1,121 @@ +import * as React from "react" +import { cn } from "cn" +import { Slot } from "radix-ui" +import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react" + +function Breadcrumb({ className, ...props }: React.ComponentProps<"nav">) { + return ( +