Skip to content

fix(web): improve stack builder logic - #737

Merged
AmanVarshney01 merged 1 commit into
mainfrom
improve-stack-builder
Dec 19, 2025
Merged

fix(web): improve stack builder logic#737
AmanVarshney01 merged 1 commit into
mainfrom
improve-stack-builder

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Dec 19, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Removed redundant CSS styling from home page layout
    • Simplified statistics display by removing the 30-day period indicator and updating labels for clarity
  • Improvements

    • Enhanced stack compatibility analysis with improved auto-adjustments and comprehensive handling of feature interactions across backend, runtime, database, deployment, and related options

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel

vercel Bot commented Dec 19, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
create-better-t-stack-web Ready Ready Preview, Comment Dec 19, 2025 6:48pm

@coderabbitai

coderabbitai Bot commented Dec 19, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This PR consolidates stack compatibility logic into a centralized analyzeStackCompatibility function while simplifying the stats section by removing helper functions and inlining computations. It also fixes a minor CSS redundancy.

Changes

Cohort / File(s) Summary
Stack Compatibility Refactor
apps/web/src/app/(home)/new/_components/utils.ts
Added analyzeStackCompatibility() function centralizing cascading constraint rules for backend, runtime, database, ORM, API, auth, payments, addons, examples, and deployment. Replaced distributed inline checks with consolidated analysis. Added getDisabledReason() and isOptionCompatible() helpers to detail compatibility constraints. Enhanced handling for Convex, self-fullstack variants, Workers runtime, MongoDB/relational DB mappings, and cross-field dependencies.
Analytics Data Simplification
apps/web/src/app/(home)/_components/stats-section.tsx
Removed DailyStats type and computeStats helper function. Replaced with inline computations for totalProjects and avgProjectsPerDay derived from stats and dailyStats. Removed "Last 30 days" badge, renamed label to "Total Projects", and adjusted lastUpdated rendering with fallback to current date.
CSS Cleanup
apps/web/src/app/(home)/page.tsx
Removed redundant mx-auto class from main container wrapper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • utils.ts requires careful review of the new analyzeStackCompatibility function's constraint logic, particularly:
    • Cascading rules across backend, runtime, database, ORM, and deployment fields
    • Edge cases for Convex, self-fullstack variants, Workers runtime, and MongoDB mappings
    • The getDisabledReason() logic ensuring consistency with constraint enforcement
  • stats-section.tsx needs verification that inline computations correctly replace the removed helper and that data sources align
  • page.tsx is trivial but included for completeness

Possibly related PRs

  • PR #458: Modifies Convex/Nuxt stack compatibility logic and shared compatibility helpers
  • PR #555: Extends cross-field constraint rules (Workers ↔ serverDeploy) and enhances isOptionCompatible/getDisabledReason behavior
  • PR #419: Alters stack compatibility analysis for ORM and database selection (Prisma-Postgres, MongoDB/relational mapping)

Poem

🐰 Constraints now dance in harmony's refrain,
One function rules them all, again and again,
Stats shed their helpers, streamlined and lean,
The cleanest stack builder ever seen!

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'fix(web): improve stack builder logic' is vague and overly broad, using generic terms like 'improve' that don't convey specific information about the changeset. The PR involves significant refactoring (analyzeStackCompatibility function, stats computation changes, UI label adjustments) but the title lacks specificity about what was actually improved. Consider a more specific title such as 'refactor: centralize stack compatibility analysis logic' or 'refactor: simplify stats computation in home page' to clearly indicate the main technical changes.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-stack-builder

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.

@AmanVarshney01
AmanVarshney01 merged commit 27b1bdd into main Dec 19, 2025
3 of 4 checks passed
@AmanVarshney01
AmanVarshney01 deleted the improve-stack-builder branch December 19, 2025 18:50

@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: 0

🧹 Nitpick comments (4)
apps/web/src/app/(home)/_components/stats-section.tsx (1)

72-77: Consider a clearer fallback for missing lastUpdated.

Displaying the current date when lastUpdated is null could mislead users into thinking data was recently updated. Consider showing "—" or "N/A" instead to indicate missing data.

🔎 Suggested change
                 <span className="truncate font-mono text-accent">
-                  {lastUpdated ||
-                    new Date().toLocaleDateString("en-US", {
-                      month: "short",
-                      day: "numeric",
-                      year: "numeric",
-                    })}
+                  {lastUpdated || "—"}
                 </span>
apps/web/src/app/(home)/new/_components/utils.ts (3)

39-43: Use type alias instead of interface per coding guidelines.

As per coding guidelines, TypeScript type aliases are preferred over interface declarations.

🔎 Suggested change
-interface CompatibilityResult {
-  adjustedStack: StackState | null;
-  notes: Record<string, { notes: string[]; hasIssue: boolean }>;
-  changes: Array<{ category: string; message: string }>;
-}
+type CompatibilityResult = {
+  adjustedStack: StackState | null;
+  notes: Record<string, { notes: string[]; hasIssue: boolean }>;
+  changes: Array<{ category: string; message: string }>;
+};

50-50: Consider using standard function declaration per coding guidelines.

The coding guidelines specify using standard function declarations instead of arrow functions. However, given this is a large function and the pattern is consistent throughout the file, this is a low-priority refactor.


490-516: Minor redundancy in Polar payment checks.

Multiple independent conditions can set payments = "none" and push changes. If multiple conditions are true, duplicate change messages could be added. Consider consolidating these checks.

🔎 Suggested consolidation
   if (nextStack.payments === "polar") {
-    if (nextStack.auth !== "better-auth") {
-      nextStack.payments = "none";
-      changed = true;
-      changes.push({
-        category: "payments",
-        message: "Payments set to 'None' (Polar requires Better Auth)",
-      });
-    }
-    if (nextStack.backend === "convex") {
-      nextStack.payments = "none";
-      changed = true;
-      changes.push({
-        category: "payments",
-        message: "Payments set to 'None' (Polar incompatible with Convex)",
-      });
-    }
     const hasWebFrontend = nextStack.webFrontend.some((f) => f !== "none");
-    if (!hasWebFrontend) {
+    const polarIncompatible =
+      nextStack.auth !== "better-auth" ||
+      nextStack.backend === "convex" ||
+      !hasWebFrontend;
+    
+    if (polarIncompatible) {
       nextStack.payments = "none";
       changed = true;
-      changes.push({
-        category: "payments",
-        message: "Payments set to 'None' (Polar requires web frontend)",
-      });
+      const reason = nextStack.auth !== "better-auth"
+        ? "Polar requires Better Auth"
+        : nextStack.backend === "convex"
+        ? "Polar incompatible with Convex"
+        : "Polar requires web frontend";
+      changes.push({ category: "payments", message: `Payments set to 'None' (${reason})` });
     }
   }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d686b1 and 9c8d9c3.

📒 Files selected for processing (3)
  • apps/web/src/app/(home)/_components/stats-section.tsx (4 hunks)
  • apps/web/src/app/(home)/new/_components/utils.ts (3 hunks)
  • apps/web/src/app/(home)/page.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)

Define functions using the standard function declaration syntax, not arrow functions

Files:

  • apps/web/src/app/(home)/_components/stats-section.tsx
  • apps/web/src/app/(home)/page.tsx
  • apps/web/src/app/(home)/new/_components/utils.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)

**/*.{ts,tsx}: Use TypeScript type aliases instead of interface declarations
Do not use explicit return types

Files:

  • apps/web/src/app/(home)/_components/stats-section.tsx
  • apps/web/src/app/(home)/page.tsx
  • apps/web/src/app/(home)/new/_components/utils.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

**/*.{ts,tsx,js,jsx}: Use bun <file> instead of node <file> or ts-node <file> for running TypeScript/JavaScript files
Bun automatically loads .env files, so don't use the dotenv package
Use Bun.serve() which supports WebSockets, HTTPS, and routes instead of express
Use bun:sqlite module for SQLite instead of better-sqlite3
Use Bun.redis for Redis instead of ioredis
Use Bun.sql for Postgres instead of pg or postgres.js
Use built-in WebSocket instead of the ws package
Prefer Bun.file over node:fs readFile/writeFile methods
Use Bun.$ template literal syntax instead of execa for shell command execution
Import .css files directly in TypeScript/JavaScript files; Bun's CSS bundler will handle bundling
Run server with bun --hot <file> to enable hot reloading during development

Files:

  • apps/web/src/app/(home)/_components/stats-section.tsx
  • apps/web/src/app/(home)/page.tsx
  • apps/web/src/app/(home)/new/_components/utils.ts
**/*.{ts,tsx,js,jsx,css}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use bun build <file> instead of webpack or esbuild for bundling TypeScript, JavaScript, and CSS files

Files:

  • apps/web/src/app/(home)/_components/stats-section.tsx
  • apps/web/src/app/(home)/page.tsx
  • apps/web/src/app/(home)/new/_components/utils.ts
**/*.{html,tsx,ts,jsx,js}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

Use HTML imports with Bun.serve() for frontend instead of Vite

Files:

  • apps/web/src/app/(home)/_components/stats-section.tsx
  • apps/web/src/app/(home)/page.tsx
  • apps/web/src/app/(home)/new/_components/utils.ts
🔇 Additional comments (11)
apps/web/src/app/(home)/page.tsx (1)

24-24: Good fix removing the duplicate mx-auto class.

apps/web/src/app/(home)/_components/stats-section.tsx (2)

21-23: Verify the average calculation logic.

The calculation totalProjects / dailyStats.length assumes dailyStats contains one entry per day. If dailyStats has gaps (non-consecutive days) or represents something other than daily entries, this average may be misleading.


45-65: LGTM!

The UI bindings correctly use the new inline computed values, and the label change accurately reflects the removal of the 30-day scope.

apps/web/src/app/(home)/new/_components/utils.ts (8)

73-94: LGTM!

The Convex backend constraints correctly override dependent options and track changes appropriately.


153-187: LGTM!

The "no backend" constraints correctly cascade to disable all backend-dependent options.


189-229: LGTM!

Fullstack backend constraints correctly enforce runtime/serverDeploy to none and ensure the appropriate frontend is selected.


236-262: LGTM!

The Workers runtime constraints correctly enforce Hono backend, server deployment, and handle MongoDB incompatibility by switching to SQLite with D1.


285-362: LGTM!

The database and ORM constraints correctly handle the interdependencies, including MongoDB requiring Prisma/Mongoose and relational DBs requiring Drizzle/Prisma.


364-457: LGTM!

The DB Setup constraints correctly enforce database requirements for each setup option and handle incompatibilities appropriately.


609-922: Well-structured disabled reason logic with clear documentation.

The function correctly implements the philosophy of only disabling truly incompatible options while allowing selections that trigger auto-adjustments. The sectioned comments improve readability.


924-933: LGTM!

Clean wrapper function that correctly handles YOLO mode bypass and delegates to getDisabledReason.

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