The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Local Development Docs
Steven Teyc663f8a3a30c
diff --git a/apps/docs/local-development.mdx b/apps/docs/local-development.mdxnew file mode 100644index 0000000000..35b5a344f2--- /dev/null+++ b/apps/docs/local-development.mdx@@ -0,0 +1,64 @@+---+title: "Local Development"+description: "A guide on how to run Dub's codebase locally."+---++<img+ className="rounded-lg border border-gray-100"+ src="https://dub.co/_static/thumbnail.png"+ alt="Dub.co Thumbnail"+/>++## Introduction++Dub's codebase is set up in a monorepo (via [Turborepo](https://turbo.build/repo)) and is fully [open-source on GitHub](https://github.com/dubinc/dub).++Here's the monorepo structure:++```+apps+├── docs+├── web+packages+├── tailwind-config+├── tinybird+├── tsconfig+├── ui+├── utils+```++The `apps` directory contains the code for:++- `web`: The entirety of Dub's application ([app.dub.co](https://app.dub.co)) + our link redirect infrastructure.+- `docs`: Dub's documentation site ([dub.co/docs](https://dub.co/docs)) – including this page you're on right now!++The `packages` directory contains the code for:++- `tailwind-config`: The Tailwind CSS configuration for Dub's web app.+- `tinybird`: Dub's Tinybird configuration.+- `tsconfig`: The TypeScript configuration for Dub's web app.+- `ui`: Dub's UI component library.+- `utils`: A collection of utility functions and constants used across Dub's codebase.++## How `app.dub.co` works++Dub's web app is built with [Next.js](https://nextjs.org) and [TailwindCSS](https://tailwindcss.com).++It also utilizes code from the `packages` directory, specifically the `@dub/ui` and `@dub/utils` packages.++All of the code for the web app is located in here: [`main`/apps/web/app/app.dub.co](https://github.com/dubinc/dub/tree/main/apps/web/app/app.dub.co)++There's also the API server, which is located in here: [`main`/apps/web/app/api](https://github.com/dubinc/dub/tree/main/apps/web/app/api)++## How link redirects work on Dub++Link redirects on Dub are powered by [Next.js Middleware](https://nextjs.org/docs/app/building-your-application/routing/middleware).++To handle high traffic, we use Redis to cache every link's metadata when it's first created. This allows us to serve redirects without hitting our MySQL database.++Here's the code that powers link redirects:++- Link redirects: [`main`/apps/web/lib/middleware/link.ts](https://github.com/dubinc/dub/blob/main/apps/web/lib/middleware/link.ts).+- Root domain redirects: [`main`/apps/web/lib/middleware/root.ts](https://github.com/dubinc/dub/blob/main/apps/web/lib/middleware/root.ts).++## Running Dub locallydiff --git a/apps/docs/mint.json b/apps/docs/mint.jsonindex 1073689b10..8c0ed0b898 100644--- a/apps/docs/mint.json+++ b/apps/docs/mint.json@@ -61,7 +61,7 @@"navigation": [{"group": "Getting Started",- "pages": ["introduction", "self-hosting/guide"]+ "pages": ["introduction", "local-development", "self-hosting/guide"]},{"group": "Integrations",