1
0
Fork 0
mirror of https://gitbruv.vercel.app/api/git/bruv/gitbruv.git synced 2025-12-20 23:24:09 +01:00
Find a file
Ahmet Kilinc 468781e311 linting
2025-12-20 12:07:05 +00:00
actions add tabs 2025-12-20 11:53:09 +00:00
app linting 2025-12-20 12:07:05 +00:00
components add tabs 2025-12-20 11:53:09 +00:00
db added 2025-12-20 04:46:30 +00:00
lib linting 2025-12-20 12:07:05 +00:00
.gitignore Initial commit from Create Next App 2025-12-20 01:21:13 +00:00
bun.lock add tabs 2025-12-20 11:53:09 +00:00
components.json mvp 2025-12-20 02:43:11 +00:00
drizzle.config.ts mvp 2025-12-20 02:43:11 +00:00
eslint.config.mjs Initial commit from Create Next App 2025-12-20 01:21:13 +00:00
next.config.ts wip 2025-12-20 03:15:55 +00:00
package.json add tabs 2025-12-20 11:53:09 +00:00
postcss.config.mjs Initial commit from Create Next App 2025-12-20 01:21:13 +00:00
README.md mvp 2025-12-20 02:43:11 +00:00
tsconfig.json Initial commit from Create Next App 2025-12-20 01:21:13 +00:00

gitbruv

A GitHub clone built with Next.js, featuring real Git repository support with Cloudflare R2 storage.

Tech Stack

  • Framework: Next.js 16 (App Router)
  • Auth: better-auth (email/password)
  • Database: PostgreSQL + Drizzle ORM
  • Storage: Cloudflare R2 (S3-compatible)
  • UI: shadcn/ui + Tailwind CSS
  • Data Fetching: TanStack React Query
  • Git: isomorphic-git + Git HTTP Smart Protocol

Getting Started

Prerequisites

  • Node.js 18+ or Bun
  • PostgreSQL database
  • Git installed on your system
  • Cloudflare account with R2 enabled

Cloudflare R2 Setup

  1. Go to Cloudflare Dashboard → R2
  2. Create a bucket named gitbruv-repos
  3. Go to R2 → Manage R2 API Tokens → Create API Token
  4. Select "Object Read & Write" permissions
  5. Copy the Account ID, Access Key ID, and Secret Access Key

Setup

  1. Clone and install dependencies:
bun install
  1. Create a .env file with the following variables:
DATABASE_URL=postgresql://postgres:password@localhost:5432/gitbruv
BETTER_AUTH_SECRET=your-secret-key-here-at-least-32-characters
BETTER_AUTH_URL=http://localhost:3000
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Cloudflare R2 Configuration
R2_ACCOUNT_ID=your-cloudflare-account-id
R2_ACCESS_KEY_ID=your-r2-access-key-id
R2_SECRET_ACCESS_KEY=your-r2-secret-access-key
R2_BUCKET_NAME=gitbruv-repos
  1. Push the database schema:
bun run db:push
  1. Start the development server:
bun run dev
  1. Open http://localhost:3000

Features

  • User authentication (sign up, sign in, sign out)
  • Create public/private repositories
  • Browse repository files
  • View file contents with syntax highlighting
  • Clone repositories via HTTP
  • Push to repositories via HTTP (with authentication)
  • Markdown README rendering
  • Cloud storage with Cloudflare R2 (zero egress fees)

Project Structure

app/
├── (auth)/          # Auth pages (login, register)
├── (main)/          # Main app pages
│   ├── [username]/  # User profile & repos
│   └── new/         # Create repository
├── api/
│   ├── auth/        # better-auth API
│   └── git/         # Git HTTP Smart Protocol
actions/             # Server actions
components/          # React components
db/                  # Database schema & connection
lib/                 # Utilities, auth config, R2 integration

Git Operations

Clone a repository:

git clone http://localhost:3000/api/git/username/repo.git

Push to a repository (requires auth):

git push origin main
# Enter your email and password when prompted

Architecture

Git repositories are stored in Cloudflare R2 as bare repos. When git operations occur:

  1. Repository files are synced from R2 to a temp directory
  2. Git commands execute against the temp directory
  3. For push operations, changes are synced back to R2
  4. Temp directory is cleaned up

This allows serverless deployment while maintaining full Git compatibility.