Skip to content

Conversation

@mdhruvil
Copy link
Owner

@mdhruvil mdhruvil commented Jan 3, 2026

Greptile Summary

This PR migrates the project from direct Wrangler configuration to Alchemy, a declarative infrastructure-as-code framework for Cloudflare. The change centralizes all Cloudflare resource configuration (D1 databases, Durable Objects, Workers) into alchemy.run.ts and replaces manual deployment workflows with Alchemy's automated deployment system.

Key Changes:

  • Replaced wrangler.jsonc and manual Worker config with alchemy.run.ts for declarative infrastructure
  • Updated deployment workflows to use Alchemy commands (alchemy deploy, alchemy destroy)
  • Added automated PR preview environments with GitHub comment integration
  • Replaced auto-generated worker-configuration.d.ts with cleaner env.d.ts using Alchemy's type inference
  • Migrated from @cloudflare/vite-plugin to Alchemy's Vite plugin for TanStack Start
  • Added pnpm overrides for libsodium-wrappers compatibility

Benefits:

  • Automated preview deployments for every PR with automatic cleanup
  • Type-safe environment configuration through Alchemy
  • Simplified deployment process with single source of truth
  • Better integration between infrastructure and application code

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • Well-structured migration to Alchemy with clean configuration and proper error handling. All infrastructure resources are properly defined with appropriate bindings. The GitHub workflows follow best practices with environment protection and proper cleanup. No logic errors, security issues, or style violations detected.
  • No files require special attention

Important Files Changed

Filename Overview
.github/workflows/pr-preview.yml Added PR preview workflow with deploy and cleanup jobs using Alchemy
.github/workflows/publish.yml Added production deployment workflow for main branch using Alchemy
apps/web/alchemy.run.ts New Alchemy configuration defining infrastructure, bindings, and GitHub comment automation
apps/web/env.d.ts Added TypeScript types for Cloudflare environment from Alchemy configuration
apps/web/package.json Updated scripts to use Alchemy commands and added Alchemy dependencies
apps/web/vite.config.ts Replaced @cloudflare/vite-plugin with Alchemy's Vite plugin for TanStack Start

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant GH as GitHub Actions
    participant Alchemy as Alchemy CLI
    participant CF as Cloudflare
    participant App as TanStack Start App

    alt PR Preview Flow
        Dev->>GH: Push to PR
        GH->>GH: Trigger pr-preview workflow
        GH->>Alchemy: pnpm deploy (STAGE=pr-N)
        Alchemy->>Alchemy: Read alchemy.run.ts config
        Alchemy->>CF: Create D1 Database (gitflare-db)
        Alchemy->>CF: Create Durable Object (Repo)
        Alchemy->>CF: Deploy Worker with bindings
        CF-->>Alchemy: Return preview URL
        Alchemy->>GH: Post comment with preview URL
        GH-->>Dev: Display preview comment on PR
        App->>CF: Access REPO, DB, and env bindings
    else Production Deploy
        Dev->>GH: Merge to main
        GH->>GH: Trigger publish workflow
        GH->>Alchemy: pnpm deploy (STAGE=prod)
        Alchemy->>Alchemy: Read alchemy.run.ts config
        Alchemy->>CF: Update/Create D1 Database
        Alchemy->>CF: Update/Create Durable Object
        Alchemy->>CF: Deploy to custom domain
        CF-->>Alchemy: Deployment complete
        App->>CF: Access REPO, DB, and env bindings
    else PR Closed
        Dev->>GH: Close PR
        GH->>GH: Trigger cleanup-preview job
        GH->>Alchemy: pnpm destroy (STAGE=pr-N)
        Alchemy->>CF: Delete preview resources
        CF-->>Alchemy: Resources deleted
    end
Loading

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 3, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch mdhruvil/setup-alchemy

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.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

13 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link

github-actions bot commented Jan 3, 2026

🚀 Preview Deployed

Your preview is ready!

Preview URL: https://gitflare-web-pr-29.mdhruvil.workers.dev

This preview was built from commit 21261f4


🤖 This comment will be updated automatically when you push new commits to this PR.

@mdhruvil
Copy link
Owner Author

mdhruvil commented Jan 3, 2026

🚀 Preview Deployed

Your preview is ready!

Preview URL: https://gitflare-web-pr-29.mdhruvil.workers.dev

This preview was built from commit cf24df5


🤖 This comment will be updated automatically when you push new commits to this PR.

@mdhruvil
Copy link
Owner Author

mdhruvil commented Jan 3, 2026

@greptileai

@greptile-apps
Copy link

greptile-apps bot commented Jan 3, 2026

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@mdhruvil mdhruvil merged commit 0b5c9d7 into the-great-rewrite Jan 3, 2026
4 checks passed
mdhruvil added a commit that referenced this pull request Jan 3, 2026
* feat: migrate to D1 (#28)

* chore: add libraries as submodule for context to the AI agents

* chore: add .context to zed `file_scan_exclusions`

* chore: exclude .context from search in vscode compat

* feat: add better auth config and drizzle schema

* feat: add db functions

* feat: migrate better auth from convext to d1

* feat: migrate to d1

* feat: nuke convex stuff

* chore: remove convex from the other files

* feat: add @tanstack/react-router-ssr-query integration and update related components

* refactor: update issue and pull request database schema to use integer for repositoryId, adjust issue creation logic to increment issue number based on last number

* feat: add new migration entry and enhance issue refetching logic in RouteComponent

* feat: setup alchemy (#29)

* feat: setup alchemy

* fix(ci): pnpm not found error

* fix(ci): use STAGE env var instead of flag

* fix(ci): use right command to deploy

* fix(ci): use right url

* fix(ci): resolve 5XX in auth endpoints

* fix(ci): use alchemy.env

* fix(ci): test if console.log appears in logs or not

* fix(ci): require permission on pr-preview workflow run

* fix(ci): remove logging

plus testing the permissions

* fix(ci): shared vars in preview.yml

* fix(ci): it works now ??
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.

2 participants