Skip to content

03 auth#2

Merged
abhiSingh-coder merged 2 commits into
mainfrom
03-auth
Apr 16, 2026
Merged

03 auth#2
abhiSingh-coder merged 2 commits into
mainfrom
03-auth

Conversation

@abhiSingh-coder

@abhiSingh-coder abhiSingh-coder commented Apr 15, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • New Features

    • Added authentication system with email and password login
  • Improvements

    • Updated visual design theme to Radix Nova for enhanced aesthetics
    • Enhanced button styling with improved interactions
    • Refined CSS theme variables and custom properties

@coderabbitai

coderabbitai Bot commented Apr 15, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR introduces a complete authentication system into the project. It updates the Shadcn UI theme from new-york to radix-nova, adds authentication dependencies (better-auth, clsx, shadcn, tailwind-merge), creates server-side authentication via better-auth with Drizzle ORM database integration, establishes client-side auth utilities, and replaces the basic user table with a comprehensive schema supporting sessions, accounts, and email verification.

Changes

Cohort / File(s) Summary
Configuration Updates
components.json, package.json
Updated Shadcn theme from new-york to radix-nova; added configuration fields for iconLibrary, rtl, menuColor, menuAccent, and registries; introduced dependencies for authentication (better-auth), CSS utilities (clsx, tailwind-merge, tw-animate-css), and component framework (shadcn).
Authentication Infrastructure
src/lib/auth.ts, src/lib/auth-client.ts, src/app/api/auth/[...all]/route.ts
Created backend authentication via betterAuth with Drizzle ORM adapter configured for PostgreSQL; established client-side auth wrapper through createAuthClient; wired Next.js API route handlers for authentication requests.
Database Schema
src/db/schema.ts
Replaced simple usersTable with comprehensive auth schema: user table (text PK with emailVerified, image, audit timestamps), session table (unique tokens with expiry and user FK), account table (external provider data with optional tokens and user FK), and verification table (email verification codes with identifier indexing).
Styling and Utilities
src/app/globals.css, src/lib/utils.ts, src/components/ui/button.tsx
Added Shadcn Tailwind stylesheet import; extended CSS theme variables with --font-heading and additional radius tokens; created cn utility function for Tailwind class conflict resolution; updated button component with new variant styling, attribute-selector based sizing, and enhanced focus/active states.

Sequence Diagram

sequenceDiagram
    actor Client
    participant AuthClient as authClient<br/>(Client-side)
    participant APIRoute as API Route<br/>auth/[...all]
    participant Auth as auth<br/>(Better-Auth)
    participant DB as Database<br/>(Drizzle + Postgres)

    Client->>AuthClient: Call auth function<br/>(login/signup)
    AuthClient->>APIRoute: POST/GET request<br/>to /api/auth/*
    APIRoute->>Auth: toNextJsHandler converts<br/>request to auth context
    Auth->>DB: Query/Insert user,<br/>session, account data
    DB-->>Auth: Return results
    Auth-->>APIRoute: Return response
    APIRoute-->>AuthClient: Send auth response<br/>(token, session)
    AuthClient-->>Client: Update client state
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • 02-db #1: Directly modifies src/db/schema.ts with conflicting schema definitions; this PR replaces the usersTable approach with a new auth-focused schema structure.

Poem

🐰 Hoppity-hop, authentication's here!
With Drizzle and sessions throughout the year,
Nova themes shimmer in radiant glow,
Better-auth magic makes users all go! ✨🔐

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title '03 auth' is vague and generic, using a branch-like identifier without clearly conveying the specific changes being made to the codebase. Use a more descriptive title that summarizes the main changes, such as 'Integrate better-auth authentication system' or 'Add authentication with database schema and API routes'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 03-auth

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (2)
src/app/api/auth/[...all]/route.ts (1)

1-1: Remove scaffold comment on Line 1.

// path to your auth file is stale/noisy in committed code.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/api/auth/`[...all]/route.ts at line 1, The scaffold comment in the
import line is noisy; remove the trailing comment from the import statement that
references the path (the line importing the auth symbol: import { auth } from
"@/lib/auth";) so the file only contains the clean import without the scaffold
comment, e.g., keep the import of auth and delete the "// path to your auth
file" comment.
src/db/schema.ts (1)

2-2: Unused import: relations

The relations import is not used anywhere in this file. Consider removing it to keep imports clean.

🧹 Proposed fix
-import { relations } from "drizzle-orm";
-import { pgTable, text, timestamp, boolean, index } from "drizzle-orm/pg-core";
+import { pgTable, text, timestamp, boolean, index } from "drizzle-orm/pg-core";
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/db/schema.ts` at line 2, Remove the unused import symbol "relations" from
the top-level import in this file; locate the import statement that reads import
{ relations } from "drizzle-orm" and delete the "relations" specifier (or remove
the entire import if nothing else is imported) so the module no longer contains
an unused import.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/globals.css`:
- Line 10: Replace the self-referential CSS variable assignment --font-sans:
var(--font-sans) with a reference to the actual font token used in layout.tsx
(e.g., change the value to var(--font-geist-sans)) so the CSS variable
--font-sans points to --font-geist-sans (matching the pattern used for
--font-mono) and resolves correctly.

In `@src/db/schema.ts`:
- Around line 25-27: The updatedAt column definition for the sessions table (the
timestamp("updated_at") chain) is missing .defaultNow(), causing INSERTs to
violate the NOT NULL constraint; update the timestamp("updated_at") chain for
updatedAt to include .defaultNow() (keep the existing .$onUpdate(() => new
Date()) and .notNull()) so it behaves like the user and verification table
definitions and supplies a default on INSERT while still updating on UPDATE.
- Around line 54-56: The updatedAt column definition is missing a default value
so INSERTs violate the NOT NULL constraint; update the updatedAt column (the
timestamp("updated_at") chain) to include .defaultNow() in the fluent chain
(keep the existing .$onUpdate(() => new Date()) and .notNull()) so the column
gets a default on INSERT and still updates on UPDATE.

---

Nitpick comments:
In `@src/app/api/auth/`[...all]/route.ts:
- Line 1: The scaffold comment in the import line is noisy; remove the trailing
comment from the import statement that references the path (the line importing
the auth symbol: import { auth } from "@/lib/auth";) so the file only contains
the clean import without the scaffold comment, e.g., keep the import of auth and
delete the "// path to your auth file" comment.

In `@src/db/schema.ts`:
- Line 2: Remove the unused import symbol "relations" from the top-level import
in this file; locate the import statement that reads import { relations } from
"drizzle-orm" and delete the "relations" specifier (or remove the entire import
if nothing else is imported) so the module no longer contains an unused import.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e3da54d3-97c4-4d3d-bf23-ca4a15d52f8f

📥 Commits

Reviewing files that changed from the base of the PR and between 85bb183 and 4fcd183.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • components.json
  • package.json
  • src/app/api/auth/[...all]/route.ts
  • src/app/globals.css
  • src/components/ui/button.tsx
  • src/db/index.ts
  • src/db/schema.ts
  • src/lib/auth-client.ts
  • src/lib/auth.ts
  • src/lib/utils.ts

Comment thread src/app/globals.css
--color-background: var(--background);
--color-foreground: var(--foreground);
--font-sans: var(--font-geist-sans);
--font-sans: var(--font-sans);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In Tailwind CSS v4, does @theme inline { --font-sans: var(--font-sans); } create a self-referential custom-property cycle, and what is the recommended pattern for mapping font tokens?

💡 Result:

Yes, @theme inline { --font-sans: var(--font-sans); } creates a self-referential custom-property cycle. This is a CSS specification limitation where a custom property referencing itself directly leads to cyclic dependency issues, preventing proper resolution. Tailwind CSS v4 discussions and issues confirm this behavior explicitly for font variables and similar cases. The recommended pattern for mapping font tokens in Tailwind CSS v4 is to fully redefine the --font-* theme variables (e.g., --font-sans) with your custom font stack followed by Tailwind's default fallbacks. Copy the default values from the official docs: @import "tailwindcss"; @theme { --font-sans: "Space Grokest", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; } To prepend without duplicating fallbacks (avoiding cycles), define a separate fallback variable first: @theme { --font-sans-fallback: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; --font-sans: "Space Grokest", var(--font-sans-fallback); } For referencing external font variables (e.g., from next/font), use @theme inline { --font-sans: var(--font-inter); } where --font-inter is a different variable defined outside the theme. Official docs recommend @theme inline specifically when a theme variable references another non-cyclic variable to ensure proper inlining in utilities and avoid resolution issues during CSS variable inheritance.

Citations:


🏁 Script executed:

cat -n src/app/globals.css

Repository: idforabhilaptop-png/Meet-Ai

Length of output: 5285


🏁 Script executed:

# Search for all CSS custom property definitions related to fonts
rg "^\s*--font-" src/app/globals.css

Repository: idforabhilaptop-png/Meet-Ai

Length of output: 178


🏁 Script executed:

# Check for Next.js font imports in relevant files
rg "@next/font" --type ts --type tsx --type js --type jsx

Repository: idforabhilaptop-png/Meet-Ai

Length of output: 98


🏁 Script executed:

# Search for layout files that might define fonts
fd -e tsx -e ts layout

Repository: idforabhilaptop-png/Meet-Ai

Length of output: 89


🏁 Script executed:

# Search for next/font imports
rg "@next/font|next/font" --type ts --type tsx --type js

Repository: idforabhilaptop-png/Meet-Ai

Length of output: 98


🏁 Script executed:

# Search for font variable definitions (--font-geist-sans, --font-inter, etc.)
rg "\-\-font-geist|--font-inter" --type css --type tsx --type ts --type jsx --type js

Repository: idforabhilaptop-png/Meet-Ai

Length of output: 98


🏁 Script executed:

cat -n src/app/layout.tsx

Repository: idforabhilaptop-png/Meet-Ai

Length of output: 997


🏁 Script executed:

# Search for font variable definitions without type restrictions
rg "\-\-font-"

Repository: idforabhilaptop-png/Meet-Ai

Length of output: 342


Fix self-referential font token on Line 10.

Line 10 creates a CSS variable cycle by mapping --font-sans to itself, breaking font resolution. The correct pattern is to reference --font-geist-sans, which is defined in layout.tsx and applied to the document body—matching the working pattern used for --font-mono on line 11.

💡 Proposed fix
-  --font-sans: var(--font-sans);
+  --font-sans: var(--font-geist-sans);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
--font-sans: var(--font-sans);
--font-sans: var(--font-geist-sans);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/globals.css` at line 10, Replace the self-referential CSS variable
assignment --font-sans: var(--font-sans) with a reference to the actual font
token used in layout.tsx (e.g., change the value to var(--font-geist-sans)) so
the CSS variable --font-sans points to --font-geist-sans (matching the pattern
used for --font-mono) and resolves correctly.

Comment thread src/db/schema.ts
Comment on lines +25 to +27
updatedAt: timestamp("updated_at")
.$onUpdate(() => /* @__PURE__ */ new Date())
.notNull(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Missing .defaultNow() on updatedAt will cause INSERT failures.

The updatedAt column is marked .notNull() but lacks .defaultNow(). The $onUpdate() hook only triggers on UPDATE operations, not INSERT. This will cause a NOT NULL constraint violation when creating new sessions.

Compare with the user table (line 12) and verification table (line 69) which correctly include .defaultNow().

🐛 Proposed fix
     updatedAt: timestamp("updated_at")
+      .defaultNow()
       .$onUpdate(() => /* `@__PURE__` */ new Date())
       .notNull(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
updatedAt: timestamp("updated_at")
.$onUpdate(() => /* @__PURE__ */ new Date())
.notNull(),
updatedAt: timestamp("updated_at")
.defaultNow()
.$onUpdate(() => /* `@__PURE__` */ new Date())
.notNull(),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/db/schema.ts` around lines 25 - 27, The updatedAt column definition for
the sessions table (the timestamp("updated_at") chain) is missing .defaultNow(),
causing INSERTs to violate the NOT NULL constraint; update the
timestamp("updated_at") chain for updatedAt to include .defaultNow() (keep the
existing .$onUpdate(() => new Date()) and .notNull()) so it behaves like the
user and verification table definitions and supplies a default on INSERT while
still updating on UPDATE.

Comment thread src/db/schema.ts
Comment on lines +54 to +56
updatedAt: timestamp("updated_at")
.$onUpdate(() => /* @__PURE__ */ new Date())
.notNull(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Same issue: Missing .defaultNow() on updatedAt.

Same problem as the session table - INSERT operations will fail due to NOT NULL constraint without a default value.

🐛 Proposed fix
     updatedAt: timestamp("updated_at")
+      .defaultNow()
       .$onUpdate(() => /* `@__PURE__` */ new Date())
       .notNull(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
updatedAt: timestamp("updated_at")
.$onUpdate(() => /* @__PURE__ */ new Date())
.notNull(),
updatedAt: timestamp("updated_at")
.defaultNow()
.$onUpdate(() => /* `@__PURE__` */ new Date())
.notNull(),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/db/schema.ts` around lines 54 - 56, The updatedAt column definition is
missing a default value so INSERTs violate the NOT NULL constraint; update the
updatedAt column (the timestamp("updated_at") chain) to include .defaultNow() in
the fluent chain (keep the existing .$onUpdate(() => new Date()) and .notNull())
so the column gets a default on INSERT and still updates on UPDATE.

@abhiSingh-coder abhiSingh-coder merged commit 9c8099f into main Apr 16, 2026
1 check passed
@abhiSingh-coder abhiSingh-coder deleted the 03-auth branch April 16, 2026 13:35
This was referenced Apr 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant