Skip to content

Convert to Cloudflare monorepo#3

Merged
iHildy merged 9 commits intomainfrom
cloudflare-monorepo
Dec 14, 2025
Merged

Convert to Cloudflare monorepo#3
iHildy merged 9 commits intomainfrom
cloudflare-monorepo

Conversation

@iHildy
Copy link
Owner

@iHildy iHildy commented Dec 14, 2025

still kept vercel-unorepo as a snapshot of the current main before this.

…e website to `apps/website` and database logic to `packages/db`.
…Prisma to Drizzle, and update website configuration for new packages and serverless deployment.
@vercel
Copy link

vercel bot commented Dec 14, 2025

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

Project Deployment Review Updated (UTC)
create-hildy-app Error Error Dec 14, 2025 7:49pm

@gemini-code-assist
Copy link

Summary of Changes

Hello @iHildy, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request represents a significant architectural shift, transforming the project into a Cloudflare-native pnpm monorepo. The core changes involve migrating the database from Prisma/Supabase to Drizzle ORM with Cloudflare D1, integrating Cloudflare R2 for object storage, and adopting BetterAuth for authentication. The project structure is now organized into distinct apps/ and packages/ workspaces, supported by a new setup.sh script to automate Cloudflare resource provisioning and initial configuration. This transition aims to leverage Cloudflare's edge capabilities for improved performance and scalability.

Highlights

  • Monorepo Conversion: The project has been restructured into a pnpm monorepo, organizing code into apps/ (for the Next.js website) and packages/ (for shared auth, database, and storage logic).
  • Cloudflare Native Stack: The entire infrastructure has shifted to Cloudflare, utilizing Cloudflare Workers for edge compute, D1 for SQLite database, and R2 for S3-compatible object storage.
  • Database Migration: The database layer has been completely revamped, moving from Prisma with PostgreSQL (Supabase) to Drizzle ORM with Cloudflare D1.
  • Authentication Integration: A new authentication solution, BetterAuth, has been integrated, providing secure email/password authentication with Drizzle adapter support.
  • Automated Setup Script: A comprehensive setup.sh script has been added to streamline the initial configuration of Cloudflare resources (D1, R2), generate secrets, and update project files.
  • Documentation Update: The README.md and AGENTS.md files have been extensively updated to reflect the new monorepo structure, Cloudflare tech stack, and associated best practices.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/slack-deploy-notify.yml
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This is an impressive and comprehensive refactoring to convert the project into a Cloudflare-native monorepo. The migration from Prisma/Supabase to Drizzle/D1 and the adoption of a pnpm workspace structure are well-executed and set a strong foundation for future development. The new packages for db, auth, and storage create clear separation of concerns, and the inclusion of a setup.sh script is a great addition for developer experience. I've identified a few areas for improvement to enhance robustness, type safety, and fix a minor bug in the setup script. Overall, this is an excellent pull request.

// This is a placeholder that will be replaced when running with wrangler dev
return createInnerTRPCContext({
headers: opts.req.headers,
db: {} as DbClient, // Will be replaced by actual binding in runtime

Choose a reason for hiding this comment

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

high

Using a type assertion {} as DbClient compromises type safety, even in a local development context. If the runtime injection by Wrangler fails or doesn't behave as expected (e.g., when running pnpm dev without wrangler dev), this could lead to runtime errors that are hard to debug because they are not caught by TypeScript. Consider creating a lightweight mock DbClient that either throws informative errors for all methods or provides a basic in-memory implementation. This would make the local development setup more robust and type-safe.

Comment on lines +9 to +11
accountId: process.env.CLOUDFLARE_ACCOUNT_ID!,
databaseId: process.env.CLOUDFLARE_D1_DATABASE_ID!,
token: process.env.CLOUDFLARE_D1_TOKEN!,

Choose a reason for hiding this comment

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

high

Using non-null assertions (!) for environment variables can mask configuration issues and lead to runtime errors if the variables are not set. It's safer to validate these variables at the start of the script and throw a clear, informative error if they are missing. This fail-fast approach makes configuration problems much easier to diagnose.

For example, you could add a small helper function:

function getRequiredEnv(key: string): string {
  const value = process.env[key];
  if (!value) throw new Error(`Missing required environment variable: ${key}`);
  return value;
}

// Then use it like this:
// accountId: getRequiredEnv('CLOUDFLARE_ACCOUNT_ID'),

Comment on lines +169 to +173
read -p "Enter the existing database ID (or press Enter to skip): " DATABASE_ID
if [ -z "$DATABASE_ID" ]; then
print_error "Database ID is required."
exit 1
fi

Choose a reason for hiding this comment

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

high

There's a logical contradiction here. The prompt on line 169 says (or press Enter to skip), but if the user presses Enter, DATABASE_ID becomes empty, and the check on line 170 causes the script to exit with an error. This will be confusing for the user.

The script should either handle the 'skip' case gracefully by using a placeholder and warning the user, or remove the 'skip' option from the prompt to avoid confusion.

Suggested change
read -p "Enter the existing database ID (or press Enter to skip): " DATABASE_ID
if [ -z "$DATABASE_ID" ]; then
print_error "Database ID is required."
exit 1
fi
read -p "Enter the existing database ID (or press Enter to skip manual entry): " DATABASE_ID
if [ -z "$DATABASE_ID" ]; then
print_warning "Skipping database ID entry. You will need to update wrangler.toml manually."
DATABASE_ID="YOUR_DATABASE_ID_HERE" # Use a placeholder
fi

AGENTS.md Outdated
# AGENTS RULES OVERVIEW

This document condenses the most critical rules for agents working on this repository. Note that YOU doesn't have access to enviormental variables and cannot run commands like `pnpm build` because of this, instead use `pnpm lint`
This document condenses the most critical rules for agents working on this repository. Note that YOU doesn't have access to environmental variables and cannot run commands like `pnpm build` because of this, instead use `pnpm lint`

Choose a reason for hiding this comment

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

medium

There's a small grammatical error in this line. When addressing YOU, it should be don't instead of doesn't.

Suggested change
This document condenses the most critical rules for agents working on this repository. Note that YOU doesn't have access to environmental variables and cannot run commands like `pnpm build` because of this, instead use `pnpm lint`
This document condenses the most critical rules for agents working on this repository. Note that YOU don't have access to environmental variables and cannot run commands like `pnpm build` because of this, instead use `pnpm lint`

@iHildy iHildy merged commit 9a2d940 into main Dec 14, 2025
1 of 2 checks passed
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