sailfork / t3code-github / .repos/ alchemy-effect/ website/ src/ content/ docs/ git/ recipes/ index.mdx

The examples use Authentication from Getting Started: the application's request middleware.

Start from the graph the tutorial built and change the lines your requirements touch:

const GitLive = Git.ApiLive.pipe(
  Layer.provide(Git.ApiHandlersLive),
  Layer.provide(Authentication.layer),
  Layer.provide(Git.ReposDurableObject),
  Layer.provide(Git.RegistryDurableObject),
  Layer.provide(Git.HasherInline),
  Layer.provide(Git.BlobStoreR2(GitObjects)),
);
You needChangeWhere
Everything on one Cloudflare accountnothingAll on Cloudflare
Large pushes verified fast, still on one cloudHasherWorkerLoader()Scaling
Bytes stored in AWSBlobStoreS3(bucket)Bytes in S3, hashing on Lambda
The widest push parallelismHasherLambda(HasherFunction)Bytes in S3, hashing on Lambda
Bytes somewhere that is neither R2 nor S3your own BlobStoreBring your own store
Registry reads near users everywhere, SQL over the indexRegistryD1(RepoIndex)Registry
Your own users and credentialsyour HttpRouter middlewareTutorial Part 4
Branch rulesapplication handlers + Git.EngineTutorial Part 6
Your web app and git on one domaina front-door WorkerApplication example

Every row is independent. Bytes in S3 with the loader hasher and a D1 registry is three changed lines, and the type checker confirms the graph is whole. Scaling is the why behind the first four rows.

One cloud or two

A graph that only touches Cloudflare deploys with Cloudflare's providers:

export default Alchemy.Stack(
  "GitService",
  { providers: Cloudflare.providers(), state: Cloudflare.state() },
  Effect.gen(function* () {
    const git = yield* GitHost;
    return { url: git.url.as<string>() };
  }),
);

A graph that declares a Lambda or reads S3 carries both provider sets. The stack is otherwise identical, and Alchemy creates what each cloud needs:

export default Alchemy.Stack(
  "GitService",
-  { providers: Cloudflare.providers(), state: Cloudflare.state() },
+  {
+    providers: Layer.mergeAll(Cloudflare.providers(), AWS.providers()),
+    state: Cloudflare.state(),
+  },
  Effect.gen(function* () {
    const git = yield* GitHost;
    return { url: git.url.as<string>() };
  }),
);